summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralanh <alanh>2000-07-10 20:44:39 +0000
committeralanh <alanh>2000-07-10 20:44:39 +0000
commit60e42e23e9d16503c30e461581d215356086820c (patch)
tree1312135ca14bfca015c1fd32bf27d535a1da79b5
parente8573a3e7daa0bd83c906ede920e2450527984e0 (diff)
Initial revision
-rw-r--r--xc/extras/Mesa/src/X/xfonts.h38
-rw-r--r--xc/extras/Mesa/src/glext_proto.h1757
-rw-r--r--xc/extras/rman/ANNOUNCE-rman78
-rw-r--r--xc/extras/rman/CHANGES100
-rw-r--r--xc/extras/rman/MANIFEST28
-rw-r--r--xc/extras/rman/Makefile166
-rw-r--r--xc/extras/rman/Makefile.mac105
-rw-r--r--xc/extras/rman/README-rman69
-rw-r--r--xc/extras/rman/contrib/README-contrib147
-rw-r--r--xc/extras/rman/contrib/authried.txt36
-rw-r--r--xc/extras/rman/contrib/bennett.txt371
-rw-r--r--xc/extras/rman/contrib/gzip.patch46
-rwxr-xr-xxc/extras/rman/contrib/hman.cgi7
-rwxr-xr-xxc/extras/rman/contrib/hman.ksh9
-rwxr-xr-xxc/extras/rman/contrib/hman.pl261
-rw-r--r--xc/extras/rman/contrib/http-rman.c200
-rw-r--r--xc/extras/rman/contrib/http-rman.html21
-rw-r--r--xc/extras/rman/contrib/lewis.pl17
-rwxr-xr-xxc/extras/rman/contrib/man2html108
-rwxr-xr-xxc/extras/rman/contrib/rman_html_split324
-rw-r--r--xc/extras/rman/contrib/rman_html_split.171
-rwxr-xr-xxc/extras/rman/contrib/sco-wrapper.sh6
-rw-r--r--xc/extras/rman/contrib/sutter.txt155
-rwxr-xr-xxc/extras/rman/contrib/youki.pl195
-rw-r--r--xc/extras/rman/getopt.c79
-rw-r--r--xc/extras/rman/macish.c6
-rw-r--r--xc/extras/rman/rman.1269
-rw-r--r--xc/extras/rman/rman.c5460
-rw-r--r--xc/extras/rman/rman.html322
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/Imakefile234
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c348
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_context.h197
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c123
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_dd.h36
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c192
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_depth.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h28
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_fog.c73
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c275
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h261
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h28
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c84
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h11
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_points.c155
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_points.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h114
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_span.c133
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_span.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_state.c1400
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_state.h13
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c200
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c292
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h324
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c318
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h63
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c547
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h33
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/Imakefile315
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_alloc.c447
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_clear.c570
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_common.h190
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_ctx.c840
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_ctx.h255
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_debug.c138
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_debug.h11
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c193
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_fog.c141
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_init.h260
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h243
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_lock.h102
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_mesa.c1542
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_mesa.h201
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_reg.h948
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_render.c491
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_span.c285
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_stencil.c149
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h153
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_texture.c884
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h91
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c962
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c432
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h557
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_xwin.c171
-rw-r--r--xc/lib/X11/lcUniConv/iso8859_13.h91
-rw-r--r--xc/lib/X11/lcUniConv/utf8.h110
-rw-r--r--xc/lib/Xaw6/Xaw6os2.def205
-rw-r--r--xc/lib/Xaw6/Xaw6os2.rsp10
-rw-r--r--xc/lib/dps/dpsops.h.os21601
-rw-r--r--xc/lib/dps/dpsos2.def854
-rw-r--r--xc/lib/dps/dpsos2.rsp13
-rw-r--r--xc/lib/dps/genheader.cmd14
-rw-r--r--xc/lib/dps/psops.h.os21602
-rw-r--r--xc/lib/dpstk/dpstkos2.def69
-rw-r--r--xc/lib/dpstk/dpstkos2.rsp4
-rw-r--r--xc/lib/psres/psresos2.def29
-rw-r--r--xc/lib/psres/psresos2.rsp3
100 files changed, 31169 insertions, 0 deletions
diff --git a/xc/extras/Mesa/src/X/xfonts.h b/xc/extras/Mesa/src/X/xfonts.h
new file mode 100644
index 000000000..1fe67f980
--- /dev/null
+++ b/xc/extras/Mesa/src/X/xfonts.h
@@ -0,0 +1,38 @@
+
+/*
+ * 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.
+ */
+
+
+#ifndef XFONTS_H
+#define XFONTS_H
+
+
+#include <X11/Xlib.h>
+
+
+extern void Fake_glXUseXFont( Font font, int first, int count, int listbase );
+
+
+#endif
+
diff --git a/xc/extras/Mesa/src/glext_proto.h b/xc/extras/Mesa/src/glext_proto.h
new file mode 100644
index 000000000..6f7e21535
--- /dev/null
+++ b/xc/extras/Mesa/src/glext_proto.h
@@ -0,0 +1,1757 @@
+#ifndef __glext_proto_h_
+#define __glext_proto_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** 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 (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN32)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
+/*************************************************************/
+
+/* OpenGL ABI for Linux version number */
+#define GLEXT_VERSION_EXT 5
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_BLEND_COLOR 0x8005
+#define GL_FUNC_ADD 0x8006
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_BLEND_EQUATION 0x8009
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_CONVOLUTION_1D 0x8010
+#define GL_CONVOLUTION_2D 0x8011
+#define GL_SEPARABLE_2D 0x8012
+#define GL_CONVOLUTION_BORDER_MODE 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS 0x8015
+#define GL_REDUCE 0x8016
+#define GL_CONVOLUTION_FORMAT 0x8017
+#define GL_CONVOLUTION_WIDTH 0x8018
+#define GL_CONVOLUTION_HEIGHT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
+#define GL_HISTOGRAM 0x8024
+#define GL_PROXY_HISTOGRAM 0x8025
+#define GL_HISTOGRAM_WIDTH 0x8026
+#define GL_HISTOGRAM_FORMAT 0x8027
+#define GL_HISTOGRAM_RED_SIZE 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
+#define GL_HISTOGRAM_SINK 0x802D
+#define GL_MINMAX 0x802E
+#define GL_MINMAX_FORMAT 0x802F
+#define GL_MINMAX_SINK 0x8030
+#define GL_TABLE_TOO_LARGE 0x8031
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_RESCALE_NORMAL 0x803A
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_COLOR_MATRIX 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
+#define GL_COLOR_TABLE 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
+#define GL_PROXY_COLOR_TABLE 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
+#define GL_COLOR_TABLE_SCALE 0x80D6
+#define GL_COLOR_TABLE_BIAS 0x80D7
+#define GL_COLOR_TABLE_FORMAT 0x80D8
+#define GL_COLOR_TABLE_WIDTH 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_TEXTURE0_ARB 0x84C0
+#define GL_TEXTURE1_ARB 0x84C1
+#define GL_TEXTURE2_ARB 0x84C2
+#define GL_TEXTURE3_ARB 0x84C3
+#define GL_ACTIVE_TEXTURE_ARB 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
+#define GL_MAX_ACTIVE_TEXTURES_ARB 0x84E2
+#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6
+#define GL_MULTISAMPLE_ARB 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
+#define GL_SAMPLE_COVERAGE_ARB 0x80A0
+#define GL_SAMPLE_BUFFERS_ARB 0x80A8
+#define GL_SAMPLES_ARB 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
+#define GL_MULTISAMPLE_BIT_ARB 0x20000000
+#define GL_NORMAL_MAP_ARB 0x8511
+#define GL_REFLECTION_MAP_ARB 0x8512
+#define GL_TEXTURE_CUBE_MAP_ARB 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
+#define GL_COMPRESSED_ALPHA_ARB 0x84E9
+#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
+#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
+#define GL_COMPRESSED_RGB_ARB 0x84ED
+#define GL_COMPRESSED_RGBA_ARB 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
+#define GL_TEXTURE_IMAGE_SIZE_ARB 0x86A0
+#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
+#define GL_ABGR_EXT 0x8000
+#define GL_CONSTANT_COLOR_EXT 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
+#define GL_CONSTANT_ALPHA_EXT 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
+#define GL_BLEND_COLOR_EXT 0x8005
+#define GL_POLYGON_OFFSET_EXT 0x8037
+#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038
+#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039
+#define GL_ALPHA4_EXT 0x803B
+#define GL_ALPHA8_EXT 0x803C
+#define GL_ALPHA12_EXT 0x803D
+#define GL_ALPHA16_EXT 0x803E
+#define GL_LUMINANCE4_EXT 0x803F
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE12_EXT 0x8041
+#define GL_LUMINANCE16_EXT 0x8042
+#define GL_LUMINANCE4_ALPHA4_EXT 0x8043
+#define GL_LUMINANCE6_ALPHA2_EXT 0x8044
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_LUMINANCE12_ALPHA4_EXT 0x8046
+#define GL_LUMINANCE12_ALPHA12_EXT 0x8047
+#define GL_LUMINANCE16_ALPHA16_EXT 0x8048
+#define GL_INTENSITY_EXT 0x8049
+#define GL_INTENSITY4_EXT 0x804A
+#define GL_INTENSITY8_EXT 0x804B
+#define GL_INTENSITY12_EXT 0x804C
+#define GL_INTENSITY16_EXT 0x804D
+#define GL_RGB2_EXT 0x804E
+#define GL_RGB4_EXT 0x804F
+#define GL_RGB5_EXT 0x8050
+#define GL_RGB8_EXT 0x8051
+#define GL_RGB10_EXT 0x8052
+#define GL_RGB12_EXT 0x8053
+#define GL_RGB16_EXT 0x8054
+#define GL_RGBA2_EXT 0x8055
+#define GL_RGBA4_EXT 0x8056
+#define GL_RGB5_A1_EXT 0x8057
+#define GL_RGBA8_EXT 0x8058
+#define GL_RGB10_A2_EXT 0x8059
+#define GL_RGBA12_EXT 0x805A
+#define GL_RGBA16_EXT 0x805B
+#define GL_TEXTURE_RED_SIZE_EXT 0x805C
+#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D
+#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E
+#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060
+#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061
+#define GL_REPLACE_EXT 0x8062
+#define GL_PROXY_TEXTURE_1D_EXT 0x8063
+#define GL_PROXY_TEXTURE_2D_EXT 0x8064
+#define GL_TEXTURE_TOO_LARGE_EXT 0x8065
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_SKIP_IMAGES_EXT 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_TEXTURE_3D_EXT 0x806F
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_PROXY_TEXTURE_3D_EXT 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_DEPTH_EXT 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_TEXTURE_WRAP_R_EXT 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073
+#define GL_FILTER4_SGIS 0x8146
+#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147
+#define GL_HISTOGRAM_EXT 0x8024
+#define GL_PROXY_HISTOGRAM_EXT 0x8025
+#define GL_HISTOGRAM_WIDTH_EXT 0x8026
+#define GL_HISTOGRAM_FORMAT_EXT 0x8027
+#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C
+#define GL_HISTOGRAM_SINK_EXT 0x802D
+#define GL_MINMAX_EXT 0x802E
+#define GL_MINMAX_FORMAT_EXT 0x802F
+#define GL_MINMAX_SINK_EXT 0x8030
+#define GL_TABLE_TOO_LARGE_EXT 0x8031
+#define GL_CONVOLUTION_1D_EXT 0x8010
+#define GL_CONVOLUTION_2D_EXT 0x8011
+#define GL_SEPARABLE_2D_EXT 0x8012
+#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015
+#define GL_REDUCE_EXT 0x8016
+#define GL_CONVOLUTION_FORMAT_EXT 0x8017
+#define GL_CONVOLUTION_WIDTH_EXT 0x8018
+#define GL_CONVOLUTION_HEIGHT_EXT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023
+#define GL_COLOR_MATRIX_SGI 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB
+#define GL_COLOR_TABLE_SGI 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2
+#define GL_PROXY_COLOR_TABLE_SGI 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5
+#define GL_COLOR_TABLE_SCALE_SGI 0x80D6
+#define GL_COLOR_TABLE_BIAS_SGI 0x80D7
+#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8
+#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF
+#define GL_PIXEL_TEXTURE_SGIS 0x8353
+#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354
+#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355
+#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356
+#define GL_PIXEL_TEX_GEN_SGIX 0x8139
+#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B
+#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130
+#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131
+#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132
+#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133
+#define GL_TEXTURE_4D_SGIS 0x8134
+#define GL_PROXY_TEXTURE_4D_SGIS 0x8135
+#define GL_TEXTURE_4DSIZE_SGIS 0x8136
+#define GL_TEXTURE_WRAP_Q_SGIS 0x8137
+#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138
+#define GL_TEXTURE_4D_BINDING_SGIS 0x814F
+#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC
+#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD
+#define GL_CMYK_EXT 0x800C
+#define GL_CMYKA_EXT 0x800D
+#define GL_PACK_CMYK_HINT_EXT 0x800E
+#define GL_UNPACK_CMYK_HINT_EXT 0x800F
+#define GL_TEXTURE_PRIORITY_EXT 0x8066
+#define GL_TEXTURE_RESIDENT_EXT 0x8067
+#define GL_TEXTURE_1D_BINDING_EXT 0x8068
+#define GL_TEXTURE_2D_BINDING_EXT 0x8069
+#define GL_TEXTURE_3D_BINDING_EXT 0x806A
+#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095
+#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096
+#define GL_LINEAR_DETAIL_SGIS 0x8097
+#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098
+#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099
+#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A
+#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B
+#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C
+#define GL_LINEAR_SHARPEN_SGIS 0x80AD
+#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE
+#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF
+#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0
+#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036
+#define GL_TEXTURE_MIN_LOD_SGIS 0x813A
+#define GL_TEXTURE_MAX_LOD_SGIS 0x813B
+#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C
+#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D
+#define GL_MULTISAMPLE_SGIS 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F
+#define GL_SAMPLE_MASK_SGIS 0x80A0
+#define GL_1PASS_SGIS 0x80A1
+#define GL_2PASS_0_SGIS 0x80A2
+#define GL_2PASS_1_SGIS 0x80A3
+#define GL_4PASS_0_SGIS 0x80A4
+#define GL_4PASS_1_SGIS 0x80A5
+#define GL_4PASS_2_SGIS 0x80A6
+#define GL_4PASS_3_SGIS 0x80A7
+#define GL_SAMPLE_BUFFERS_SGIS 0x80A8
+#define GL_SAMPLES_SGIS 0x80A9
+#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA
+#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB
+#define GL_SAMPLE_PATTERN_SGIS 0x80AC
+#define GL_RESCALE_NORMAL_EXT 0x803A
+#define GL_VERTEX_ARRAY_EXT 0x8074
+#define GL_NORMAL_ARRAY_EXT 0x8075
+#define GL_COLOR_ARRAY_EXT 0x8076
+#define GL_INDEX_ARRAY_EXT 0x8077
+#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
+#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
+#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
+#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
+#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
+#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
+#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
+#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
+#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
+#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
+#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
+#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
+#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
+#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
+#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
+#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
+#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
+#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
+#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
+#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
+#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
+#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
+#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
+#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
+#define GL_GENERATE_MIPMAP_SGIS 0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
+#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170
+#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171
+#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172
+#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173
+#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174
+#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175
+#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176
+#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177
+#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178
+#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D
+#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E
+#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F
+#define GL_TEXTURE_COMPARE_SGIX 0x819A
+#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B
+#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C
+#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D
+#define GL_CLAMP_TO_EDGE_SGIS 0x812F
+#define GL_CLAMP_TO_BORDER_SGIS 0x812D
+#define GL_FUNC_ADD_EXT 0x8006
+#define GL_MIN_EXT 0x8007
+#define GL_MAX_EXT 0x8008
+#define GL_BLEND_EQUATION_EXT 0x8009
+#define GL_FUNC_SUBTRACT_EXT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B
+#define GL_INTERLACE_SGIX 0x8094
+#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E
+#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F
+#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140
+#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141
+#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142
+#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143
+#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144
+#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145
+#define GL_DUAL_ALPHA4_SGIS 0x8110
+#define GL_DUAL_ALPHA8_SGIS 0x8111
+#define GL_DUAL_ALPHA12_SGIS 0x8112
+#define GL_DUAL_ALPHA16_SGIS 0x8113
+#define GL_DUAL_LUMINANCE4_SGIS 0x8114
+#define GL_DUAL_LUMINANCE8_SGIS 0x8115
+#define GL_DUAL_LUMINANCE12_SGIS 0x8116
+#define GL_DUAL_LUMINANCE16_SGIS 0x8117
+#define GL_DUAL_INTENSITY4_SGIS 0x8118
+#define GL_DUAL_INTENSITY8_SGIS 0x8119
+#define GL_DUAL_INTENSITY12_SGIS 0x811A
+#define GL_DUAL_INTENSITY16_SGIS 0x811B
+#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C
+#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D
+#define GL_QUAD_ALPHA4_SGIS 0x811E
+#define GL_QUAD_ALPHA8_SGIS 0x811F
+#define GL_QUAD_LUMINANCE4_SGIS 0x8120
+#define GL_QUAD_LUMINANCE8_SGIS 0x8121
+#define GL_QUAD_INTENSITY4_SGIS 0x8122
+#define GL_QUAD_INTENSITY8_SGIS 0x8123
+#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124
+#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125
+#define GL_SPRITE_SGIX 0x8148
+#define GL_SPRITE_MODE_SGIX 0x8149
+#define GL_SPRITE_AXIS_SGIX 0x814A
+#define GL_SPRITE_TRANSLATION_SGIX 0x814B
+#define GL_SPRITE_AXIAL_SGIX 0x814C
+#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D
+#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E
+#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E
+#define GL_POINT_SIZE_MIN_EXT 0x8126
+#define GL_POINT_SIZE_MIN_SGIS 0x8126
+#define GL_POINT_SIZE_MAX_EXT 0x8127
+#define GL_POINT_SIZE_MAX_SGIS 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
+#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128
+#define GL_DISTANCE_ATTENUATION_EXT 0x8129
+#define GL_DISTANCE_ATTENUATION_SGIS 0x8129
+#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180
+#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181
+#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179
+#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A
+#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B
+#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C
+#define GL_FRAMEZOOM_SGIX 0x818B
+#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C
+#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D
+#define GL_REFERENCE_PLANE_SGIX 0x817D
+#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E
+#define GL_DEPTH_COMPONENT16_SGIX 0x81A5
+#define GL_DEPTH_COMPONENT24_SGIX 0x81A6
+#define GL_DEPTH_COMPONENT32_SGIX 0x81A7
+#define GL_FOG_FUNC_SGIS 0x812A
+#define GL_FOG_FUNC_POINTS_SGIS 0x812B
+#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C
+#define GL_FOG_OFFSET_SGIX 0x8198
+#define GL_FOG_OFFSET_VALUE_SGIX 0x8199
+#define GL_IMAGE_SCALE_X_HP 0x8155
+#define GL_IMAGE_SCALE_Y_HP 0x8156
+#define GL_IMAGE_TRANSLATE_X_HP 0x8157
+#define GL_IMAGE_TRANSLATE_Y_HP 0x8158
+#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159
+#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A
+#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B
+#define GL_IMAGE_MAG_FILTER_HP 0x815C
+#define GL_IMAGE_MIN_FILTER_HP 0x815D
+#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E
+#define GL_CUBIC_HP 0x815F
+#define GL_AVERAGE_HP 0x8160
+#define GL_IMAGE_TRANSFORM_2D_HP 0x8161
+#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162
+#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163
+#define GL_IGNORE_BORDER_HP 0x8150
+#define GL_CONSTANT_BORDER_HP 0x8151
+#define GL_REPLICATE_BORDER_HP 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154
+#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE
+#define GL_VERTEX_DATA_HINT_PGI 0x1A22A
+#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B
+#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C
+#define GL_MAX_VERTEX_HINT_PGI 0x1A22D
+#define GL_COLOR3_BIT_PGI 0x00010000
+#define GL_COLOR4_BIT_PGI 0x00020000
+#define GL_EDGEFLAG_BIT_PGI 0x00040000
+#define GL_INDEX_BIT_PGI 0x00080000
+#define GL_MAT_AMBIENT_BIT_PGI 0x00100000
+#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000
+#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000
+#define GL_MAT_EMISSION_BIT_PGI 0x00800000
+#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000
+#define GL_MAT_SHININESS_BIT_PGI 0x02000000
+#define GL_MAT_SPECULAR_BIT_PGI 0x04000000
+#define GL_NORMAL_BIT_PGI 0x08000000
+#define GL_TEXCOORD1_BIT_PGI 0x10000000
+#define GL_TEXCOORD2_BIT_PGI 0x20000000
+#define GL_TEXCOORD3_BIT_PGI 0x40000000
+#define GL_TEXCOORD4_BIT_PGI 0x80000000
+#define GL_VERTEX23_BIT_PGI 0x00000004
+#define GL_VERTEX4_BIT_PGI 0x00000008
+#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8
+#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD
+#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE
+#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202
+#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203
+#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204
+#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C
+#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D
+#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E
+#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F
+#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210
+#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211
+#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216
+#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217
+#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218
+#define GL_FULL_STIPPLE_HINT_PGI 0x1A219
+#define GL_CLIP_NEAR_HINT_PGI 0x1A220
+#define GL_CLIP_FAR_HINT_PGI 0x1A221
+#define GL_WIDE_LINE_HINT_PGI 0x1A222
+#define GL_BACK_NORMALS_HINT_PGI 0x1A223
+#define GL_COLOR_INDEX1_EXT 0x80E2
+#define GL_COLOR_INDEX2_EXT 0x80E3
+#define GL_COLOR_INDEX4_EXT 0x80E4
+#define GL_COLOR_INDEX8_EXT 0x80E5
+#define GL_COLOR_INDEX12_EXT 0x80E6
+#define GL_COLOR_INDEX16_EXT 0x80E7
+#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
+#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0
+#define GL_LIST_PRIORITY_SGIX 0x8182
+#define GL_IR_INSTRUMENT1_SGIX 0x817F
+#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183
+#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E
+#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F
+#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190
+#define GL_SHADOW_AMBIENT_SGIX 0x80BF
+#define GL_INDEX_MATERIAL_EXT 0x81B8
+#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9
+#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA
+#define GL_INDEX_TEST_EXT 0x81B5
+#define GL_INDEX_TEST_FUNC_EXT 0x81B6
+#define GL_INDEX_TEST_REF_EXT 0x81B7
+#define GL_IUI_V2F_EXT 0x81AD
+#define GL_IUI_V3F_EXT 0x81AE
+#define GL_IUI_N3F_V2F_EXT 0x81AF
+#define GL_IUI_N3F_V3F_EXT 0x81B0
+#define GL_T2F_IUI_V2F_EXT 0x81B1
+#define GL_T2F_IUI_V3F_EXT 0x81B2
+#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3
+#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4
+#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8
+#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9
+#define GL_CULL_VERTEX_EXT 0x81AA
+#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB
+#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC
+#define GL_YCRCB_422_SGIX 0x81BB
+#define GL_YCRCB_444_SGIX 0x81BC
+#define GL_FRAGMENT_LIGHTING_SGIX 0x8400
+#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401
+#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402
+#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403
+#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404
+#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405
+#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406
+#define GL_LIGHT_ENV_MODE_SGIX 0x8407
+#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408
+#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409
+#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A
+#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B
+#define GL_FRAGMENT_LIGHT0_SGIX 0x840C
+#define GL_FRAGMENT_LIGHT1_SGIX 0x840D
+#define GL_FRAGMENT_LIGHT2_SGIX 0x840E
+#define GL_FRAGMENT_LIGHT3_SGIX 0x840F
+#define GL_FRAGMENT_LIGHT4_SGIX 0x8410
+#define GL_FRAGMENT_LIGHT5_SGIX 0x8411
+#define GL_FRAGMENT_LIGHT6_SGIX 0x8412
+#define GL_FRAGMENT_LIGHT7_SGIX 0x8413
+#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262
+#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167
+#define GL_TEXTURE_POST_SPECULAR_HP 0x8168
+#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169
+#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8
+#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9
+#define GL_PHONG_WIN 0x80EA
+#define GL_PHONG_HINT_WIN 0x80EB
+#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC
+#define GL_FRAGMENT_MATERIAL_EXT 0x8349
+#define GL_FRAGMENT_NORMAL_EXT 0x834A
+#define GL_FRAGMENT_COLOR_EXT 0x834C
+#define GL_ATTENUATION_EXT 0x834D
+#define GL_SHADOW_ATTENUATION_EXT 0x834E
+#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F
+#define GL_TEXTURE_LIGHT_EXT 0x8350
+#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351
+#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352
+/* reuse GL_FRAGMENT_DEPTH_EXT */
+#define GL_ALPHA_MIN_SGIX 0x8320
+#define GL_ALPHA_MAX_SGIX 0x8321
+#define GL_BGR_EXT 0x80E0
+#define GL_BGRA_EXT 0x80E1
+#define GL_PARALLEL_ARRAYS_INTEL 0x83F4
+#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5
+#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6
+#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7
+#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8
+#define GL_OCCLUSION_TEST_HP 0x8165
+#define GL_OCCLUSION_TEST_RESULT_HP 0x8166
+#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330
+#define GL_PIXEL_MAG_FILTER_EXT 0x8331
+#define GL_PIXEL_MIN_FILTER_EXT 0x8332
+#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333
+#define GL_CUBIC_EXT 0x8334
+#define GL_AVERAGE_EXT 0x8335
+#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336
+#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337
+#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338
+#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
+#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
+#define GL_SINGLE_COLOR_EXT 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA
+#define GL_COLOR_SUM_EXT 0x8458
+#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
+#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E
+#define GL_PERTURB_EXT 0x85AE
+#define GL_TEXTURE_NORMAL_EXT 0x85AF
+#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450
+#define GL_FOG_COORDINATE_EXT 0x8451
+#define GL_FRAGMENT_DEPTH_EXT 0x8452
+#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
+#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
+#define GL_SCREEN_COORDINATES_REND 0x8490
+#define GL_INVERTED_SCREEN_W_REND 0x8491
+#define GL_TANGENT_ARRAY_EXT 0x8439
+#define GL_BINORMAL_ARRAY_EXT 0x843A
+#define GL_CURRENT_TANGENT_EXT 0x843B
+#define GL_CURRENT_BINORMAL_EXT 0x843C
+#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E
+#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F
+#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440
+#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441
+#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442
+#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443
+#define GL_MAP1_TANGENT_EXT 0x8444
+#define GL_MAP2_TANGENT_EXT 0x8445
+#define GL_MAP1_BINORMAL_EXT 0x8446
+#define GL_MAP2_BINORMAL_EXT 0x8447
+#define GL_COMBINE_EXT 0x8570
+#define GL_COMBINE_RGB_EXT 0x8571
+#define GL_COMBINE_ALPHA_EXT 0x8572
+#define GL_RGB_SCALE_EXT 0x8573
+#define GL_ADD_SIGNED_EXT 0x8574
+#define GL_INTERPOLATE_EXT 0x8575
+#define GL_CONSTANT_EXT 0x8576
+#define GL_PRIMARY_COLOR_EXT 0x8577
+#define GL_PREVIOUS_EXT 0x8578
+#define GL_SOURCE0_RGB_EXT 0x8580
+#define GL_SOURCE1_RGB_EXT 0x8581
+#define GL_SOURCE2_RGB_EXT 0x8582
+#define GL_SOURCE3_RGB_EXT 0x8583
+#define GL_SOURCE4_RGB_EXT 0x8584
+#define GL_SOURCE5_RGB_EXT 0x8585
+#define GL_SOURCE6_RGB_EXT 0x8586
+#define GL_SOURCE7_RGB_EXT 0x8587
+#define GL_SOURCE0_ALPHA_EXT 0x8588
+#define GL_SOURCE1_ALPHA_EXT 0x8589
+#define GL_SOURCE2_ALPHA_EXT 0x858A
+#define GL_SOURCE3_ALPHA_EXT 0x858B
+#define GL_SOURCE4_ALPHA_EXT 0x858C
+#define GL_SOURCE5_ALPHA_EXT 0x858D
+#define GL_SOURCE6_ALPHA_EXT 0x858E
+#define GL_SOURCE7_ALPHA_EXT 0x858F
+#define GL_OPERAND0_RGB_EXT 0x8590
+#define GL_OPERAND1_RGB_EXT 0x8591
+#define GL_OPERAND2_RGB_EXT 0x8592
+#define GL_OPERAND3_RGB_EXT 0x8593
+#define GL_OPERAND4_RGB_EXT 0x8594
+#define GL_OPERAND5_RGB_EXT 0x8595
+#define GL_OPERAND6_RGB_EXT 0x8596
+#define GL_OPERAND7_RGB_EXT 0x8597
+#define GL_OPERAND0_ALPHA_EXT 0x8598
+#define GL_OPERAND1_ALPHA_EXT 0x8599
+#define GL_OPERAND2_ALPHA_EXT 0x859A
+#define GL_OPERAND3_ALPHA_EXT 0x859B
+#define GL_OPERAND4_ALPHA_EXT 0x859C
+#define GL_OPERAND5_ALPHA_EXT 0x859D
+#define GL_OPERAND6_ALPHA_EXT 0x859E
+#define GL_OPERAND7_ALPHA_EXT 0x859F
+#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0
+#define GL_TRANSFORM_HINT_APPLE 0x85B1
+#define GL_FOG_SCALE_SGIX 0x81FC
+#define GL_FOG_SCALE_VALUE_SGIX 0x81FD
+#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5
+#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6
+#define GL_GLOBAL_ALPHA_SUN 0x81D9
+#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA
+#define GL_RESTART_SUN 0x01
+#define GL_REPLACE_MIDDLE_SUN 0x02
+#define GL_REPLACE_OLDEST_SUN 0x03
+#define GL_TRIANGLE_LIST_SUN 0x81D7
+#define GL_REPLACEMENT_CODE_SUN 0x81D8
+#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0
+#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1
+#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2
+#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3
+#define GL_R1UI_V3F_SUN 0x85C4
+#define GL_R1UI_C4UB_V3F_SUN 0x85C5
+#define GL_R1UI_C3F_V3F_SUN 0x85C6
+#define GL_R1UI_N3F_V3F_SUN 0x85C7
+#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8
+#define GL_R1UI_T2F_V3F_SUN 0x85C9
+#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA
+#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB
+#define GL_BLEND_DST_RGB_EXT 0x80C8
+#define GL_BLEND_SRC_RGB_EXT 0x80C9
+#define GL_BLEND_DST_ALPHA_EXT 0x80CA
+#define GL_BLEND_SRC_ALPHA_EXT 0x80CB
+#define GL_RED_MIN_CLAMP_INGR 0x8560
+#define GL_GREEN_MIN_CLAMP_INGR 0x8561
+#define GL_BLUE_MIN_CLAMP_INGR 0x8562
+#define GL_ALPHA_MIN_CLAMP_INGR 0x8563
+#define GL_RED_MAX_CLAMP_INGR 0x8564
+#define GL_GREEN_MAX_CLAMP_INGR 0x8565
+#define GL_BLUE_MAX_CLAMP_INGR 0x8566
+#define GL_ALPHA_MAX_CLAMP_INGR 0x8567
+#define GL_INTERLACE_READ_INGR 0x8568
+#define GL_INCR_WRAP_EXT 0x8507
+#define GL_DECR_WRAP_EXT 0x8508
+#define GL_422_EXT 0x80CC
+#define GL_422_REV_EXT 0x80CD
+#define GL_422_AVERAGE_EXT 0x80CE
+#define GL_422_REV_AVERAGE_EXT 0x80CF
+#define GL_NORMAL_MAP_NV 0x8511
+#define GL_REFLECTION_MAP_NV 0x8512
+#define GL_NORMAL_MAP_EXT 0x8511
+#define GL_REFLECTION_MAP_EXT 0x8512
+#define GL_TEXTURE_CUBE_MAP_EXT 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C
+#define GL_WRAP_BORDER_SUN 0x81D4
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD
+#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT 0x8501
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH
+#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502
+#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX
+#define GL_MODELVIEW_MATRIX1_EXT 0x8506
+#define GL_VERTEX_WEIGHTING_EXT 0x8509
+#define GL_MODELVIEW0_EXT GL_MODELVIEW
+#define GL_MODELVIEW1_EXT 0x850A
+#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B
+#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C
+#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D
+#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E
+#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F
+#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510
+#define GL_MAX_SHININESS_NV 0x8504
+#define GL_MAX_SPOT_EXPONENT_NV 0x8505
+#define GL_VERTEX_ARRAY_RANGE_NV 0x851D
+#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E
+#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F
+#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520
+#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521
+#define GL_REGISTER_COMBINERS_NV 0x8522
+#define GL_VARIABLE_A_NV 0x8523
+#define GL_VARIABLE_B_NV 0x8524
+#define GL_VARIABLE_C_NV 0x8525
+#define GL_VARIABLE_D_NV 0x8526
+#define GL_VARIABLE_E_NV 0x8527
+#define GL_VARIABLE_F_NV 0x8528
+#define GL_VARIABLE_G_NV 0x8529
+#define GL_CONSTANT_COLOR0_NV 0x852A
+#define GL_CONSTANT_COLOR1_NV 0x852B
+#define GL_PRIMARY_COLOR_NV 0x852C
+#define GL_SECONDARY_COLOR_NV 0x852D
+#define GL_SPARE0_NV 0x852E
+#define GL_SPARE1_NV 0x852F
+#define GL_DISCARD_NV 0x8530
+#define GL_E_TIMES_F_NV 0x8531
+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
+#define GL_UNSIGNED_IDENTITY_NV 0x8536
+#define GL_UNSIGNED_INVERT_NV 0x8537
+#define GL_EXPAND_NORMAL_NV 0x8538
+#define GL_EXPAND_NEGATE_NV 0x8539
+#define GL_HALF_BIAS_NORMAL_NV 0x853A
+#define GL_HALF_BIAS_NEGATE_NV 0x853B
+#define GL_SIGNED_IDENTITY_NV 0x853C
+#define GL_SIGNED_NEGATE_NV 0x853D
+#define GL_SCALE_BY_TWO_NV 0x853E
+#define GL_SCALE_BY_FOUR_NV 0x853F
+#define GL_SCALE_BY_ONE_HALF_NV 0x8540
+#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541
+#define GL_COMBINER_INPUT_NV 0x8542
+#define GL_COMBINER_MAPPING_NV 0x8543
+#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544
+#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545
+#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546
+#define GL_COMBINER_MUX_SUM_NV 0x8547
+#define GL_COMBINER_SCALE_NV 0x8548
+#define GL_COMBINER_BIAS_NV 0x8549
+#define GL_COMBINER_AB_OUTPUT_NV 0x854A
+#define GL_COMBINER_CD_OUTPUT_NV 0x854B
+#define GL_COMBINER_SUM_OUTPUT_NV 0x854C
+#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
+#define GL_NUM_GENERAL_COMBINERS_NV 0x854E
+#define GL_COLOR_SUM_CLAMP_NV 0x854F
+#define GL_COMBINER0_NV 0x8550
+#define GL_COMBINER1_NV 0x8551
+#define GL_COMBINER2_NV 0x8552
+#define GL_COMBINER3_NV 0x8553
+#define GL_COMBINER4_NV 0x8554
+#define GL_COMBINER5_NV 0x8555
+#define GL_COMBINER6_NV 0x8556
+#define GL_COMBINER7_NV 0x8557
+/* reuse GL_TEXTURE0_ARB */
+/* reuse GL_TEXTURE1_ARB */
+/* reuse GL_ZERO */
+/* reuse GL_NONE */
+/* reuse GL_FOG */
+#define GL_FOG_DISTANCE_MODE_NV 0x855A
+#define GL_EYE_RADIAL_NV 0x855B
+#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
+/* reuse GL_EYE_PLANE */
+#define GL_EMBOSS_LIGHT_NV 0x855D
+#define GL_EMBOSS_CONSTANT_NV 0x855E
+#define GL_EMBOSS_MAP_NV 0x855F
+#define GL_COMBINE4_NV 0x8503
+#define GL_SOURCE3_RGB_NV 0x8583
+#define GL_SOURCE3_ALPHA_NV 0x858B
+#define GL_OPERAND3_RGB_NV 0x8593
+#define GL_OPERAND3_ALPHA_NV 0x859B
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#define GL_CULL_VERTEX_IBM 103050
+#define GL_VERTEX_ARRAY_LIST_IBM 103070
+#define GL_NORMAL_ARRAY_LIST_IBM 103071
+#define GL_COLOR_ARRAY_LIST_IBM 103072
+#define GL_INDEX_ARRAY_LIST_IBM 103073
+#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074
+#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075
+#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076
+#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077
+#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080
+#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081
+#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082
+#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083
+#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084
+#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085
+#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086
+#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087
+#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0
+#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1
+#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2
+#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3
+#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4
+#define GL_YCRCB_SGIX 0x8318
+#define GL_YCRCBA_SGIX 0x8319
+#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310
+#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311
+#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312
+#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
+#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1
+#define GL_MULTISAMPLE_3DFX 0x86B2
+#define GL_SAMPLE_BUFFERS_3DFX 0x86B3
+#define GL_SAMPLES_3DFX 0x86B4
+#define GL_MULTISAMPLE_BIT_3DFX 0x20000000
+#define GL_MULTISAMPLE_EXT 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
+#define GL_SAMPLE_MASK_EXT 0x80A0
+#define GL_1PASS_EXT 0x80A1
+#define GL_2PASS_0_EXT 0x80A2
+#define GL_2PASS_1_EXT 0x80A3
+#define GL_4PASS_0_EXT 0x80A4
+#define GL_4PASS_1_EXT 0x80A5
+#define GL_4PASS_2_EXT 0x80A6
+#define GL_4PASS_3_EXT 0x80A7
+#define GL_SAMPLE_BUFFERS_EXT 0x80A8
+#define GL_SAMPLES_EXT 0x80A9
+#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA
+#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB
+#define GL_SAMPLE_PATTERN_EXT 0x80AC
+#define GL_VERTEX_PRECLIP_SGIX 0x83EE
+#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF
+#define GL_CONVOLUTION_HINT_SGIX 0x8316
+#define GL_PACK_RESAMPLE_SGIX 0x842C
+#define GL_UNPACK_RESAMPLE_SGIX 0x842D
+#define GL_RESAMPLE_REPLICATE_SGIX 0x842E
+#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F
+#define GL_RESAMPLE_DECIMATE_SGIX 0x8430
+#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0
+#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1
+#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2
+#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3
+#define GL_EYE_POINT_SGIS 0x81F4
+#define GL_OBJECT_POINT_SGIS 0x81F5
+#define GL_EYE_LINE_SGIS 0x81F6
+#define GL_OBJECT_LINE_SGIS 0x81F7
+
+
+/*************************************************************/
+
+extern void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf);
+typedef void (APIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+extern void APIENTRY glBlendEquation (GLenum);
+typedef void (APIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode);
+extern void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+extern void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+extern void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+extern void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+extern void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+extern void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+extern void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+extern void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+extern void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+extern void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+extern void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
+extern void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+extern void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint);
+typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
+extern void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+extern void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+extern void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+extern void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+extern void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *);
+typedef void (APIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+extern void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *);
+typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+extern void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+extern void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+extern void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean);
+typedef void (APIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+extern void APIENTRY glMinmax (GLenum, GLenum, GLboolean);
+typedef void (APIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+extern void APIENTRY glResetHistogram (GLenum);
+typedef void (APIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target);
+extern void APIENTRY glResetMinmax (GLenum);
+typedef void (APIENTRY * PFNGLRESETMINMAXPROC) (GLenum target);
+extern void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+extern void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+extern void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+extern void APIENTRY glActiveTextureARB (GLenum);
+typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+extern void APIENTRY glClientActiveTextureARB (GLenum);
+typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
+typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+extern void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *);
+typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+extern void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *);
+typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+extern void APIENTRY glMultTransposeMatrixfARB (const GLfloat *);
+typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+extern void APIENTRY glMultTransposeMatrixdARB (const GLdouble *);
+typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+extern void APIENTRY glSampleCoverageARB (GLclampf, GLboolean);
+typedef void (APIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);
+extern void APIENTRY glSamplePassARB (GLenum);
+typedef void (APIENTRY * PFNGLSAMPLEPASSARBPROC) (GLenum pass);
+extern void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+extern void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+extern void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+extern void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+extern void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+extern void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+extern void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, void *);
+typedef void (APIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img);
+extern void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf);
+typedef void (APIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+extern void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);
+extern void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+extern void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+extern void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights);
+extern void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *);
+typedef void (APIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
+extern void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+extern void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+extern void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
+typedef void (APIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+extern void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+typedef void (APIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+extern void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+extern void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+extern void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+extern void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+extern void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+extern void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean);
+typedef void (APIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+extern void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean);
+typedef void (APIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+extern void APIENTRY glResetHistogramEXT (GLenum);
+typedef void (APIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);
+extern void APIENTRY glResetMinmaxEXT (GLenum);
+typedef void (APIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target);
+extern void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+extern void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+extern void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params);
+extern void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+extern void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint);
+typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params);
+extern void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+extern void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+extern void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+extern void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+extern void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *);
+typedef void (APIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+extern void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *);
+typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+extern void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+extern void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params);
+extern void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params);
+extern void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+extern void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+extern void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glPixelTexGenSGIX (GLenum);
+typedef void (APIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);
+extern void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint);
+typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param);
+extern void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params);
+extern void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+extern void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+extern void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params);
+extern void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params);
+extern void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+extern void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
+extern GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *);
+typedef GLboolean (APIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences);
+extern void APIENTRY glBindTextureEXT (GLenum, GLuint);
+typedef void (APIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);
+extern void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *);
+typedef void (APIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures);
+extern void APIENTRY glGenTexturesEXT (GLsizei, GLuint *);
+typedef void (APIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures);
+extern GLboolean APIENTRY glIsTextureEXT (GLuint);
+typedef GLboolean (APIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture);
+extern void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *);
+typedef void (APIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
+extern void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *);
+typedef void (APIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+extern void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+extern void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *);
+typedef void (APIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+extern void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+extern void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean);
+typedef void (APIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);
+extern void APIENTRY glSamplePatternSGIS (GLenum);
+typedef void (APIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);
+extern void APIENTRY glArrayElementEXT (GLint);
+typedef void (APIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i);
+extern void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+extern void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei);
+typedef void (APIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);
+extern void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *);
+typedef void (APIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);
+extern void APIENTRY glGetPointervEXT (GLenum, GLvoid* *);
+typedef void (APIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params);
+extern void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+extern void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+extern void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+extern void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+extern void APIENTRY glBlendEquationEXT (GLenum);
+typedef void (APIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);
+extern void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);
+extern void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params);
+extern void APIENTRY glSpriteParameteriSGIX (GLenum, GLint);
+typedef void (APIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);
+extern void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params);
+extern void APIENTRY glPointParameterfEXT (GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
+extern void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
+extern void APIENTRY glPointParameterfSGIS (GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+extern void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+extern GLint APIENTRY glGetInstrumentsSGIX (void);
+typedef GLint (APIENTRY * PFNGLGETINSTRUMENTSSGIXPROC) (void);
+extern void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *);
+typedef void (APIENTRY * PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer);
+extern GLint APIENTRY glPollInstrumentsSGIX (GLint *);
+typedef GLint (APIENTRY * PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p);
+extern void APIENTRY glReadInstrumentsSGIX (GLint);
+typedef void (APIENTRY * PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker);
+extern void APIENTRY glStartInstrumentsSGIX (void);
+typedef void (APIENTRY * PFNGLSTARTINSTRUMENTSSGIXPROC) (void);
+extern void APIENTRY glStopInstrumentsSGIX (GLint);
+typedef void (APIENTRY * PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker);
+extern void APIENTRY glFrameZoomSGIX (GLint);
+typedef void (APIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor);
+extern void APIENTRY glTagSampleBufferSGIX (void);
+typedef void (APIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);
+extern void APIENTRY glReferencePlaneSGIX (const GLdouble *);
+typedef void (APIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation);
+extern void APIENTRY glFlushRasterSGIX (void);
+typedef void (APIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void);
+extern void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *);
+typedef void (APIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points);
+extern void APIENTRY glGetFogFuncSGIS (const GLfloat *);
+typedef void (APIENTRY * PFNGLGETFOGFUNCSGISPROC) (const GLfloat *points);
+extern void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint);
+typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param);
+extern void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param);
+extern void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params);
+extern void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params);
+extern void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+extern void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei);
+typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+extern void APIENTRY glHintPGI (GLenum, GLint);
+typedef void (APIENTRY * PFNGLHINTPGIPROC) (GLenum target, GLint mode);
+extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+extern void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
+extern void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+extern void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params);
+extern void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param);
+extern void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params);
+extern void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint);
+typedef void (APIENTRY * PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param);
+extern void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params);
+extern void APIENTRY glIndexMaterialEXT (GLenum, GLenum);
+typedef void (APIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);
+extern void APIENTRY glIndexFuncEXT (GLenum, GLclampf);
+typedef void (APIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref);
+extern void APIENTRY glLockArraysEXT (GLint, GLsizei);
+typedef void (APIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
+extern void APIENTRY glUnlockArraysEXT (void);
+typedef void (APIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void);
+extern void APIENTRY glCullParameterdvEXT (GLenum, const GLdouble *);
+typedef void (APIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, const GLdouble *params);
+extern void APIENTRY glCullParameterfvEXT (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
+extern void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum);
+typedef void (APIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);
+extern void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);
+extern void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
+extern void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint);
+typedef void (APIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);
+extern void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);
+extern void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);
+extern void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);
+extern void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint);
+typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);
+extern void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);
+extern void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param);
+extern void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params);
+extern void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint);
+typedef void (APIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param);
+extern void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params);
+extern void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params);
+extern void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
+extern void APIENTRY glLightEnviSGIX (GLenum, GLint);
+typedef void (APIENTRY * PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param);
+extern void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
+typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+extern void APIENTRY glApplyTextureEXT (GLenum);
+typedef void (APIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);
+extern void APIENTRY glTextureLightEXT (GLenum);
+typedef void (APIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);
+extern void APIENTRY glTextureMaterialEXT (GLenum, GLenum);
+typedef void (APIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);
+extern void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *);
+typedef void (APIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+extern void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *);
+typedef void (APIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer);
+extern void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *);
+typedef void (APIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+extern void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *);
+typedef void (APIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+extern void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint);
+typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);
+extern void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);
+extern void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+extern void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+extern void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
+extern void APIENTRY glSecondaryColor3bvEXT (const GLbyte *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
+extern void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
+extern void APIENTRY glSecondaryColor3dvEXT (const GLdouble *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
+extern void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
+extern void APIENTRY glSecondaryColor3fvEXT (const GLfloat *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
+extern void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
+extern void APIENTRY glSecondaryColor3ivEXT (const GLint *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
+extern void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
+extern void APIENTRY glSecondaryColor3svEXT (const GLshort *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
+extern void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
+extern void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
+extern void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
+extern void APIENTRY glSecondaryColor3uivEXT (const GLuint *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
+extern void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
+extern void APIENTRY glSecondaryColor3usvEXT (const GLushort *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
+extern void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, GLvoid *);
+typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer);
+extern void APIENTRY glTextureNormalEXT (GLenum);
+typedef void (APIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode);
+extern void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
+typedef void (APIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+extern void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
+typedef void (APIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+extern void APIENTRY glFogCoordfEXT (GLfloat);
+typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord);
+extern void APIENTRY glFogCoordfvEXT (const GLfloat *);
+typedef void (APIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
+extern void APIENTRY glFogCoorddEXT (GLdouble);
+typedef void (APIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord);
+extern void APIENTRY glFogCoorddvEXT (const GLdouble *);
+typedef void (APIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
+extern void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+extern void APIENTRY glTangent3b (GLbyte, GLbyte, GLbyte);
+typedef void (APIENTRY * PFNGLTANGENT3BPROC) (GLbyte tx, GLbyte ty, GLbyte tz);
+extern void APIENTRY glTangent3bv (const GLbyte *);
+typedef void (APIENTRY * PFNGLTANGENT3BVPROC) (const GLbyte *v);
+extern void APIENTRY glTangent3d (GLdouble, GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLTANGENT3DPROC) (GLdouble tx, GLdouble ty, GLdouble tz);
+extern void APIENTRY glTangent3dv (const GLdouble *);
+typedef void (APIENTRY * PFNGLTANGENT3DVPROC) (const GLdouble *v);
+extern void APIENTRY glTangent3f (GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLTANGENT3FPROC) (GLfloat tx, GLfloat ty, GLfloat tz);
+extern void APIENTRY glTangent3fv (const GLfloat *);
+typedef void (APIENTRY * PFNGLTANGENT3FVPROC) (const GLfloat *v);
+extern void APIENTRY glTangent3i (GLint, GLint, GLint);
+typedef void (APIENTRY * PFNGLTANGENT3IPROC) (GLint tx, GLint ty, GLint tz);
+extern void APIENTRY glTangent3iv (const GLint *);
+typedef void (APIENTRY * PFNGLTANGENT3IVPROC) (const GLint *v);
+extern void APIENTRY glTangent3s (GLshort, GLshort, GLshort);
+typedef void (APIENTRY * PFNGLTANGENT3SPROC) (GLshort tx, GLshort ty, GLshort tz);
+extern void APIENTRY glTangent3sv (const GLshort *);
+typedef void (APIENTRY * PFNGLTANGENT3SVPROC) (const GLshort *v);
+extern void APIENTRY glBinormal3b (GLbyte, GLbyte, GLbyte);
+typedef void (APIENTRY * PFNGLBINORMAL3BPROC) (GLbyte bx, GLbyte by, GLbyte bz);
+extern void APIENTRY glBinormal3bv (const GLbyte *);
+typedef void (APIENTRY * PFNGLBINORMAL3BVPROC) (const GLbyte *v);
+extern void APIENTRY glBinormal3d (GLdouble, GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLBINORMAL3DPROC) (GLdouble bx, GLdouble by, GLdouble bz);
+extern void APIENTRY glBinormal3dv (const GLdouble *);
+typedef void (APIENTRY * PFNGLBINORMAL3DVPROC) (const GLdouble *v);
+extern void APIENTRY glBinormal3f (GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLBINORMAL3FPROC) (GLfloat bx, GLfloat by, GLfloat bz);
+extern void APIENTRY glBinormal3fv (const GLfloat *);
+typedef void (APIENTRY * PFNGLBINORMAL3FVPROC) (const GLfloat *v);
+extern void APIENTRY glBinormal3i (GLint, GLint, GLint);
+typedef void (APIENTRY * PFNGLBINORMAL3IPROC) (GLint bx, GLint by, GLint bz);
+extern void APIENTRY glBinormal3iv (const GLint *);
+typedef void (APIENTRY * PFNGLBINORMAL3IVPROC) (const GLint *v);
+extern void APIENTRY glBinormal3s (GLshort, GLshort, GLshort);
+typedef void (APIENTRY * PFNGLBINORMAL3SPROC) (GLshort bx, GLshort by, GLshort bz);
+extern void APIENTRY glBinormal3sv (const GLshort *);
+typedef void (APIENTRY * PFNGLBINORMAL3SVPROC) (const GLshort *v);
+extern void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+extern void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+extern void APIENTRY glFinishTextureSUNX (void);
+typedef void (APIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void);
+extern void APIENTRY glGlobalAlphaFactorbSUN (GLbyte);
+typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);
+extern void APIENTRY glGlobalAlphaFactorsSUN (GLshort);
+typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);
+extern void APIENTRY glGlobalAlphaFactoriSUN (GLint);
+typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);
+extern void APIENTRY glGlobalAlphaFactorfSUN (GLfloat);
+typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);
+extern void APIENTRY glGlobalAlphaFactordSUN (GLdouble);
+typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);
+extern void APIENTRY glGlobalAlphaFactorubSUN (GLubyte);
+typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);
+extern void APIENTRY glGlobalAlphaFactorusSUN (GLushort);
+typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);
+extern void APIENTRY glGlobalAlphaFactoruiSUN (GLuint);
+typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);
+extern void APIENTRY glReplacementCodeuiSUN (GLuint);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);
+extern void APIENTRY glReplacementCodeusSUN (GLushort);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);
+extern void APIENTRY glReplacementCodeubSUN (GLubyte);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);
+extern void APIENTRY glReplacementCodeuivSUN (const GLuint *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code);
+extern void APIENTRY glReplacementCodeusvSUN (const GLushort *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code);
+extern void APIENTRY glReplacementCodeubvSUN (const GLubyte *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code);
+extern void APIENTRY glReplacementCodePointer (GLenum, GLsizei, const GLvoid* *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer);
+extern void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
+extern void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *);
+typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+extern void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *);
+typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+extern void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v);
+extern void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+extern void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+extern void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *);
+typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
+extern void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
+extern void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glReplacementCodeuiVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLenum rc, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLenum *, const GLfloat *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *v);
+extern void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLenum, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLenum rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLenum *, const GLubyte *, const GLfloat *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLenum *rc, const GLubyte *c, const GLfloat *v);
+extern void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLenum rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *c, const GLfloat *v);
+extern void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLenum rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLenum rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLenum rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *tc, const GLfloat *v);
+extern void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLenum rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLenum rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+extern void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum);
+typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+extern void APIENTRY glVertexWeightfEXT (GLfloat);
+typedef void (APIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);
+extern void APIENTRY glVertexWeightfvEXT (const GLfloat *);
+typedef void (APIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight);
+extern void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer);
+extern void APIENTRY glFlushVertexArrayRangeNV (void);
+typedef void (APIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);
+extern void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *);
+typedef void (APIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei size, const GLvoid *pointer);
+extern void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *);
+typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
+extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
+typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
+extern void APIENTRY glCombinerParameterivNV (GLenum, const GLint *);
+typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+extern void APIENTRY glCombinerParameteriNV (GLenum, GLint);
+typedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
+extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum);
+typedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
+typedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum);
+typedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+extern void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
+extern void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *);
+typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
+extern void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *);
+typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
+extern void APIENTRY glResizeBuffersMESA (void);
+typedef void (APIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void);
+extern void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);
+extern void APIENTRY glWindowPos2dvMESA (const GLdouble *);
+typedef void (APIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v);
+extern void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);
+extern void APIENTRY glWindowPos2fvMESA (const GLfloat *);
+typedef void (APIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v);
+extern void APIENTRY glWindowPos2iMESA (GLint, GLint);
+typedef void (APIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);
+extern void APIENTRY glWindowPos2ivMESA (const GLint *);
+typedef void (APIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v);
+extern void APIENTRY glWindowPos2sMESA (GLshort, GLshort);
+typedef void (APIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);
+extern void APIENTRY glWindowPos2svMESA (const GLshort *);
+typedef void (APIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v);
+extern void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);
+extern void APIENTRY glWindowPos3dvMESA (const GLdouble *);
+typedef void (APIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v);
+extern void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);
+extern void APIENTRY glWindowPos3fvMESA (const GLfloat *);
+typedef void (APIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v);
+extern void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint);
+typedef void (APIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);
+extern void APIENTRY glWindowPos3ivMESA (const GLint *);
+typedef void (APIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v);
+extern void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort);
+typedef void (APIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);
+extern void APIENTRY glWindowPos3svMESA (const GLshort *);
+typedef void (APIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v);
+extern void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble);
+typedef void (APIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern void APIENTRY glWindowPos4dvMESA (const GLdouble *);
+typedef void (APIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v);
+extern void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (APIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern void APIENTRY glWindowPos4fvMESA (const GLfloat *);
+typedef void (APIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v);
+extern void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint);
+typedef void (APIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);
+extern void APIENTRY glWindowPos4ivMESA (const GLint *);
+typedef void (APIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v);
+extern void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort);
+typedef void (APIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);
+extern void APIENTRY glWindowPos4svMESA (const GLshort *);
+typedef void (APIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v);
+extern void APIENTRY glMultiModeDrawArraysIBM (GLenum, const GLint *, const GLsizei *, GLsizei, GLint);
+typedef void (APIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
+extern void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* *, GLsizei, GLint);
+typedef void (APIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, GLint modestride);
+extern void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+typedef void (APIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+extern void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+extern void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint);
+typedef void (APIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride);
+extern void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+typedef void (APIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+extern void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+typedef void (APIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+extern void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+typedef void (APIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+extern void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+typedef void (APIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+extern void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+typedef void (APIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+extern void APIENTRY glTbufferMask3DFX (GLuint);
+typedef void (APIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);
+extern void APIENTRY glSampleMaskEXT (GLclampf, GLboolean);
+typedef void (APIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);
+extern void APIENTRY glSamplePatternEXT (GLenum);
+typedef void (APIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/xc/extras/rman/ANNOUNCE-rman b/xc/extras/rman/ANNOUNCE-rman
new file mode 100644
index 000000000..209b843a9
--- /dev/null
+++ b/xc/extras/rman/ANNOUNCE-rman
@@ -0,0 +1,78 @@
+======================================================================
+
+PolyglotMan (nee RosettaMan) is a filter for UNIX manual pages. It
+takes as input man pages for a variety of UNIX flavors and produces as
+output a variety of file formats. Currently PolyglotMan accepts man
+pages from the following flavors of UNIX: Hewlett-Packard HP-UX, AT&T
+System V, SunOS, Sun Solaris, OSF/1, DEC Ultrix, SGI IRIX, Linux, SCO,
+FreeBSD; and produces output for the following formats: printable
+ASCII only (stripping page headers and footers), section and
+subsection headers only, TkMan, [tn]roff, RTF, SGML (soon--I finally
+found a DTD), HTML, MIME, LaTeX, LaTeX 2e, Perl 5's pod. Previously
+<I>PolyglotMan</I> required pages to be formatted by nroff prior to
+its processing; with version 3.0, it prefers [tn]roff source and
+usually can produce results that are better yet.
+
+PolyglotMan improves upon other man page filters in several ways: (1) its
+analysis recognizes the structural pieces of man pages, enabling high
+quality output, (2) its modular structure permits easy augmentation of
+output formats, (3) it accepts man pages formatted with the variant
+macros of many different flavors of UNIX, and (4) it doesn't require
+modification of or cooperation with any other program.
+
+PolyglotMan is a rewrite of TkMan's man page filter, called bs2tk. (If
+you haven't heard about TkMan, a hypertext man page browser, you
+should grab it via anonymous ftp from ftp.cs.berkeley.edu:
+/ucb/people/phelps/tkman.tar.Z.) Whereas bs2tk generated output only for
+TkMan, PolyglotMan generalizes the process so that the analysis can be
+leveraged to new output formats. A single analysis engine recognizes
+section heads, subsection heads, body text, lists, references to other
+man pages, boldface, italics, bold italics, special characters (like
+bullets), tables (to a degree) and strips out page headers and
+footers. The engine sends signals to the selected output functions so
+that an enhancement in the engine improves the quality of output of
+all of them. Output format functions are easy to add, and thus far
+average about about 75 lines of C code each.
+
+A note for HTML consumers: This filter does real (heuristic) parsing--
+no <PRE>! Man page references are turned into hypertext links. The files
+<URL:ftp://ftp.cs.berkeley.edu/ucb/people/phelps/tcltk/sgi-ls.1.html>
+and <URL:ftp://ftp.cs.berkeley.edu/ucb/people/phelps/tcltk/ksh.1.html>
+are examples of the quality of output produced entirely automatically
+(no retouching) by PolyglotMan. These translations were produced by
+PolyglotMan starting with the [tn]roff source (again no retouching).
+Several people have extended World Wide Web servers to format man pages
+on the fly. Check the README file in the contrib directory for a list.
+
+
+CHANGES in 3.0
+
+* [tn]roff source preferred for superior results, when roff macros are
+ sufficiently recognized. Autodetection of source or formatted input.
+* New software license that makes it free for any use
+
+
+CHANGES in 2.5
+
+* SGML output format that adheres to Davenport DocBook v2.3 DTD
+ (NOT READY IN CURRENT VERSION!)
+* MIME output format, for e-mail and Emacs 19.29's enriched mode
+ (Neal Becker)
+* port to Macintosh by Matthias Neeracher
+* list of valid volume names can be given as a parameter (Dag Nygren)
+* updated to LaTeX2e (H. Palme)
+* debugging scaffolding erected (at the end of software's development cycle!)
+
+
+CHANGES in 2.2
+
+* when in SEE ALSO, hyphens would confuse man page-reference finder,
+ so re-linebreak if necessary to eliminate them (!) (Greg Earle & Uri Guttman)
+
+
+CHANGES in 2.1
+
+* gets() replaced by custom code. gets() deprecated since it reads until \0,
+ introducing security problems. (Robert Withrow)
+
+* TkMan module revised for Tk 4.0
diff --git a/xc/extras/rman/CHANGES b/xc/extras/rman/CHANGES
new file mode 100644
index 000000000..e37d026ad
--- /dev/null
+++ b/xc/extras/rman/CHANGES
@@ -0,0 +1,100 @@
+1993
+ 1 Apr as bs2tk posted to comp.lang.tcl (126 lines)
+ 2 bullets, change bars, copyright symbol
+ 5 boldface, other SGI nicks
+ 7 skip unrecognized escape codes
+10 small caps
+13 underscores considered uppercase so show up in default small caps font
+ screen out Ultrix junk (code getting pretty tangled now)
+14 until Tk text has better tab support, replace tabs by spaces until get to next tab stop (for Ultrix); -t gives tabstop spacing
+20 Solaris support (Larry Tsui)
+ 3 Jun section subheading parsing (Per-Erik Martin)
+28 hyphenated man pages in SEE ALSO show up correctly in Links (Mike Steele)
+13 Jul under FILES, fully qualified path names are added to Links, but this taken out immediately because not useful
+14 option to keep changebars on right (Warren Jessop)
+ 5 Aug search for header, footer dynamically--no need to edit or search large list of patterns
+11 -m kicks in man page formatting beyond nroff backspace kludges
+27 handle double digit numbers better by trying again relative to end of line
+19 Sep -T gives Tk extras (otherwise ASCII only)
+ -H gives headers only (implies -T off)
+10 Oct -r reverse compiles to [tn]roff source (as Geoff Collyer's nam and fontch, but leveraging existing analysis so only addition of ~60 lines) (The code is device-driver obscure now--obfuscated C contest next.)
+13 header and footer optionally available at bottom in Tk view (Marty Leisner)
+19 "reflected" odd and even page headers&footers zapped
+20 keep count of sections and subsections, using smaller font for larger numbers
+ 1 Nov reverse compiles to Ensemble, except for character ranges
+ 4 started rman rewrite for cleaner support of multiple output targets, including: plain ascii, headers only, TkMan, [nt]roff, Ensemble, SGML, HTML
+ 5 line filtering separated from other logic despite greater sophistication, RosettaMan faster than bs2tk (!)
+28 Dec man page reference recognition (Michael Harrison)
+
+
+1994
+ 1 Jan identify descriptive lists by comparing scnt2 with s_avg
+ 3 tail-end table of contents in HTML documents
+ 5 -f <filter> and LaTeX output mode
+24 proof-of-concept RTF output mode
+26 handle man pages that don't have a header on the first page
+28 parse "handwritten" man pages
+22 Feb alpha version released
+ 6 Mar various bug fixes
+10 beta version released
+13 Jun fixed surious generation on <DL>'s (the existence of which pointed out by David Sibley)
+22 Jul table recognition experiment. works reasonably well, except for tables with centered headers
+ 3 Aug allow for off-by-one (and -two) in identification of header and footer
+ fixed problem with recurrent/leftover text with OSF/1 bold bullets (yeesh)
+12 Sep 2.0gamma released
+13 check for *third* header, possibly centered, possibly after blank lines (Charles Anderson)
+ fixed tag ranges for lines following blank lines (just \n) of pages with global indentation (Owen Rees)
+19 fixed two small problems with LaTeX (^ => \^, \bullet => $\bullet$) (Neal Becker)
+24 simple check for erroneously being fed roff source
+26 deal with bold +- as in ksh (ugh)
+30 2.0delta released
+ 9 Oct special check for OSF to guard against section head interpreted as footer
+ 8 Nov Perl pod output format (result still needs work, but not much)
+ 7 Dec 2.0epsilon released (last one before final 2.0)
+22 Happy Winter Solstice! 2.0 released
+ deprecated gets() replaced (Robert Withrow)
+25 TkMan module's $w.show => $t, saving about 9% in generated characters
+
+
+1995
+ 1 Jan experiment with TkMan output to take advantage of my hack to Tk text (i.e., $t insert end "text" => $t insert end "text1" tag1 "text2" tag2 ...); results => output size reduced about 25%, time reduced about 12-15%
+25 Mar back to old mark command for Tk module
+8 May hyphens in SEE ALSO section would confuse link-finder, so re-linebreak if necessary(!) (Greg Earle & Uri Guttman)
+ 4 Aug put formats and options into tables (inspired by Steve Maguire's Writing Solid Code)
+19 -V accepts colon-separated list of valid volume names (Dag Nygren)
+22 MIME output format that's usable in Emacs 19.29 (just three hours at hacking HTML module) (Neal Becker)
+ 9 Sep nits in HTML and better Solaris code snippets (Drazen Kacar)
+13 Nov Macintosh port by Matthias Neeracher <neeri@iis.ee.ethz.ch>
+18 Dec adapted to LaTeX2e, null manRef yields italicized man ref (H. Palme)
+28 allow long option names (Larry Schwimmer)
+
+
+1996
+22 Jan fixed problem with hyphenation supression and tabs in man page--sheesh! (H. Palme)
+23 May split TkMan format into Tk and TkMan (which calls Tk)
+25 in TkMan format, initial spaces converted to tabs
+24 Sep experiment with formatting from source's macros, for better transcription short of full nroff interpreter
+27 commented out Ensemble output format, which nobody used
+ 2 Oct >4000 lines
+11
+ 8 Nov released 3.0 alpha. source code parsing works well for Solaris, SunOS, HP-UX; in generating HTML
+25 recognize URLs (Mic Campanel)
+
+1997
+19 Mar bug fixes, more special characters (roff expert Larry Jones)
+ 8 Aug renamed to PolyglotMan
+ 4 Nov TkMan module: Rebus and NoteMark identification for paragraph lengths and command line options taken over from Tcl (still have search, highlight in Tcl, necessarily) (Chad Loder)
+ >5000 lines, or nearly 40X the lines of code of version 1.0 (which just supported TkMan)
+
+1998
+20 Mar automatic detection of Tcl/Tk source (within automatic detection of source; already had within formatted)
+ centralize casifying SH and SS for formatted and source
+ group exception table by category
+17 Apr in source translation, pass along comment lines too
+20 incorporate (RCS) versioning diff's, for HTML
+
+
+Anticipated/Contemplated
+make source translation work on Digital UNIX better--just tweaks now
+fix up other output formats to work well with source parsing
+??-??? SGML/XML output format (DTD found at long last), validated by sgmls/sp
diff --git a/xc/extras/rman/MANIFEST b/xc/extras/rman/MANIFEST
new file mode 100644
index 000000000..a88687fc1
--- /dev/null
+++ b/xc/extras/rman/MANIFEST
@@ -0,0 +1,28 @@
+gcksum crc length name
+---------- ------ ----
+3783133468 152817 rman.c
+2435527268 1654 getopt.c
+1480364202 71 macish.c
+476345420 3770 ANNOUNCE-rman
+510464631 3311 README-rman
+892917966 4571 Makefile
+236255660 3149 Makefile.mac
+733124117 11877 rman.1
+694318729 13321 rman.html
+1726493852 5810 CHANGES
+3948042252 4732 contrib/README-contrib
+953283015 911 contrib/authried.txt
+641079878 13609 contrib/bennett.txt
+1827405570 1220 contrib/gzip.patch
+4230791356 250 contrib/hman.cgi
+1743159239 359 contrib/hman.ksh
+2919099478 8005 contrib/hman.pl
+1821945783 4978 contrib/http-rman.c
+3091246851 661 contrib/http-rman.html
+2646244070 350 contrib/lewis.pl
+2860919314 2049 contrib/man2html
+3466647040 7531 contrib/rman_html_split
+75383086 2482 contrib/rman_html_split.1
+2032677288 150 contrib/sco-wrapper.sh
+884546947 3806 contrib/sutter.txt
+3112317992 5086 contrib/youki.pl
diff --git a/xc/extras/rman/Makefile b/xc/extras/rman/Makefile
new file mode 100644
index 000000000..1e348a959
--- /dev/null
+++ b/xc/extras/rman/Makefile
@@ -0,0 +1,166 @@
+#
+# Makefile for PolyglotMan
+# It's helpful to read the README-rman file first.
+# You should read over all parts of this file,
+# down to the "you shouldn't modify" line
+#
+# Tom Phelps (phelps@ACM.org)
+#
+
+
+### you need to localize the paths on these lines
+
+# The executable `rman' is placed in BINDIR.
+# If you're also installing TkMan (available separately--see README-rman),
+# this must be a directory that's in your bin PATH.
+# MANDIR holds the man page.
+
+BINDIR = /private/share/bin
+#BINDIR = /usr/local/bin
+MANDIR = /home/auspex/h/bair/phelps/man/man1
+#MANDIR = /usr/local/man/man1
+
+
+### if you have GNU gcc v2.x, use these definitions
+
+CC = gcc
+# if you don't have gcc v2.x, try -O for CFLAGS
+CFLAGS = -O2 -finline-functions
+
+### if you just have a standard UNIX, use these instead of GNU.
+### CC must be an ANSI C compiler
+
+#CC = cc
+#CFLAGS = -O
+
+# Solaris and SysV people may need this
+#CFLAGS = -O2 -finline-functions
+
+# For HP-UX
+#CC = cc
+#CFLAGS = -Aa -O
+# HP-UX 10.20
+#CFLAGS = -Ae -O
+
+# DEC Alpha and Ultrix, -std1 needed to conform to ANSI C
+#CC = cc
+#CFLAGS = -std1 -O3 -Olimit 1000
+
+
+# list of valid volume numbers and letters
+# you can also set these at runtime with -V
+VOLLIST = "1:2:3:4:5:6:7:8:9:o:l:n:p"
+# SCO Unix has expanded set of volume letters
+#VOLLIST = "1:2:3:4:5:6:7:8:9:o:l:n:p:C:X:S:L:M:F:G:A:H"
+# SGI and UnixWare 2.0
+#VOLLIST = "1:2:3:4:5:6:7:8:9:o:l:n:p:D"
+
+
+# the printf strings used to set the <TITLE> and
+# to set URL hyperlinks to referenced manual pages
+# can be defined at runtime. The defaults are defined below.
+# The first %s parameter is the manual page name,
+# the second the volume/section number.
+# you can set these at runtime with -l and -r, respectively
+
+MANTITLEPRINTF = "%s(%s) manual page"
+# relative link to pregenerated file in same directory
+MANREFPRINTF = "%s.%s"
+# on-the-fly through a cgi-bin script
+#MANREFPRINTF = "/cgi-bin/man2html?%s&%s"
+
+
+# # # these lines are probably fine
+
+CP = cp
+# or you can use GNU's cp and backup files that are about to be overwritten
+#CP = cp -b
+RM = rm
+
+
+#--------------------------------------------------
+#
+# you shouldn't modify anything below here
+#
+#--------------------------------------------------
+
+version = 3.0.8
+rman = rman-$(version)
+srcs = rman.c getopt.c macish.c
+objs = rman
+defs = -DVOLLIST='$(VOLLIST)' -DMANTITLEPRINTF='$(MANTITLEPRINTF)' -DMANREFPRINTF='$(MANREFPRINTF)'
+libs =
+aux = ANNOUNCE-rman README-rman Makefile Makefile.mac rman.1 rman.html CHANGES
+distrib = $(srcs) $(libs) $(aux) contrib
+
+
+all: rman
+ @echo 'Files made in current directory.'
+ @echo 'You should "make install".'
+
+# everyone but me zaps assertions with the -DNDEBUG flag
+rman: rman.c Makefile
+ $(CC) -DNDEBUG $(defs) -DPOLYGLOTMANVERSION=\"$(version)\" $(CFLAGS) -o rman rman.c
+
+dox: rman.1 ANNOUNCE-rman
+
+ANNOUNCE-rman: Announce-rman
+ sed -e /=========/,/bogusline/p -e d Announce-rman > ANNOUNCE-rman
+
+rman.1: rman.html rman
+ echo '.TH PolyglotMan 1' > rman.1
+ cat ../html/html.dtd rman.html | sgmls | ../html/html2man.pl >> rman.1
+
+debug:
+ $(CC) $(defs) -DDEBUG -DPOLYGLOTMANVERSION=\"debug\" -g -Wall -o rman rman.c
+
+prof:
+ quantify -cache-dir=/home/orodruin/h/bair/phelps/spine/rman/cache $(CC) -DNDEBUG $(defs) -DPOLYGLOTMANVERSION=\"QUANTIFY\" -g -o rman rman.c
+
+install: rman
+# $(INSTALL) -s rman $(BINDIR)
+ $(RM) -f $(BINDIR)/rman
+ $(CP) rman $(BINDIR)
+ $(RM) -f $(MANDIR)/rman.1
+ $(CP) rman.1 $(MANDIR)
+
+# test version includes assertions
+# ginstall rman $(BINDIR)/`arch`
+test: rman.c Makefile
+ $(CC) $(defs) -DPOLYGLOTMANVERSION=\"$(version)\" $(CFLAGS) -Wall -ansi -pedantic -o rman rman.c
+ ls -l rman
+ ginstall rman $(BINDIR)
+ rman -v
+ rman --help
+ @echo 'Assertion checks:'
+ rman -f html weirdman/hp-tbl.1 > /dev/null
+ rman -f html weirdman/Pnews.1 > /dev/null
+ nroff -man rman.1 | rman -f html > /dev/null
+
+sww:
+ rm -f rman $(wildcard ~/bin/{sun4,snake,alpha}/rman)
+ rman
+
+clean:
+ rm -f $(objs)
+
+dist: dox
+ rm -rf $(rman)*
+ mkdir $(rman)
+ $(CP) -R $(distrib) $(rman)
+# expand -4 rman.c > $(rman)/rman.c
+ rm -f $(rman)/contrib/*~
+ @echo 'gcksum crc length name' > MANIFEST
+ @echo '---------- ------ ----' >> MANIFEST
+ @gcksum $(filter-out contrib, $(filter-out %~, $(distrib) $(wildcard contrib/*))) | gtee -a MANIFEST
+ mv MANIFEST $(rman)
+ gtar chvf $(rman).tar $(rman)
+ compress $(rman).tar
+# gzip -9v $(rman).tar
+ rm -rf $(rman) ANNOUNCE-rman rman.1
+ @echo "*** Did you remember to ci -l first?"
+
+uu: tar
+ gznew $(rman).tar.Z
+ echo 'uudecode, gunzip (from GNU), untar' > $(rman).tar.gz.uu
+ uuencode $(rman).tar.gz $(rman).tar.gz >> $(rman).tar.gz.uu
diff --git a/xc/extras/rman/Makefile.mac b/xc/extras/rman/Makefile.mac
new file mode 100644
index 000000000..2bdd606ba
--- /dev/null
+++ b/xc/extras/rman/Makefile.mac
@@ -0,0 +1,105 @@
+#
+# Makefile for RosettaMan
+# It's helpful to read the README-rman file first.
+# You should read over all parts of this file,
+# down to the "you shouldn't modify" line
+#
+# Tom Phelps (phelps@ACM.org)
+#
+# Mac version: Matthias Neeracher <neeri@iis.ee.ethz.ch>
+#
+
+BINDIR = "{{MPW}}LocalTools:"
+
+version = 2.4
+rman = rman-$(version)
+srcs = rman.c getopt.c macish.c
+defs = -d MANTITLEPRINTF='$(MANTITLEPRINTF)' -d MANREFPRINTF='$(MANREFPRINTF)' \
+ -d ROSETTAMANVERSION='"$(version)"'
+libs =
+aux = README-rman Makefile rman.1 rman.html Copyright
+distrib = $(srcs) $(libs) $(aux) contrib
+
+COpt = $(defs) -d macintosh -w off -sym on
+C68K = MWC68K ${COpt} -mc68020 -model far -mbg on
+CPPC = MWCPPC ${COpt} -traceback
+ROptions = -i :
+Lib68K = MWLink68K -xm library -sym on
+LibPPC = MWLinkPPC -xm library -sym on
+LOpt = -sym on -w -xm mpwtool
+Link68K = MWLink68K ${LOpt} -model far
+LinkPPC = MWLinkPPC ${LOpt}
+
+LibFiles68K = "{{MW68KLibraries}}GUSIDispatch.Lib.68K" \
+ "{{MW68KLibraries}}GUSIMPW.Lib.68K" \
+ "{{MW68KLibraries}}MPW_Runtime.o.lib" \
+ "{{MW68KLibraries}}new MPW ANSI (4i/8d) C.68K.Lib" \
+ "{{MW68KLibraries}}MathLib68K (4i/8d).Lib" \
+ "{{MW68KLibraries}}MacOS.Lib" \
+ "{{MW68KLibraries}}GUSI.Lib.68K" \
+ "{{MW68KLibraries}}CPlusPlus.lib" \
+ "{{MW68KLibraries}}ToolLibs.o" \
+ "{{MW68KLibraries}}PLStringFuncs.glue.lib"
+
+LibFilesPPC = "{{MWPPCLibraries}}GUSIMPW.Lib.PPC" \
+ "{{MWPPCLibraries}}GUSI.Lib.PPC" \
+ "{{MWPPCLibraries}}MWStdCRuntime.Lib" \
+ "{{MWPPCLibraries}}InterfaceLib" \
+ "{{MWPPCLibraries}}ANSI (NL) C++.PPC.Lib" \
+ "{{MWPPCLibraries}}ANSI (NL) C.PPC.Lib" \
+ "{{MWPPCLibraries}}StdCLib" \
+ "{{MWPPCLibraries}}MathLib" \
+ "{{MWPPCLibraries}}PPCToolLibs.o"
+
+# the printf strings used to set the <TITLE> and
+# to set URL hyperlinks to referenced manual pages
+# can be defined at runtime. The defaults are defined below.
+# The first %s parameter is the manual page name,
+# the second the volume/section number.
+
+MANTITLEPRINTF = "%s(%s) manual page"
+MANREFPRINTF = "http://localhost/cgi-bin/man2html?%s?%s"
+CP = Duplicate -y
+
+OBJ68K = $(srcs:s/.c/.c.68K.o/)
+OBJPPC = $(srcs:s/.c/.c.PPC.o/)
+
+.SOURCE.o : ":Obj:"
+
+%.c.68K.o : %.c
+ Set Echo 0
+ Set Src68K "{{Src68K}} $<"
+%.c.PPC.o : %.c
+ Set Echo 0
+ Set SrcPPC "{{SrcPPC}} $<"
+
+all: rman
+
+install: all
+ Begin
+ Backup -a -to $(BINDIR) rman
+ End>"{{TempFolder}}"rman.run
+ "{{TempFolder}}"rman.run
+
+rman: rman.68K rman.PPC
+ Duplicate -y rman.PPC rman
+ Echo 'Include "rman.68K" '¶''CODE'¶'';Include "rman.68K" '¶''DATA'¶'';' ¶
+ | Rez -a -c 'MPS ' -t MPST -o rman
+rman.68K: Objects68K
+ ${Link68K} -o rman.68K :Obj:{${OBJ68K}} ${LibFiles68K}
+rman.PPC: ObjectsPPC
+ ${LinkPPC} -o rman.PPC :Obj:{${OBJPPC}} ${LibFilesPPC}
+
+Objects68K : ${OBJ68K}
+ Set Echo 1
+ If "{{Src68K}}" != ""
+ ${C68K} -t -fatext {{Src68K}} -o :Obj:
+ End
+ echo > Objects68K
+
+ObjectsPPC : ${OBJPPC}
+ Set Echo 1
+ If "{{SrcPPC}}" != ""
+ ${CPPC} -t -fatext {{SrcPPC}} -o :Obj:
+ End
+ echo > ObjectsPPC
diff --git a/xc/extras/rman/README-rman b/xc/extras/rman/README-rman
new file mode 100644
index 000000000..b53c34b7b
--- /dev/null
+++ b/xc/extras/rman/README-rman
@@ -0,0 +1,69 @@
+*** INSTALLING ***
+
+Set BINDIR in the Makefile to where you keep your binaries and MANDIR
+to where you keep your man pages (in their source form). (If you're
+using PolyglotMan with TkMan, BINDIR needs to be a component of your
+bin PATH.) After properly editing the Makefile, type `make install'.
+Thereafter (perhaps after a `rehash') type `rman' to invoke PolyglotMan.
+PolyglotMan requires an ANSI C compiler. To compile on a Macintosh
+under MPW, use Makefile.mac.
+
+If you send me bug reports and/or suggestions for new features,
+include the version of PolyglotMan (available by typing `rman -v').
+PolyglotMan doesn't parse every aspect of every man page perfectly, but
+if it blows up spectacularly where it doesn't seem like it should, you
+can send me the man page (or a representative man page if it blows up
+on a class of man pages) in BOTH: (1) [tn]roff source form, from
+.../man/manX and (2) formatted form (as formatted by `nroff -man'),
+uuencoded to preserve the control characters, from .../man/catX.
+
+The home location for PolyglotMan is ftp.cs.berkeley.edu:
+/ucb/people/phelps/tcltk/rman.tar.Z (this is a softlink to the latest,
+numbered version). If you discover a bug and you obtained PolyglotMan
+at some other site, first grab it from this one to see if the problem
+has been fixed.
+
+Be sure to look in the contrib directory for WWW server interfaces,
+a batch converter, and a wrapper for SCO.
+
+--------------------------------------------------
+
+*** NOTES ON CURRENT VERSION ***
+
+Help! I'm looking for people to help with the following projects.
+(1) Better RTF output format. The current one works, but could be
+made better. (2) Extending the macro sets for source recognition. If
+you write an output format or otherwise improve PolyglotMan, please
+send in your code so that I may share the wealth in future releases.
+(3) Fixing output for various (accented?) characters in the Latin1
+character set.
+
+--------------------------------------------------
+
+
+Copyright (c) 1993-1997 Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for educational, research, internal corporate and
+non-profit purposes, without fee, and without a written agreement is
+hereby granted for all cases that do not conflict with the restriction
+in the first sentence of this paragraph, provided that the above
+copyright notice, this paragraph, and the following three paragraphs
+appear in all copies.
+
+Permission to incorporate this software into commercial products may
+be obtained from the Office of Technology Licensing, 2150 Shattuck
+Avenue, Suite 510, Berkeley, CA 94704.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ENHANCEMENTS, OR MODIFICATIONS.
diff --git a/xc/extras/rman/contrib/README-contrib b/xc/extras/rman/contrib/README-contrib
new file mode 100644
index 000000000..111236989
--- /dev/null
+++ b/xc/extras/rman/contrib/README-contrib
@@ -0,0 +1,147 @@
+This directory contains files contributed by PolyglotMan users. These
+files are not installed, supported or regularly updated to work with
+new versions of PolyglotMan. They are included because some may find
+them useful, and if so they prevent duplication of effort.
+
+--
+
+* sutter.txt - "Edward L. Sutter" <els@sage.sage.att.com>
+
+"...converting "man" directories with their typical sub-directories of
+man1, man2, etc... to an equivalently structured "html" directory with
+the same sub-directory heirarchy."
+
+"I added an option to rman that allows it to search for the files over
+a specified set of directories. This allows (for example) manpages under
+man1 that reference something under man3 to be properly linked."
+
+--
+
+* bennett.txt - Anne Bennett <anne@alcor.concordia.ca>
+
+"... I applied the mods in contrib/sutter.txt, and then amplified
+them. I append the relevant context diffs. In short, I added options
+"-P" (a URL prefix for use with the paths found by "-S"), and "-H" and
+"-F" (header and footer HTML files to help adjust the style of the
+resulting page, for example by adding company logos,
+return-to-home-page buttons, etc.)."
+
+--
+
+* authried.txt - Erwin Authried <eauth@mail4u.atnet.at>
+
+"I wrote a small perl script (it's a quick hack) to view man-pages
+with the web-browser."
+
+--
+
+* gzip.patch - Todd Larason <jtl@molehill.org>
+
+"I keep several manpage hierarchies locally, for easy comparison when
+programming for multiple unix machines, most of which are across a
+relatively slow link. To save disk space, I keep them gzipped.
+
+"Here's a small patch to make .so handling work against gzipped files.
+It's a late-night-after-a-long-day hack, but it seems clean enough. If
+you think there might be any interest, feel free to include it either in
+rman itself or the contrib directory. It's against 3.0a3."
+
+--
+
+* man2html - Marc Donner (donner@fid.morgan.com)
+
+A Korn Shell script that is moderately generic. It takes all the
+files in a directory or a set of directories and does them one at a
+time, putting the html output somewhere appropriate. The only
+infelicity in the script is the stuff with localeo (local electronic
+office) which is a hack put together to tweak the URLs not to refer to
+localhost, which is broken right now, but directly to the local
+server's alias.
+
+---
+
+* sco-wrapper.sh - Dag Nygren <dag@newtech.fi>
+
+SCO puts the names of valid man page sections in the file /etc/default/man.
+This wrapper extracts the names from this file and passes them on to
+PolyglotMan for use in determining man page cross references.
+
+---
+
+* http-rman.{c,html} - Fredrik Lundh <fredrik@kalle.teragon.ivab.se>
+
+An HTTP server using PolyglotMan to produce hypertext renditions of
+man-pages on the fly.
+
+---
+
+* lewis.pl - Herb Lewis <herb@chomps.engr.sgi.com>
+
+CGI bin script written in Perl.
+
+---
+
+* hman.{cgi,ksh,pl} by teto@geocities.com
+A more recent version may be available at http://www.geocities.com/SiliconValley/Lakes/8777/hman.html
+
+ hman.cgi An example of a cgi-bin wrapper to launch hman.pl
+ Ideally, all customization should occur here
+ hman.ksh A stand-alone (non-browser) version of hman.cgi
+ hman.pl The core of the PolyglotMan front-end
+
+"I've written a man to html front-end that appears to have unique features:
+A second attempt to locate related man pages is made if the original
+inquiry fails
+
+"Since PolyglotMan can filter nroff's output or can work with raw
+nroff files, this viewer allows selection of the actual man page
+file. Thus either raw or cooked man pages can be selected directly.
+
+"The program is basic perl, but the implementation allows all customization
+to be embodied in enviroment variables that should be set in a cgi-bin
+wrapper."
+
+--
+
+* youki.pl - Youki Kadobayashi <youki@center.osaka-u.ac.jp>
+
+CGI bin script written in Perl 5, and using CGI.pm
+and thus "it can be accelerated with mod_perl".
+
+---
+
+rman_html_split - Robert Moniot <moniot@fordham.edu>
+rman_html_split.1
+
+Breaks up rman HTML output in file (or standard input) into separate
+section files, placing them into a directory. With manual page.
+
+---
+
+Other converters are not included in this directory, but rather are
+available over the net:
+
+* bsdi-man.pl - Fritz Heinrichmeyer
+
+Available at: http://ES-sun2.fernuni-hagen.de
+
+
+* bbc_man2html - Brooks Cutter (brooks@paradyne.com)
+
+Available at: http://www.stuff.com/~bcutter/home/programs/bbc_man2html.html
+
+
+* rman.pl - Alex Gagin
+
+Available at: http://www.jinr.dubna.su/~gagin/rman.pl.html
+
+(Be aware that the communications link is slow.)
+
+
+* manner.pl - Ray W. Hiltbrand
+
+Available at: ftp://ftp.eng.auburn.edu/pub/rayh/man2html/manner.pl
+
+
+The active list kept at http://http.cs.berkeley.edu/~phelps/tcltk/polyglotmen.html
+
diff --git a/xc/extras/rman/contrib/authried.txt b/xc/extras/rman/contrib/authried.txt
new file mode 100644
index 000000000..7bdbc4023
--- /dev/null
+++ b/xc/extras/rman/contrib/authried.txt
@@ -0,0 +1,36 @@
+#!/usr/local/bin/perl
+
+require "common.pl";
+
+$webmaster="webadmin\@domain";
+$man_path="/usr/local/man:/usr/man:/usr/X11/man:/usr/lib/teTeX/man";
+$manpage_and_section = $ENV{"QUERY_STRING"};
+$rman="/usr/local/bin/rman -f HTML";
+
+($manpage,$section)=split("[&]",$manpage_and_section);
+
+
+ split(":",$man_path);
+ foreach(@_){
+ $file=join("", $_, "/man", $section,"/",$manpage,".",$section);
+
+# printf("try %s\n", $file);
+
+ if (-e $file) {
+ exec "echo Content-Type:text/html; echo; cat $file | $rman";
+ }
+ elsif (-e join("",$file,".gz")){
+ exec "echo Content-Type:text/html; echo; zcat $file | $rman";
+ }
+
+ $file=join("",$file,"x");
+ if (-e $file) {
+ exec "echo Content-Type:text/html; echo; cat $file | $rman";
+ }
+ elsif (-e join("",$file,".gz")){
+ exec "echo Content-Type:text/html; echo; zcat $file | $rman";
+ }
+
+ }
+
+&return_error(500,"man2html error","could not find manual page.");
diff --git a/xc/extras/rman/contrib/bennett.txt b/xc/extras/rman/contrib/bennett.txt
new file mode 100644
index 000000000..072facbde
--- /dev/null
+++ b/xc/extras/rman/contrib/bennett.txt
@@ -0,0 +1,371 @@
+*** rman.c.original Tue Jul 16 21:19:49 1996
+--- rman.c Tue Aug 27 15:59:38 1996
+***************
+*** 1,5 ****
+--- 1,9 ----
+ static char rcsid[] = "$Header: /home/ajax/dri-backup/xc/xc/extras/rman/contrib/bennett.txt,v 1.1 2000/07/10 20:49:22 alanh Exp $";
+
++ /* ELS: SearchDirs by "Edward L. Sutter" <els@sage.sage.att.com> */
++ /* AB: HTMLHeader and HTMLFooter by Anne Bennett <anne@alcor.concordia.ca> */
++ /* AB: SearchDirsPrefix by Anne Bennett <anne@alcor.concordia.ca> */
++
+ /*
+ RosettaMan
+
+***************
+*** 265,271 ****
+--- 269,278 ----
+
+ /*** utility functions ***/
+
++ /* 1996/08/26 Anne Bennett patched */
++ int HrefSearch(char *manname, char *section);
+
++
+ /* case insensitive versions of strcmp and strncmp */
+
+ int
+***************
+*** 1338,1343 ****
+--- 1345,1355 ----
+ char *manTitle = MANTITLEPRINTF;
+ char *manRef = MANREFPRINTF;
+ int fmanRef=1; /* valid man ref? */
++ /* 1996/08/26 Anne Bennett patched */
++ char *SearchDirs=0; /* ELS: added for smarter external reference generator. */
++ char *SearchDirsPrefix=0; /* AB: added for HREF prefix to manpage path. */
++ char *HTMLHeader=0; /* AB: added for HTML header and footer files. */
++ char *HTMLFooter=0; /* AB: added for HTML header and footer files. */
+
+ /*
+ * HTML
+***************
+*** 1349,1354 ****
+--- 1361,1373 ----
+ int i,j;
+ int lasttoc;
+ char *p, *p0;
++ /* 1996/08/26 Anne Bennett patched */
++ /* AB: To support HTMLHeader and HTMLFooter */
++ #define SUB_MANNAME "@@MANPAGE_NAME@@"
++ #define SUB_MANSECT "@@MANPAGE_SECTION@@"
++ #define STRING_SIZE 1024
++ char line[STRING_SIZE];
++ FILE *fp;
+
+ /* always respond to these signals */
+ switch (cmd) {
+***************
+*** 1397,1402 ****
+--- 1416,1474 ----
+ /* better title possible? */
+ printf("<TITLE>"); printf(manTitle, manName, manSect); printf("</TITLE>\n");
+ printf("</HEAD>\n<BODY>\n");
++ /* 1996/08/26 Anne Bennett patched */
++ /* AB: added HTMLHeader file, if -H option is set */
++ if (HTMLHeader) {
++ if ((fp = fopen(HTMLHeader,"r")) == NULL) {
++ fprintf(stderr,"Could not open HTMLHeader file\n");
++ }
++ else {
++ /* Output the header file, replacing strings as needed */
++ while (fgets(line, STRING_SIZE, fp) != (char *)NULL) {
++ char *walker, *found;
++ int i;
++
++ /* replace man section */
++ walker = line;
++ while ( ( found = strstr(walker, SUB_MANSECT) ) != NULL ) {
++ if ( ( strlen(line) + strlen(manSect)
++ - strlen (SUB_MANSECT) ) > sizeof(line) ) {
++ fprintf(stderr,"Cannot substitute %s for %s; "
++ "line would be too long:\n "
++ "%s\n", manSect, SUB_MANSECT, line);
++ walker = found + strlen(SUB_MANSECT);
++ }
++ else {
++ (void) memmove(found+strlen(manSect),
++ found+strlen(SUB_MANSECT),
++ strlen(found+strlen(SUB_MANSECT))+1);
++ memcpy(found, manSect, strlen(manSect));
++ walker = found + strlen(manSect);
++ }
++ }
++ /* replace man name */
++ walker = line;
++ while ( ( found = strstr(walker, SUB_MANNAME) ) != NULL ) {
++ if ( ( strlen(line) + strlen(manName)
++ - strlen (SUB_MANNAME) ) > sizeof(line) ) {
++ fprintf(stderr,"Cannot substitute %s for %s; "
++ "line would be too long:\n "
++ "%s\n", manName, SUB_MANNAME, line);
++ walker = found + strlen(SUB_MANNAME);
++ }
++ else {
++ (void) memmove(found+strlen(manName),
++ found+strlen(SUB_MANNAME),
++ strlen(found+strlen(SUB_MANNAME))+1);
++ memcpy(found, manName, strlen(manName));
++ walker = found + strlen(manName);
++ }
++ }
++ printf("%s", line);
++ }
++ fclose(fp);
++ }
++ }
+ printf("<A HREF=\"#toc\">%s</A><P>\n", TABLEOFCONTENTS);
+ I=0;
+ break;
+***************
+*** 1424,1429 ****
+--- 1496,1514 ----
+ if (lasttoc==BEGINSUBSECTION) printf("</UL>");
+ printf("</UL>\n");
+ }
++ /* 1996/08/26 Anne Bennett patched */
++ /* AB: added HTMLFooter file, if -F option is set */
++ if (HTMLFooter) {
++ if ((fp = fopen(HTMLFooter,"r")) == NULL) {
++ fprintf(stderr,"Could not open HTMLFooter file\n");
++ }
++ else {
++ /* Output the footer file */
++ while (fgets(line, STRING_SIZE, fp) != (char *)NULL)
++ printf("%s", line);
++ fclose(fp);
++ }
++ }
+ printf("</BODY></HTML>\n");
+ break;
+ case BEGINBODY: break;
+***************
+*** 1500,1510 ****
+ *p++='\0'; p0=p;
+ for (; *p && *p!=')'; p++) /* empty */;
+ *p='\0';
+! if (fmanRef) { printf("<A HREF=\""); printf(manRef, hitxt, p0); printf("\">"); }
+ else printf("<I>");
+ break;
+ case ENDMANREF:
+! if (fmanRef) printf("</A>"); else printf("</I>");
+ break;
+
+ case BEGINSC: case ENDSC:
+--- 1585,1604 ----
+ *p++='\0'; p0=p;
+ for (; *p && *p!=')'; p++) /* empty */;
+ *p='\0';
+! /* 1996/08/26 Anne Bennett patched */
+! /* ELS: added a call to HrefSearch() if the -S option is set.. */
+! if (SearchDirs)
+! HrefSearch(hitxt,p0);
+! else if (fmanRef) {
+! printf("<A HREF=\"");
+! printf(manRef, hitxt, p0);
+! printf("\">");
+! }
+ else printf("<I>");
+ break;
+ case ENDMANREF:
+! /* 1996/08/26 Anne Bennett patched */
+! if (fmanRef || SearchDirs) printf("</A>"); else printf("</I>");
+ break;
+
+ case BEGINSC: case ENDSC:
+***************
+*** 2744,2754 ****
+--- 2838,2856 ----
+ extern char *optarg;
+ extern int optind, opterr;
+
++ /* 1996/08/26 Anne Bennett patched */
++ /* ELS: added the -S option: */
++ /* AB: added the -H and -F options */
++ /* AB: added the -P option */
+ char strgetopt[80];
+ /* options with an arg must have a '<' in the description */
+ struct { char letter; int arg; char *longnames; char *desc; } option[] = {
+ { 'f', 1, "filter", " <ASCII|roff|TkMan|Tk|Ensemble|Sections|HTML|SGML|MIME|LaTeX|LaTeX2e|RTF|pod>" },
+ { 'r', 1, "reference:manref:ref", " <man reference printf string>" },
++ { 'S', 1, "searchdirs", " <man reference search directories>" },
++ { 'P', 1, "prefix", " <prefix for manpage paths in -S>" },
++ { 'H', 1, "header", " <HTML header file>" },
++ { 'F', 1, "footer", " <HTML footer file>" },
+ { 'l', 1, "title", " <title printf string>" },
+ { 'b', 0, "subsections:sub", " (show subsections)" },
+ { 'n', 1, "name", "(ame of man page) <string>" },
+***************
+*** 2830,2835 ****
+--- 2932,2953 ----
+ case 'r': manRef = optarg;
+ if (strlen(manRef)==0 || strcmp(manRef,"-")==0 || strcmp(manRef,"off")==0) fmanRef=0;
+ break;
++ /* 1996/08/26 Anne Bennett patched */
++ /* ELS: added the -S option: */
++ /* AB: added the -H and -F options */
++ /* AB: added the -P option */
++ case 'S': SearchDirs = optarg;
++ if (strlen(SearchDirs)==0 ) SearchDirs=0;
++ break;
++ case 'P': SearchDirsPrefix = optarg;
++ if (strlen(SearchDirsPrefix)==0 ) SearchDirsPrefix=0;
++ break;
++ case 'H': HTMLHeader = optarg;
++ if (strlen(HTMLHeader)==0 ) HTMLHeader=0;
++ break;
++ case 'F': HTMLFooter = optarg;
++ if (strlen(HTMLFooter)==0 ) HTMLFooter=0;
++ break;
+ case 't': TabStops=atoi(optarg); break;
+ case 'm': fMan=0; break;
+ case 'T': fTable=1; break;
+***************
+*** 2904,2906 ****
+--- 3022,3126 ----
+ filter();
+ return 0;
+ }
++
++
++ /* 1996/08/26 Anne Bennett patched */
++ /* ELS...
++ HrefSearch():
++ Active only with command line option -S...
++ Called when rman -fHTML has determined that it is going to add a
++ hypertext link. The user tells rman where to search for the hypertext
++ links (local machine search only) and if HrefSearch() finds the file
++
++ SRCHDIR/manname.section
++
++ where
++ SRCHDIR is one of the colon-delimited paths specified with
++ the -S option;
++ manname is the text that rman found preceding a "manname(##)"
++ detection;
++ section is the string within the parens of the manname spec;
++
++
++ then it will use that path to build the HREF line. If not found,
++ then <A> is all that is inserted.
++ This is generally only helpful when you are simply attempting to
++ turn a man directory into an html directory.
++
++ Note that if the first char of SearchDirs is a colon, then if
++ HrefSearch does not find the reference, it defaults to what rman
++ used to do (use manRef, -r option); otherwise, it will not add
++ a hypertext link at all.
++ */
++ int HrefSearch(char *manname, char *section)
++ {
++ char *dir, *colon, tmp;
++ int DefaultToManRef;
++ FILE *fp;
++ static char path[256];
++
++ tmp = 0;
++
++ again:
++ if (SearchDirs[0] == ':') {
++ dir = &SearchDirs[1];
++ DefaultToManRef = 1;
++ }
++ else {
++ dir = SearchDirs;
++ DefaultToManRef = 0;
++ }
++
++ /* Make 2 passes on all search directories... */
++ /* First pass is with the path dir/manname.section */
++ /* Second pass is with the path dir/manname.section[0] */
++ /* This allows the spec manname(3x) to be found as manname.3 */
++ /* just in cast manname.3x doesn't exist. */
++ /* Note that the second pass is only necessary if the section */
++ /* string is more than one character in length. */
++ while(1) {
++ colon = strchr(dir,':');
++ if (colon) *colon = 0;
++ sprintf(path,"%s/%s.%s.html",dir,manname,section);
++ /* 1996/08/26 Anne: read-only, not rw, please. */
++ if ((fp = fopen(path,"r")) != NULL) {
++ printf("<A HREF=\"");
++ /* AB: Put in the manpage location prefix */
++ if (SearchDirsPrefix)
++ printf("%s",SearchDirsPrefix);
++ printf("%s",path);
++ printf("\">");
++ fclose(fp);
++ if (colon) *colon = ':';
++ fprintf(stderr,"HREF @ %s\n",path);
++ return(1);
++ }
++ if (colon) {
++ *colon = ':';
++ dir = colon+1;
++ }
++ else
++ break;
++ }
++ if (section[1]) {
++ tmp = section[1];
++ section[1] = 0;
++ dir = SearchDirs;
++ goto again;
++ }
++ if (tmp)
++ section[1] = tmp;
++
++ /* 1996/08/27 Anne Bennett: use manRef only if set */
++ if (DefaultToManRef && manRef) {
++ printf("<A HREF=\"");
++ printf(manRef, manname, section);
++ printf("\">");
++ }
++ else
++ printf("<A>");
++ return(1);
++ }
++
++ /* End ELS additions. */
++
+*** rman.1.original Tue Jul 16 21:19:49 1996
+--- rman.1 Tue Aug 27 15:16:29 1996
+***************
+*** 75,80 ****
+--- 75,109 ----
+ or `off', then man page references will not be HREFs, just set
+ in italics.
+ .TP 15
++ -S|--searchDirs \fIcolon-separated-directories \fR
++ Valid only with \fI-fHTML \fR, this option modifies the behaviour of
++ rman when inserting a hyperlink to a referenced manpage.
++ The directories indicate where to look
++ for a pre-HTMLized version of the referenced manpage under the name
++ " \fIname \fR. \fIsection \fR. \fIhtml \fR". If the file is not
++ found, no hypertext link is added, except if the first character of
++ the directories list is a colon, in which case a link is added using
++ manRef, ( \fI-r \fR option).
++ .TP 15
++ -P|--prefix \fIstring \fR
++ Valid only with \fI-S \fR, the string indicates what prefix to add to
++ the path when constructing the hyperlink for a referenced manpage.
++ The string will usually be
++ similar to that given with \fI-r \fR, except that there will be no
++ printf-style escapes, for example "http://localhost/manpages".
++ .TP 15
++ -H|--header \fIfilename \fR
++ Valid only with \fI-fHTML \fR, the filename refers to a file
++ containing an HTML "header", which might consist of, for example, a
++ company logo, or body color specifications. If the strings
++ "@@MANPAGE_NAME@@" or "@@MANPAGE_SECTION@@" are found in this file,
++ they are replaced by the appropriate manpage name and section.
++ .TP 15
++ -F|--footer \fIfilename \fR
++ Valid only with \fI-fHTML \fR, the filename refers to a file
++ containing an HTML "footer", which might consist of, for example, a
++ link back to the site's home page.
++ .TP 15
+ -s|section \fI# \fR
+ Set volume (aka section) number of man page (used in roff format).
+ .TP 15
+
diff --git a/xc/extras/rman/contrib/gzip.patch b/xc/extras/rman/contrib/gzip.patch
new file mode 100644
index 000000000..d10666b6a
--- /dev/null
+++ b/xc/extras/rman/contrib/gzip.patch
@@ -0,0 +1,46 @@
+--- rman.c.~1~ Wed Nov 20 13:33:52 1996
++++ rman.c Fri Oct 24 00:10:56 1997
+@@ -3583,6 +3583,43 @@
+ }
+ free(sobuf);
+ }
++ } else {
++#define GZIP "/bin/gzip"
++ char * gz = malloc(strlen(p)+3+1);
++ sprintf(gz, "%s.gz", p);
++ if (stat(gz, &fileinfo)==0) {
++ /* first, figure out how big */
++ char * cmd = malloc(strlen(gz) + strlen(GZIP) + 7 + 1);
++ char buffer[512];
++ unsigned long compr, uncomp;
++ FILE * proc;
++ sprintf(cmd, "%s -l \"%s\"", GZIP, gz);
++ proc = popen(cmd, "r");
++ fgets(buffer, sizeof buffer, proc); /* label line */
++ fgets(buffer, sizeof buffer, proc); /* length line */
++ sscanf(buffer, "%lu %lu", &compr, &uncomp);
++ fclose(proc);
++ /* Boy, don't you wish stat would do that? */
++ sobuf = malloc(uncomp + 1);
++ if (sobuf!=NULL) {
++ /* suck in entire file, as above */
++ sprintf(cmd, "%s -dc \"%s\"", GZIP, gz);
++ proc = popen(cmd, "r");
++ if (proc!=NULL) {
++ if(fread(sobuf, 1, uncomp, proc)) {
++ sobuf[uncomp]='\0';
++ for (q=sobuf; (q=strstr(q," \\}"))!=NULL; q+=3) *q='\n';
++ source_subfile(sobuf);
++ err = 0;
++ }
++ fclose(proc);
++ }
++ free(sobuf);
++ }
++ free(cmd);
++ }
++ free(gz);
++
+ }
+
+ if (err) {
diff --git a/xc/extras/rman/contrib/hman.cgi b/xc/extras/rman/contrib/hman.cgi
new file mode 100755
index 000000000..540899c03
--- /dev/null
+++ b/xc/extras/rman/contrib/hman.cgi
@@ -0,0 +1,7 @@
+#!/bin/ksh
+##########
+export MANPATH=/trane/mach/man:/trane/share/man:/usr/man:/usr/X11/man:/usr/openwin/man:/var/man
+export PATH=/trane/mach/bin:/trane/share/bin:$PATH
+export HMANPRG=rman
+export HMANOPT='-b -f html'
+exec /home/teto/dev/hman/hman.pl
diff --git a/xc/extras/rman/contrib/hman.ksh b/xc/extras/rman/contrib/hman.ksh
new file mode 100755
index 000000000..99df60107
--- /dev/null
+++ b/xc/extras/rman/contrib/hman.ksh
@@ -0,0 +1,9 @@
+#!/bin/ksh
+##########
+export MANPATH=/trane/mach/man:/trane/share/man:/usr/man:/usr/X11/man:/usr/openwin/man:/var/man
+export PATH=/trane/mach/bin:/trane/share/bin:$PATH
+export HMANPRG=rman
+export HMANOPT='-b -f html'
+export QUERY_STRING='DirectPath=/usr/man/cat4.Z/cdf.4'
+export QUERY_STRING='ManTopic=test&ManSection=key'
+perl -d /home/teto/dev/hman/hman.pl
diff --git a/xc/extras/rman/contrib/hman.pl b/xc/extras/rman/contrib/hman.pl
new file mode 100755
index 000000000..dfed39703
--- /dev/null
+++ b/xc/extras/rman/contrib/hman.pl
@@ -0,0 +1,261 @@
+#!/usr/bin/perl -w
+#!/citi/gtfd/mach/bin/perl -w
+###############
+# $Id: hman.pl,v 1.1 2000/07/10 20:49:22 alanh Exp $
+# $Source: /home/ajax/dri-backup/xc/xc/extras/rman/contrib/hman.pl,v $
+############################################
+# TODO:
+# reorganize location of man pages - move 3x stuff from man3 to man3x
+# recurse - if 'man 3x curses' does not work try 'man 3 curses'
+# display more STDERR
+# Fix broken whatis entries - instead of
+# manpage section - description
+# manpage description section -
+# highlite keywords found
+# pass MANPATH as a command line argument
+############################################
+# Inspired by:
+# http://www.jinr.dubna.su/~gagin
+# http://thsun1.jinr.dubna.su/~gagin/rman.pl
+# http://thsun1.jinr.dubna.su/cgi-bin/rman.pl
+# http://www.jinr.dubna.su/~gagin/rman.pl.html
+#
+# CGI form interface to PolyglotMan program, which is available as
+# ftp://ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z
+#
+# The most recent version of this program available as
+# http://www.geocities.com/SiliconValley/Lakes/8777/hman.html
+#---------------------------------------------------------------------
+# This is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# hman 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 software; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+# THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
+# CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
+# PERFOHMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
+# NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
+# SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
+# SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
+# PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES").
+# ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES
+# IS SPECIFICALLY DISCLAIMED.
+#---------------------------------------------------------------------
+# Request form: hman.pl?ManTopic=SOMETOPIC&ManSection=SECTION
+# Request form: hman.pl?DirectPath=filename
+#
+#---------------------------------------------------------------------
+# Stuff to change
+
+# path to PolyglotMan program. "-b" is not nessesary
+$hman="$ENV{HMANPRG} $ENV{HMANOPT}";
+
+# path to man program
+$ManPrg='/usr/bin/man';
+
+# path to cat program
+$ENV{PAGER} = '/bin/cat';
+
+# path to man directories
+($ManPathFind = $ENV{MANPATH}) =~ s/:/ /g;
+
+# URL to this program
+$hmanpl='/cgi-bin/hman';
+
+# if man produced number of lines less then follows,
+# I assume that request failed
+$emptyman=5;
+
+# tail of every produced html document
+$HtmlTail='<hr><A HREF="' . $hmanpl . '">Back to Hman</a>';
+# $HtmlTitle="<title>CGI form interface to PolyglotMan</title>\n";
+$HtmlHdr="Content-type: text/html\n\n";
+
+# end changable things
+#----------------------------------------------------------------------
+@ManSections = (
+ '1', 'user commands',
+ '2', 'system calls',
+ '3', 'subroutines',
+ '4', 'devices',
+ '5', 'file formats',
+ '6', 'games',
+ '7', 'miscellanious',
+ '8', 'sys. admin.',
+ '9', 'Linux Internals',
+ 'n', 'section n'
+);
+
+# Set unbuffered I/O. Prevents buffering problems with
+# "system()" calls.
+select((select(STDOUT), $| = 1)[0]);
+print $HtmlHdr;
+
+$string = $ENV{QUERY_STRING};
+#
+# Initial Form
+#
+if($string eq "") { initialForm(); }
+
+#
+# Generic parameter parsing ...
+#
+$DirectPath = $ManSection = $ManTopic = "";
+$string =~ s/&/'; \$/g;
+$string =~ s/=/='/g;
+$string =~ s/^(.*)$/\$$1';/;
+eval $string;
+
+hmanDirect($DirectPath) if ($DirectPath ne "");
+
+if ($ManTopic eq "") { badness("<code>Topic for man search needed</code>\n"); }
+
+if ($ManSection eq "") { badness("<code>No section specified</code>\n"); }
+
+$ManSection =~ s/all//;
+if ($ManSection =~ /key/) { manKey($ManTopic); }
+
+findIt($ManTopic);
+open(MANOUT, "$ManPrg $ManSection $ManTopic |")
+ || die "$hmanpl: can't run \"$ManPrg Section $ManTopic |\", $!\n";
+for (0..$emptyman) {
+ $temp = <MANOUT> || last;
+ push @temp, $temp;
+}
+#
+if (@temp < $emptyman) {
+ close(MANOUT);
+ print"<strong>Request failed for topic $ManTopic:</strong>\n<code>";
+ for (@temp) {print;}
+ print "</code><br><h3>Let's try a keyword search:</h3><hr>\n";
+ manKey($ManTopic);
+}
+#
+$cmd = "$hman -r \"$hmanpl?ManTopic=%s&ManSection=%s\" -l \"Man page for $ManTopic";
+if ($ManSection eq "") {
+ $cmd .= '"';
+} else {
+ $cmd .= "($ManSection)\"";
+}
+#
+open(HMANIN, "| $cmd") || die "$hmanpl: can't open $cmd: $!\n";
+for (@temp) {print HMANIN;}
+while(<MANOUT>){print HMANIN;}
+close(MANOUT);
+close(HMANIN);
+
+exitIt();
+###############################################################################
+sub initialForm {
+ print <<EOF;
+<h1>Select a manual page:</h1>
+ <FORM METHOD="GET" action="$hmanpl">
+ <table border=0>
+ <tr>
+ <td align=right>Section:</td>
+ <td>
+ <select name=ManSection>
+ <OPTION value=all>All</option>
+ <OPTION value=key>Keyword Search</option>
+EOF
+ for ($ndx = 0; $ndx < @ManSections; $ndx += 2) {
+ print ' <OPTION value=' . $ManSections[$ndx] . '>'
+ . "$ManSections[$ndx] - $ManSections[$ndx + 1] "
+ . '</option>' . "\n";
+ }
+ print <<EOF;
+ </SELECT>
+ </td>
+ </tr>
+ <tr>
+ <td align=right>Topic:</td>
+ <td><input type="TEXT" name="ManTopic"></td>
+ </tr>
+ <tr>
+ <td align=right><INPUT TYPE="submit" VALUE="Search">
+ <td align=left><input type="reset" value="Reset">
+ </td>
+ </tr>
+ </table>
+ </FORM>
+EOF
+ exitIt();
+}
+sub findIt {
+ my($topic) = ($_[0]);
+ my($cmd, $mixedCase, $navigation, $zcat);
+ $mixedCase = '';
+ foreach (split(/\s*/, $topic)) {
+ $mixedCase .= "[" . $_ . uc($_) . "]";
+ }
+ $cmd = 'find ' . $ManPathFind . ' \( -type f -o -type l \) -name '
+ . $mixedCase .'\* | sort -t. +1';
+ open(FINDIN, "$cmd |") || die "can't open pipe \"$cmd |\": $!";
+ $navigation = 0;
+ while (<FINDIN>) {
+ if ($navigation == 0) {
+ print "<UL>\n";
+ $navigation = 1;
+ }
+ $_ =~ s/[\n\r]*$//;
+ print "<li><A HREF=\"$hmanpl?DirectPath=$_\">$_</a>\n";
+ }
+ close(FINDIN);
+ print "</UL><hr>\n" if ($navigation == 1);
+}
+sub hmanDirect {
+ my($path) = ($_[0], $_[1]);
+ my($cmd, $dir, $topic, $section);
+ ($dir = $path) =~ s/\.(gz|z|Z)$//;
+ ($topic = $dir) =~ s,^.*/,,;
+ $dir =~ s,/[^/]*/[^/]*$,,;
+ # $dir =~ s,/[^/]*$,,;
+ ($section=$topic)=~s/^.*\.([^\.]*)$/$1/;
+ $topic =~ s/\.[^\.]*$//;
+ findIt($topic);
+ $cmd = "cd $dir; (gzip -dc < $path 2>/dev/null || cat < $path) | $hman -r '"
+ . $hmanpl . '?ManTopic=%s&ManSection=%s' ."' -l 'Man page for $topic($section)'";
+ system($cmd) || warn "can't run command \"$cmd\": $!";
+ print $HtmlTail;
+ exit 0;
+}
+sub exitIt {
+ print $HtmlTail;
+ exit 0;
+}
+sub badness {
+ my($text) = ($_[0]);
+ print "<strong>Request failed:</strong> $text, Try again<hr>\n";
+ initialForm();
+}
+sub manKey {
+ my($topic) = ($_[0]);
+ open(TMPHTML,"$ManPrg -k $topic | sort -u |")
+ || die "can't open pipe \"$ManPrg -k $topic | sort -u |\": $!\n";
+ print "<title>Keyword search results for \"$topic\"</title>\n";
+ print "<h1>Keyword search results for \"$topic\"</h1><hr>\n";
+ while(<TMPHTML>) {
+ s/\( \)//g;
+ next if (! /^([^(]+)\s*\(([^)]+)[^-]+-\s(.*)[\n\r]*$/);
+ @topics=split(/, /,$1);
+ next if ($2 eq "");
+ print "<h2>$3:</h2>\n";
+ print "<UL>\n";
+ for $topic (@topics) {
+ print "<li><A HREF=\"$hmanpl?ManSection=$2&ManTopic=$topic\">$topic</a>($2)\n";
+ }
+ print "</UL>\n";
+ }
+ close(TMPHTML);
+ exitIt();
+}
diff --git a/xc/extras/rman/contrib/http-rman.c b/xc/extras/rman/contrib/http-rman.c
new file mode 100644
index 000000000..8ab82ee49
--- /dev/null
+++ b/xc/extras/rman/contrib/http-rman.c
@@ -0,0 +1,200 @@
+/* $Id: http-rman.c,v 1.1 2000/07/10 20:49:23 alanh Exp $
+ *
+ * Name:
+ * http-rman.c -- a rudimentary man-page HTTP server
+ *
+ * Description:
+ * This is a minimal HTTP server using RosettaMan by T.A. Phelps
+ * (phelps@ACM.org) to produce hypertext renditions
+ * of man-pages on the fly.
+ *
+ * This server processes URLs with the following syntax:
+ *
+ * [/man] ?<command> [ ?<section> ]
+ *
+ * For URLs matching this format, it pipes the output of
+ * man <section> <command> through rman and sends it to
+ * the HTTP client. For other URLs, it returns the document
+ * given as argv[1] (using cat(1). The leading /man is
+ * optional, but is strongly recommended.
+ *
+ * This server is shipped as two files, the http-rman.c
+ * sources and the http-rman.html sample frontpage. I have
+ * not included a Makefile; you can write your own or just
+ * type [g]cc -o http-rman http-rman.c
+ *
+ * What do I need to run this:
+ * If you don't have it, pick up RosettaMan by anonymous ftp
+ * from ftp.cs.berkeley.edu: /ucb/people/phelps/tcl/rman.tar.Z
+ *
+ * You'll also need an HTTP client such as NCSA Mosaic to talk
+ * to this server. Mosaic is available by anonymous FTP from
+ * ftp://ftp.ncsa.uiuc.edu/Mosaic
+ *
+ * Both RosettaMan (rman) and Mosaic are available from many
+ * other sites. Try Archie, or check your local or national net
+ * archive.
+ *
+ * How do I get it running:
+ * First, compile the server (see above), and install it
+ * somewhere.
+ *
+ * The server runs under inetd(8). Add a service to
+ * /etc/services, say:
+ *
+ * http-rman 4080/tcp
+ *
+ * If you're not about to install another HTTP server on your
+ * machine, you may use the default HTTP port, 80, instead.
+ *
+ * Then add an entry to /etc/inetd.conf, such as (on a single line):
+ *
+ * http-rman stream tcp nowait root /usr/local/bin/http-rman
+ * http-rman /usr/local/lib/rman/http-rman.html
+ *
+ * Change /usr/local/bin and /usr/local/lib/rman to where you
+ * installed the two files. In addition, you may wish to run
+ * the server as something other than root...
+ *
+ * Restart inetd(8) (use kill -HUP or kill it and start it again)
+ * and try the following:
+ *
+ * $ Mosaic http://localhost:4080
+ *
+ * If you don't have Mosaic, try the following instead:
+ *
+ * $ telnet localhost 4080
+ * Trying 127.0.0.1...
+ * Connected to localhost.
+ * Escape character is '^]'.
+ * GET /man?ls <return>
+ * <return>
+ * HTTP/1.0 200 OK
+ * ...
+ *
+ * Portability:
+ * You'll need an ANSI compiler (or an editor and some patience).
+ * As it stands right now, this code has been successfully
+ * compiled on OSF/1 AXP using cc, and on SunOS 4.1 using gcc.
+ * Might need some tuning for other platforms.
+ *
+ * Legal Issues:
+ * Check the external visibility of the http-rman service
+ * you choose. This server gives a user access to ALL man-
+ * pages on your machine. You may have installed copyrighted
+ * software (your operating system, for example) with
+ * man-pages that you are NOT allowed to make visible for
+ * anyone out there...
+ *
+ * History:
+ * 94-04-30 fl: created
+ * 94-05-13 fl: stripped away everything but rman support
+ *
+ * Copyright (c) Fredrik Lundh 1994 (fredrik_lundh@ivab.se)
+ * All rights reserved.
+ */
+
+
+#include <stdio.h> /* printf(), fflush(stdio) etc */
+#include <string.h> /* strrchr(), strcmp() etc */
+
+
+static int
+http_error(int error)
+{
+ char *p;
+
+ switch (error) {
+ case 400:
+ p = "Bad Request";
+ break;
+ case 404:
+ p = "Not Found";
+ break;
+ default:
+ p = "Error";
+ }
+ printf("HTTP/1.0 %d %s\r\n", error, p);
+ printf("MIME-version: 1.0\r\n");
+ printf("Content-Type: text/html\r\n\r\n");
+ printf("<head><title>%d %s</title></head>\r\n", error, p);
+ printf("<body><h1>%d %s</h1></body>\r\n", error, p);
+ return 0;
+}
+
+
+static int
+http_rman(char *url)
+{
+ char *pName;
+ char *pSection;
+ char buf[200];
+
+ /* parse URL: should be /man?command[?section] */
+ pSection = strrchr(url, '?');
+ if (!pSection) {
+ return -1;
+ }
+ pName = pSection-1;
+ *pSection++ = '\0';
+
+ pName = strrchr(url, '?');
+ if (!pName) {
+ pName = pSection;
+ pSection = "";
+ }
+ else
+ pName++;
+
+ sprintf(buf, "man %s %s | rman -r \"man?%%s?%%s\" -n %s -f html",
+ pSection, pName, pName);
+
+ return system(buf);
+}
+
+
+int
+main(int ac, char **av)
+{
+ char buf[200];
+ char url[200];
+ int status;
+ char *sFrontpage = "/usr/local/lib/rman/http-rman.html";
+
+/* check arguments */
+
+ if (ac > 1)
+ sFrontpage = av[1];
+
+/* just read in one line from stdin and make sure it is a GET
+command */
+
+ if (gets(buf)) {
+
+ /* read rest of command (just for the sake of it) */
+ while (gets(url) && url[0] != '\r')
+ ;
+
+ /* command should be GET <url> [HTTP/1.0] */
+ if (sscanf(buf, "GET %s", url) == 1) {
+
+ status = http_rman(url);
+
+ if (status < 0) {
+ sprintf(buf, "cat %s", sFrontpage);
+ if (system(buf) == 0)
+ status = 0;
+ }
+
+ if (status < 0)
+ http_error(404);
+
+ } else
+
+ http_error(400);
+ }
+
+ fflush(stdout);
+
+ exit(0);
+}
diff --git a/xc/extras/rman/contrib/http-rman.html b/xc/extras/rman/contrib/http-rman.html
new file mode 100644
index 000000000..ec4cb5973
--- /dev/null
+++ b/xc/extras/rman/contrib/http-rman.html
@@ -0,0 +1,21 @@
+HTTP/1.0 200 OK
+Server: http-rman 1.0
+MIME-Version: 1.0
+Content-Type: text/html
+Content-Transfer-Encoding: binary
+
+<html>
+<!-- this is a sample frontpage for the http-rman man-page server -->
+<!-- Copyright (c) 1994 Fredrik Lundh (fredrik_lundh@ivab.se) -->
+<head><title>RosettaMan Gateway</title></head>
+<h1>RosettaMan Gateway</h1>
+
+This is a gateway to the man pages on this machine. Please enter the
+function or command you want to know more about.
+<p>
+<isindex>
+<p>
+The hypertext man-pages are generated on the fly using the excellent
+<A HREF="/man?rman">RosettaMan</A> utility by T.A. Phelps. This minimal
+HTTP-server was written by Fredrik Lundh.
+</html>
diff --git a/xc/extras/rman/contrib/lewis.pl b/xc/extras/rman/contrib/lewis.pl
new file mode 100644
index 000000000..116b652c2
--- /dev/null
+++ b/xc/extras/rman/contrib/lewis.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+
+# Syntax: man2html <topic> <section>
+
+# Print out a content-type for HTTP/1.0 compatibility
+print "Content-type: text/html\n\n";
+
+if( $ENV{'REQUEST_METHOD'} eq "GET" )
+{
+ $buffer=$ENV{'QUERY_STRING'} ;
+ @ARGV = split(/&/,$buffer) ;
+}
+
+@manpage = `man @ARGV[1] @ARGV[0] | rman -f html -n @ARGV[0] -s
+@ARGV[1]`;
+
+print "@manpage";
diff --git a/xc/extras/rman/contrib/man2html b/xc/extras/rman/contrib/man2html
new file mode 100755
index 000000000..3df77a3a8
--- /dev/null
+++ b/xc/extras/rman/contrib/man2html
@@ -0,0 +1,108 @@
+#!/bin/ksh
+
+# Take a man tree and make an html tree out of it
+
+DOMAIN=$(domainname)
+ARCH=$(arch)
+
+case ${DOMAIN} in
+ acf) localeo=reo1 ;;
+ bwfid) localeo=reo1 ;;
+ chfid) localeo=neo1 ;;
+ hkfid) localeo=teo1 ;;
+ lnfid) localeo=leo1 ;;
+ nyfid) localeo=neo1 ;;
+ psfid) localeo=leo1 ;;
+ sffid) localeo=neo1 ;;
+ tkfid) localeo=teo1 ;;
+ esac
+
+sections="{1,2,3,4,5,6,7,8}"
+from=/usr/man
+to=/u/eo/repository/system/unix/man
+
+function disambiguate
+{
+newbase=${1}
+newname="${newbase}.1"
+dis=2
+while [ -a "${newname}" ]
+ do
+ newname=$newbase"."$dis
+ dis=$(expr $dis + 1)
+ done
+}
+
+while getopts f:t:l:is:v c
+ do
+ case $c in
+ f) from=$OPTARG ;;
+ t) to=$OPTARG ;;
+ l) localeo=$OPTARG ;;
+ i) indexonly=1 ;;
+ s) sections=$OPTARG ;;
+ v) verbose=1 ;;
+ esac
+ done
+shift OPTIND-1
+
+if [ "${verbose}" ]
+ then
+ print "from: $from"
+ print "to: $to"
+ print "localeo: $localeo"
+ print "sections: $sections"
+ if [ "${indexonly}" ]
+ then
+ print "indexonly: 1"
+ fi
+ fi
+
+cd $from
+
+if [ ! "${indexonly}" ]
+ then
+ print "Processing the man pages ..."
+ for i in man${sections}/*
+ do
+ if [ "$verbose" ]
+ then
+ print $i
+ fi
+ # n=${i%.*}
+ name=${to}/${i}
+ if [ -a "${name}" ]
+ then
+ oldname=$name
+ disambiguate $name
+ name=$newname
+ print "Collision - ${oldname} will be stored as ${name}"
+ fi
+ eqn $i | tbl | nroff -man | rman -f HTML | sed -e "s/MS_LOCAL_HOST/${localeo}/g" > ${name}
+ done
+ fi
+
+print "Building the index.html files ..."
+cd $to
+for i in man${sections}
+ do
+ if [ "$verbose" ]
+ then
+ print $i
+ fi
+ cd $i
+ rm -f index.html
+ echo '<ul>' > ../new.html
+ for j in *
+ do
+ if [ "$verbose" ]
+ then
+ print -n "$j "
+ fi
+ print
+ print "<li> <a href=$j>$j</a>" >> ../new.html
+ done
+ echo '</ul>' >> ../new.html
+ mv ../new.html index.html
+ cd ..
+ done
diff --git a/xc/extras/rman/contrib/rman_html_split b/xc/extras/rman/contrib/rman_html_split
new file mode 100755
index 000000000..aafb023c5
--- /dev/null
+++ b/xc/extras/rman/contrib/rman_html_split
@@ -0,0 +1,324 @@
+#!/bin/sh
+#
+# Script to break up rman html output into separate sections in a directory.
+#
+# Author: Robert Moniot <moniot@fordham.edu>
+# Date: 4 Aug 1998
+#
+
+version="rman_html_split V1.0 (c) 1998 Robert K. Moniot"
+
+ # Usage function prints synopsis and exits
+Usage(){
+ myname=`echo $0 | sed -e 's,.*/,,'`
+cat <<EOF
+
+Usage: $myname [ options ] [ file ]
+
+Breaks up rman HTML output in file (or standard input) into separate
+section files, placing them into a directory.
+
+Options:
+ -d | --html-dir dir Place output into directory dir (default = html).
+ -m | --merge # Merge sections 0 thru # (default 1) into one file.
+ -t | --toc-first Link index.html to table of contents instead
+ of to sect0.html.
+ -T | --title "title" Use "title" as title on top of each page
+ instead of rman's title. "title" may be empty.
+ -h | --help Print synopsis and exit.
+ -V | --version Print version information and exit.
+EOF
+ exit 0
+}
+
+ # Version function prints version number and exits
+Version(){
+ echo "$version"
+ exit 0
+}
+
+ # This function puts out header needed by all but 1st page.
+do_header(){
+cat <<EOF
+<HTML>
+<HEAD>
+<TITLE>$*</TITLE>
+</HEAD>
+<BODY>
+EOF
+do_title
+}
+
+ # This function puts out the title with name of manpage
+do_title(){
+ if [ -n "$title" ]
+ then
+ echo "<H2>$title</H2>"
+ fi
+}
+
+ # This function puts out ref to table of contents that
+ # follows header for all but 1st and toc page.
+do_href_toc(){
+cat <<EOF
+<A HREF="toc.html">Table of Contents</A><P>
+EOF
+}
+
+ # This function puts out ref to previous section
+do_href_prev(){
+ echo "<P>Previous: <A HREF=\"$1.html\">$2</A><HR><P>"
+}
+
+ # This function puts out footer needed by all but last page.
+do_footer(){
+cat <<EOF
+</BODY></HTML>
+EOF
+}
+
+ # This function changes the trailing NAME anchor
+ # of a section into an href to the next section.
+ # The first edit is for sections. The second edit
+ # handles the toc anchor, which has no href and so
+ # is missed by the first edit.
+do_href_next(){
+ sed -e '$s,^.*<A NAME="\([^"]*\)" HREF=[^>]*>\([^<]*\).*$,<P><HR><P>Next: <A HREF="\1.html">\2</A>,' \
+ -e '$s,<A NAME="\(toc[^"]*\)",Next: <A HREF="\1.html",'
+}
+
+ # This function adapts internal refs from one-big-file
+ # form into multi-file format.
+ # First edit changes "#tocn" into "toc.html#tocn"
+ # Second edit changes "#sectn" into "sectn.html#sectn"
+ # Third edit changes "#toc" into "toc.html"
+change_hrefs(){
+ sed -e 's,HREF="#toc\([0-9][0-9]*\)",HREF="toc.html#toc\1",g' \
+ -e 's,HREF="#sect\([0-9][0-9]*\)",HREF="sect\1.html#sect\1",g' \
+ -e 's,HREF="#\(toc\)",HREF="\1.html",g'
+}
+
+
+# Execution begins here.
+
+ # Process the command-line options.
+htmldir="html"
+mergesect="1"
+
+while [ $# != 0 ]
+do
+ case $1 in
+
+ -d | --html-dir)
+ shift
+ if [ $# != 0 ]
+ then
+ htmldir="$1"
+ shift
+ fi
+ ;;
+
+ -m | --merge)
+ shift
+ if [ $# != 0 ]
+ then
+ mergesect="$1"
+ shift
+ fi
+ case $mergesect in
+ [0-9])
+ ;;
+ *)
+ echo "ERROR: merge section must be a digit from 0 to 9."
+ Usage
+ ;;
+ esac
+ ;;
+
+ -t | --toc-first)
+ shift
+ tocfirst="t"
+ ;;
+
+ -T | --title)
+ shift
+ if [ $# != 0 ]
+ then
+ title="$1"
+ shift
+ fi
+ if [ -z "$title" ] # If title is the null string, set notitle
+ then
+ notitle="t"
+ fi
+ ;;
+
+ -h | --help)
+ Usage
+ ;;
+
+ -V | --version)
+ Version
+ ;;
+
+ # Unrecognized flag.
+ -*)
+ echo "Unrecognized option: $1"
+ Usage
+ ;;
+
+ # Non-flag: go to process file.
+ *)
+ break
+ ;;
+ esac
+done
+
+ # At this point we should have at most one
+ # argument, the file name. Check it.
+if [ $# -gt 1 ]
+then
+ Usage
+fi
+
+if [ $# = 1 ]
+then
+ if [ ! -r "$1" ]
+ then
+ echo "ERROR: Cannot open file $1."
+ exit 1
+ fi
+fi
+
+ # Filter the input (file arg or stdin) thru a sed script
+ # that fixes cases where an anchor for a section has
+ # had its section title split across two or more lines.
+ # Put the result in a tmp file so it can be re-read.
+
+filename="/tmp/rman_html_split_$$.html"
+trap "rm -f $filename" 0
+sed -e ':top' \
+ -e '/^<H[1-9]><A NAME="sect.*[^>]$/N' \
+ -e '/^<LI><A NAME="toc.*[^>]$/N' \
+ -e 's/\n/ /' \
+ -e 't top' $1 > $filename
+
+ # If user did not supply title, get title for top of
+ # each page from rman-generated <TITLE> line. If user
+ # gave a blank title then leave it blank.
+if [ -z "$title" -a -z "$notitle" ]
+then
+ title=`sed -e '/^<TITLE>/q' $filename |
+ sed -n -e 's,^<TITLE>\([^<]*\).*$,\1,p'`
+fi
+
+ # Get a list of all the sections. Separate it into a
+ # list of merged sections and a list of all other sections.
+ # Merged sects are combined and get special treatment besides.
+allsects=`sed -n 's,^.*<A NAME="\(sect[0-9][0-9]*\)".*$,\1,p' $filename`
+
+mergesects=`echo $allsects | \
+ awk '{for(i=1; i<=NF && i<'"$mergesect"+2'; i++) print \$i;}'`
+
+sectlist=`echo $allsects |
+ awk '{for(i='"$mergesect"'+2; i<=NF; i++) print \$i;}'`
+
+
+# This little bit, copied from GNU configure, sets ac_n and ac_c such
+# that echo $ac_n "stuff $ac_c" yields "stuff " w/o following newline.
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+ # Create html directory if it does not exist.
+if [ -d $htmldir ]
+then
+ echo "Re-using directory $htmldir."
+else
+ echo "Creating directory $htmldir..."
+ if mkdir $htmldir
+ then
+ true
+ else
+ echo "Failed!"
+ exit 1
+ fi
+fi
+
+echo "Creating section pages..."
+
+ # Produce index page. It is special, since it combines
+ # merged sections and uses the rman-generated header.
+nextsect=`echo $sectlist | awk '{print $1;}'`
+echo $ac_n $mergesects "$ac_c"
+(do_title ;
+ sed -n -e "1,/^<H[23]><A NAME=\"$nextsect\"/p" $filename | \
+ do_href_next | \
+ change_hrefs ;
+ do_footer) > $htmldir/sect0.html
+
+ # Produce pages for all other sections except toc.
+prevsect="sect$mergesect"
+prevtext=`sed -n 's,^<H[23]><A NAME="'$prevsect'" HREF="#toc[0-9][0-9]*">\([^<]*\).*$,\1,p' $filename | sed -e 's/ *$//'`
+for sect in $sectlist;
+do
+ echo $ac_n "$sect $ac_c"
+ headtext=`sed -n 's,^<H[23]><A NAME="'$sect'" HREF="#toc[0-9][0-9]*">\([^<]*\).*$,\1,p' $filename | sed -e 's/ *$//'`
+ (do_header $headtext ;
+ do_href_toc ;
+ do_href_prev "$prevsect" "$prevtext" ;
+ sed -n -e '/<A NAME="'$sect'"/,/<A NAME=/p' $filename |
+ do_href_next |
+ change_hrefs ;
+ do_footer) > $htmldir/$sect.html
+ prevsect="$sect"
+ prevtext="$headtext"
+done
+
+
+ # Produce table of contents
+echo "toc"
+(do_header Table of Contents ;
+ sed -n -e '/<A NAME="toc">/,$p' $filename | \
+ change_hrefs ;
+) > $htmldir/toc.html
+
+
+ # Finally, make sure the symlinks index.html and
+ # sect1.html -> sect0.html are in place, and if not,
+ # create them. If --tocfirst is not specified, then
+ # link index.html to section 0, otherwise link it to
+ # index.html
+
+echo "Doing symlinks..."
+cd $htmldir
+
+rm -f index.html
+if [ -z "$tocfirst" ]
+then
+ echo "Linking index.html -> sect0.html"
+ ln -s sect0.html index.html
+else
+ echo "Linking index.html -> toc.html"
+ ln -s toc.html index.html
+fi
+
+for sect in $mergesects
+do
+ if [ "$sect" != "sect0" ]
+ then
+ echo "Linking $sect.html -> sect0.html"
+ rm -f $sect.html
+ ln -fs sect0.html $sect.html
+ fi
+done
+
+echo "Done."
diff --git a/xc/extras/rman/contrib/rman_html_split.1 b/xc/extras/rman/contrib/rman_html_split.1
new file mode 100644
index 000000000..5d3cb4d59
--- /dev/null
+++ b/xc/extras/rman/contrib/rman_html_split.1
@@ -0,0 +1,71 @@
+.TH rman_html_split 1 "4 Aug 1998"
+.SH NAME
+rman_html_split \- split rman html output into separate sections
+.SH SYNOPSIS
+.B rman_html_split
+[
+.I options
+] [
+.I file
+]
+.SH DESCRIPTION
+The \fBrman_html_split\fP script reads a file containing HTML produced
+from a manual page by the \fBrman\fP(1) program, and splits it into a
+set of files, each containing one section or subsection of the manual.
+Each section file has added to it an optional header identifying the
+program described by the manual page, a link to the table of contents,
+and links to the previous section and the next section. The separate
+section files are placed in a subdirectory. A symbolic link named
+\fIindex.\|html\fP is created in this subdirectory, linked to either
+\fIsect0.\|html\fP (the first section) or \fItoc.\|html\fP (the table
+of contents section).
+.PP
+Use this script to split a large manual page into smaller, more
+manageable parts for use as online web-based documentation.
+.SH OPTIONS
+.TP
+.BR "\-d \fIdir\fP" " | " "\-\-html\-dir \fIdir\fP"
+Place output into directory \fIdir\fP. The default directory name is
+\fIhtml\fP.
+.TP
+.BR "\-m \fInum\fP" " | " "\-\-merge \fInum\fP"
+Merge sections 0 thru \fInum\fP into one file. The default for
+\fInum\fP is 1, since usually section 0 is the NAME section and
+section 1 is SYNOPSIS, which are usually both short and go well
+together. Set
+.I num
+to 0 to prevent merging, or set it to a larger number to merge more
+initial sections. Maximum value of \fInum\fP is 9. There is no
+provision for merging sections other than consecutive numbers from
+section 0.
+.TP
+.BR \-t " | " \-\-toc\-first
+Link \fIindex.\|html\fP to the table of contents. By default, it is
+linked to \fIsect0.\|html\fP. Use this if you prefer the initial page
+to be the table of contents rather than the first section of the
+manual page.
+.TP
+.BR "\-T \fItitle\fP" " | " "\-\-title \fItitle\fP"
+Use \fItitle\fP as a header on top of each page. This header is
+displayed using the H2 HTML tag. By default, \fBrman_html_split\fP uses
+the title generated by \fBrman\fP. By making \fItitle\fP the empty
+string (""), the header can be suppressed entirely.
+.TP
+.BR \-h " | " \-\-help
+Print synopsis and exit.
+.TP
+.BR \-V " | " \-\-version
+Print version information and exit.
+.SH SEE ALSO
+.BR man (1),
+.BR rman (1).
+.SH BUGS
+You tell me.
+.SH AUTHOR
+Robert K. Moniot <moniot@fordham.edu>
+.br
+Fordham University
+.br
+Department of Computer and Information Sciences
+.br
+New York, NY
diff --git a/xc/extras/rman/contrib/sco-wrapper.sh b/xc/extras/rman/contrib/sco-wrapper.sh
new file mode 100755
index 000000000..95d7610ed
--- /dev/null
+++ b/xc/extras/rman/contrib/sco-wrapper.sh
@@ -0,0 +1,6 @@
+#
+REALRMAN=/usr/local/bin/rman.real
+VOLLISTFILE=/etc/default/man
+
+VOLLIST=`grep '^ORDER' $VOLLISTFILE | cut -f2 -d=`
+exec $REALRMAN -V "=$VOLLIST" $*
diff --git a/xc/extras/rman/contrib/sutter.txt b/xc/extras/rman/contrib/sutter.txt
new file mode 100644
index 000000000..b467bb348
--- /dev/null
+++ b/xc/extras/rman/contrib/sutter.txt
@@ -0,0 +1,155 @@
+"Edward L. Sutter" <els@sage.sage.att.com>
+
+Perhaps there is already a better way to do this, but since I couldn'd find
+one, I'd like to make a suggestion that has helped me quite a bit for getting
+the proper hypertext links. Keep in mind that this is under the context of
+me converting "man" directories with their typical sub-directories of
+man1, man2, etc... to an equivalently structured "html" directory with
+the same sub-directory heirarchy.
+
+I added an option to rman that allows it to search for the files over
+a specified set of directories. This allows (for example) manpages under
+man1 that reference something under man3 to be properly linked.
+
+rman.c v2.4 ...
+
+...
+
+/* ELS: added to support a smarter external reference generator. */
+char *SearchDirs=0;
+int HrefSearch();
+
+...
+
+/* ELS: added the -S option: */
+ while ((c=getopt(argc,argv,"Kh?f:l:r:bckmTpvn:t:s:yS:"))!=-1)
+ switch (c) {
+ case 'k': fHeadfoot=1; break;
+ case 'b': fSubsections=1; break;
+ case 'c': fChangeleft=1; break;
+ case 'S': SearchDirs=optarg; break;
+
+
+...
+
+
+void
+HTML(enum command cmd) {
+
+...
+
+
+ case BEGINMANREF:
+ for (p=hitxt; *p && *p!='('; p++) /* empty */;
+ *p++='\0'; p0=p;
+ for (; *p && *p!=')'; p++) /* empty */;
+ *p='\0';
+/* ELS: added a call to HrefSearch() if the -S option is set.. */
+ if (SearchDirs)
+ HrefSearch(hitxt,p0);
+ else {
+ printf("<A HREF=\"");
+ printf(manRef, hitxt, p0);
+ printf("\">");
+ }
+ break;
+
+
+...
+
+
+/* ELS...
+ HrefSearch():
+ Active only with command line option -S...
+ Called when rman -fHTML has determined that it is going to add a
+ hypertext link. The user tells rman where to search for the hypertext
+ links (local machine search only) and if HrefSearch() finds the file
+
+ SRCHDIR/manname.section
+
+ where
+ SRCHDIR is one of the colon-delimited paths specified with
+ the -S option;
+ manname is the text that rman found preceding a "manname(##)"
+ detection;
+ section is the string within the parens of the manname spec;
+
+
+ then it will use that path to build the HREF line. If not found,
+ then <A> is all that is inserted.
+ This is generally only helpful when you are simply attempting to
+ turn a man directory into an html directory.
+
+ Note that if the first char of SearchDirs is a colon, then if
+ HrefSearch does not find the reference, it defaults to what rman
+ used to do (use manRef, -r option); otherwise, it will not add
+ a hypertext link at all.
+*/
+HrefSearch(manname,section)
+char *manname, *section;
+{
+ char *dir, *colon, tmp;
+ int DefaultToManRef;
+ FILE *fp;
+ static char path[256];
+
+ tmp = 0;
+
+again:
+ if (SearchDirs[0] == ':') {
+ dir = &SearchDirs[1];
+ DefaultToManRef = 1;
+ }
+ else {
+ dir = SearchDirs;
+ DefaultToManRef = 0;
+ }
+
+ /* Make 2 passes on all search directories... */
+ /* First pass is with the path dir/manname.section */
+ /* Second pass is with the path dir/manname.section[0] */
+ /* This allows the spec manname(3x) to be found as manname.3 */
+ /* just in cast manname.3x doesn't exist. */
+ /* Note that the second pass is only necessary if the section */
+ /* string is more than one character in length. */
+ while(1) {
+ colon = strchr(dir,':');
+ if (colon) *colon = 0;
+ sprintf(path,"%s/%s.%s.html",dir,manname,section);
+ if ((fp = fopen(path,"rw")) != NULL) {
+ printf("<A HREF=\"");
+ printf("%s",path);
+ printf("\">");
+ fclose(fp);
+ if (colon) *colon = ':';
+ fprintf(stderr,"HREF @ %s\n",path);
+ return(1);
+ }
+ if (colon) {
+ *colon = ':';
+ dir = colon+1;
+ }
+ else
+ break;
+ }
+ if (section[1]) {
+ tmp = section[1];
+ section[1] = 0;
+ dir = SearchDirs;
+ goto again;
+ }
+ if (tmp)
+ section[1] = tmp;
+
+ if (DefaultToManRef) {
+ printf("<A HREF=\"");
+ printf(manRef, manname, section);
+ printf("\">");
+ }
+ else
+ printf("<A>");
+ return(1);
+}
+
+/* End ELS additions. */
+
diff --git a/xc/extras/rman/contrib/youki.pl b/xc/extras/rman/contrib/youki.pl
new file mode 100755
index 000000000..8af5865d6
--- /dev/null
+++ b/xc/extras/rman/contrib/youki.pl
@@ -0,0 +1,195 @@
+#!/usr/local/bin/perl5
+#
+# CGI script for translating manpage into html on the fly.
+# Front-end for PolyglotMan (formerly called RosettaMan)
+#
+# Author: Youki Kadobayashi <youki@center.osaka-u.ac.jp>
+#
+# NOTE: Replace 'CGI::Apache' with just 'CGI' for systems without mod_perl.
+#
+# ALSO: You may want to recompile rman like this:
+# MANREFPRINTF = "/mod-bin/cgi-rman.pl?keyword=%s&section=%s"
+#
+
+use CGI::Apache font; # for people with mod_perl and apache
+## use CGI font; # for people without mod_perl
+$par = "<P>\n";
+$brk = "<BR>\n";
+$bg = '#c0ffff';
+
+$query = new CGI::Apache; # for people with mod_perl and apache
+## $query = new CGI; # for people without mod_perl
+
+%mandatory = ('keyword' => 'Name or keyword',
+ 'section' => 'Manual page section');
+
+@given = $query->param;
+if ($#given < 0) {
+ &request_page;
+ exit 0;
+}
+
+foreach $field (keys %mandatory) {
+ if ($query->param($field) eq '') {
+ push(@missing, $mandatory{$field});
+ }
+}
+if ($#missing >= 0) {
+ &info_missing_page(@missing);
+} else {
+ if ($query->param('type') eq 'apropos') {
+ &apropos_page;
+ } else {
+ &manual_page;
+ }
+}
+exit 0;
+
+sub standout {
+ my ($level, $color, $string) = @_;
+
+ # As per CGI.pm documentation "Generating new HTML tags"
+ return $query->font({color => "$color"}, "<$level>$string</$level>");
+}
+
+sub error_page {
+ my ($message) = @_;
+
+# print $query->header,
+# $query->start_html(-title=>$message, -BGCOLOR=>$bg);
+
+ print &standout("H2", "brown", $message),
+ "The above error occured during the manual page generation",
+ " process. Please check keyword and section number,",
+ " then try again.", $par;
+
+# print $query->end_html;
+}
+
+sub info_missing_page {
+ my (@missing) = @_;
+
+ print $query->header,
+ $query->start_html(-title=>"Information is missing",
+ -BGCOLOR=>$bg);
+
+ print &standout("H2", "brown", "Information is missing"),
+ "Sorry but your request was not fulfilled because",
+ " the following information is missing in your entry:", $par,
+ join(' ', @missing), $par,
+ "Please go back and make sure to enter data on the missing field.";
+
+ print $query->end_html;
+}
+
+sub request_page {
+ print $query->header,
+ $query->start_html(-title=>'Hypertext Manual Page',
+ -author=>'Youki Kadobayashi',
+ -BGCOLOR=>$bg);
+
+ print &standout("H2", "green", "Hypertext Manual Page");
+
+ print $query->start_form,
+ "Type of Search: ",
+ $query->radio_group(-name=>'type',
+ -values=>['man', 'apropos'],
+ -default=>'man'), $brk,
+ "Name or Keyword: ",
+ $query->textfield(-name=>'keyword'), $brk,
+ "Manpage Section: ",
+ $query->popup_menu(-name=>'section',
+ -labels=>{
+ 0 => 'All Sections',
+ 1 => '1 - General Commands',
+ 2 => '2 - System Calls',
+ 3 => '3 - Library Functions',
+ 4 => '4 - Device Special Files',
+ 5 => '5 - File Formats',
+ 6 => '6 - Games',
+ 7 => '7 - Macros and Conventions',
+ 8 => '8 - System Administration',
+ 'pgsql' => 'PostgreSQL',
+ 'tcl' => 'Tcl/Tk',
+ 'mh' => 'Message Handler',
+ 'isode' => 'ISODE',
+ 'X11' => 'X Window System'},
+ -values=>[0, 1, 2, 3, 4, 5, 6, 7, 8,
+ 'pgsql', 'tcl', 'mh',
+ 'isode', 'X11'],
+ -default=>0), $brk;
+
+ print $query->submit(-name=>'Submit'), $query->reset,
+ $query->end_form, $par;
+
+ print $query->end_html;
+}
+
+sub manual_page {
+ my $keyword = $query->param('keyword');
+ my $section = $query->param('section');
+ my $man = "man";
+ my $ok = "-a-zA-Z0-9._";
+
+ # sanitize for security
+ $section =~ s/[^$ok]+/_/go;
+ $keyword =~ s/[^$ok]+/_/go;
+
+ if ($section =~ /^[A-Za-z]/) {
+ $man .= " -M$section";
+ }
+ elsif ($section =~ /^\d/) {
+ $section =~ s/^(\d)\w*/\1/go;
+ $man .= " -s $section";
+ }
+ $man .= ' ' . $keyword;
+ open (MAN, "$man | /usr/local/bin/rman -f html -n $keyword -s $section |");
+
+ print $query->header;
+ # start_html and end_html not needed here, since rman tacks them.
+ print "<!-- text generated with '$man' by cgi-rman.pl -->\n";
+ while (<MAN>) {
+ print $_;
+ }
+ if ($? != 0 || $. < 15) {
+ &error_page("Your request for manual page '$keyword' failed.");
+# print "return code $? line $.\n";
+ close(MAN);
+ return;
+ }
+ close(MAN);
+}
+
+sub apropos_page {
+ my $keyword = $query->param('keyword');
+ my $section = $query->param('section'); # igored
+ my $man = "man -k";
+ my $matches = 0;
+
+ $man .= ' ' . $keyword;
+ open (MAN, "$man |");
+
+ $url = $query->url;
+ print $query->header, $query->start_html(-title=>$man);
+
+ while (<MAN>) {
+ if (/^([a-zA-Z0-9_.-]+)[, ][a-zA-Z0-9_., -]*\((\d)\w*\)/) {
+ print $`, qq{ <A HREF="$url?keyword=$1&section=$2&type=man"> },
+ $&, "</A>", $';
+ ++$matches;
+ } else {
+ print $_;
+ }
+ print $brk;
+ }
+ if ($? != 0 || $matches == 0) {
+ &error_page("Your search request with keyword '$keyword' failed.");
+# print "return code $? matches $matches\n";
+ close(MAN);
+ return;
+ }
+ close(MAN);
+
+ print $query->end_html;
+}
+
diff --git a/xc/extras/rman/getopt.c b/xc/extras/rman/getopt.c
new file mode 100644
index 000000000..b5e8403ef
--- /dev/null
+++ b/xc/extras/rman/getopt.c
@@ -0,0 +1,79 @@
+/*
+Newsgroups: mod.std.unix
+Subject: public domain AT&T getopt source
+Date: 3 Nov 85 19:34:15 GMT
+
+Here's something you've all been waiting for: the AT&T public domain
+source for getopt(3). It is the code which was given out at the 1985
+UNIFORUM conference in Dallas. I obtained it by electronic mail
+directly from AT&T. The people there assure me that it is indeed
+in the public domain.
+*/
+
+/*LINTLIBRARY*/
+
+extern int strlen();
+extern int strcmp();
+extern char *strchr();
+extern int write();
+
+#define NULL 0
+#define EOF (-1)
+#define ERR(s, c) if(opterr){\
+ char errbuf[2];\
+ errbuf[0] = c; errbuf[1] = '\n';\
+ (void) write(2, argv[0], (unsigned)strlen(argv[0]));\
+ (void) write(2, s, (unsigned)strlen(s));\
+ (void) write(2, errbuf, 2);}
+
+
+int opterr = 1;
+int optind = 1;
+int optopt;
+char *optarg;
+
+int
+getopt(argc, argv, opts)
+int argc;
+char **argv, *opts;
+{
+ static int sp = 1;
+ register int c;
+ register char *cp;
+
+ if(sp == 1)
+ if(optind >= argc ||
+ argv[optind][0] != '-' || argv[optind][1] == '\0')
+ return(EOF);
+ else if(strcmp(argv[optind], "--") == NULL) {
+ optind++;
+ return(EOF);
+ }
+ optopt = c = argv[optind][sp];
+ if(c == ':' || (cp=strchr(opts, c)) == NULL) {
+ ERR(": illegal option -- ", c);
+ if(argv[optind][++sp] == '\0') {
+ optind++;
+ sp = 1;
+ }
+ return('?');
+ }
+ if(*++cp == ':') {
+ if(argv[optind][sp+1] != '\0')
+ optarg = &argv[optind++][sp+1];
+ else if(++optind >= argc) {
+ ERR(": option requires an argument -- ", c);
+ sp = 1;
+ return('?');
+ } else
+ optarg = argv[optind++];
+ sp = 1;
+ } else {
+ if(argv[optind][++sp] == '\0') {
+ sp = 1;
+ optind++;
+ }
+ optarg = NULL;
+ }
+ return(c);
+}
diff --git a/xc/extras/rman/macish.c b/xc/extras/rman/macish.c
new file mode 100644
index 000000000..57dd8de8b
--- /dev/null
+++ b/xc/extras/rman/macish.c
@@ -0,0 +1,6 @@
+#include <QuickDraw.h>
+
+void InitToolbox()
+{
+ InitGraf(&qd.thePort);
+}
diff --git a/xc/extras/rman/rman.1 b/xc/extras/rman/rman.1
new file mode 100644
index 000000000..7be339197
--- /dev/null
+++ b/xc/extras/rman/rman.1
@@ -0,0 +1,269 @@
+.TH PolyglotMan 1
+.SH "NAME "
+PolyglotMan, rman - reverse compile man pages from formatted
+form to a number of source formats
+.SH "SYNOPSIS "
+rman [ \fIoptions \fR] [ \fIfile \fR]
+.SH "DESCRIPTION "
+\fIPolyglotMan \fR takes man pages from most of the popular flavors
+of UNIX and transforms them into any of a number of text source
+formats. PolyglotMan was formerly known as RosettaMan. The name
+of the binary is still called \fIrman \fR, for scripts that depend
+on that name; mnemonically, just think "reverse man". Previously \fI
+PolyglotMan \fR required pages to be formatted by nroff prior
+to its processing. With version 3.0, it \fIprefers [tn]roff source \fR
+and usually produces results that are better yet. And source
+processing is the only way to translate tables. Source format
+translation is not as mature as formatted, however, so try formatted
+translation as a backup.
+.PP
+In parsing [tn]roff source, one could implement an arbitrarily
+large subset of [tn]roff, which I did not and will not do, so
+the results can be off. I did implement a significant subset
+of those use in man pages, however, including tbl (but not eqn),
+if tests, and general macro definitions, so usually the results
+look great. If they don't, format the page with nroff before
+sending it to PolyglotMan. If PolyglotMan doesn't recognize a
+key macro used by a large class of pages, however, e-mail me
+the source and a uuencoded nroff-formatted page and I'll see
+what I can do. When running PolyglotMan with man page source
+that includes or redirects to other [tn]roff source using the .so (source
+or inclusion) macro, you should be in the parent directory of
+the page, since pages are written with this assumption. For example,
+if you are translating /usr/man/man1/ls.1, first cd into /usr/man.
+.PP
+\fIPolyglotMan \fR accepts man pages from: SunOS, Sun Solaris,
+Hewlett-Packard HP-UX, AT&T System V, OSF/1 aka Digital UNIX,
+DEC Ultrix, SGI IRIX, Linux, FreeBSD, SCO. Source processing
+works for: SunOS, Sun Solaris, Hewlett-Packard HP-UX, AT&T System
+V, OSF/1 aka Digital UNIX, DEC Ultrix. It can produce printable
+ASCII-only (control characters stripped), section headers-only,
+Tk, TkMan, [tn]roff (traditional man page source), SGML, HTML,
+MIME, LaTeX, LaTeX2e, RTF, Perl 5 POD. A modular architecture
+permits easy addition of additional output formats.
+.PP
+The latest version of PolyglotMan is always available from \fI
+ftp://ftp.cs.berkeley.edu/ucb/people/phelps/tcltk/rman.tar.Z \fR.
+.SH "OPTIONS "
+The following options should not be used with any others and
+exit PolyglotMan without processing any input.
+.TP 15
+-h|--help
+Show list of command line options and exit.
+.TP 15
+-v|--version
+Show version number and exit.
+.PP
+\fIYou should specify the filter first, as this sets a number
+of parameters, and then specify other options.
+.TP 15
+-f|--filter <ASCII|roff|TkMan|Tk|Sections|HTML|SGML|MIME|LaTeX|LaTeX2e|RTF|POD>
+Set the output filter. Defaults to ASCII.
+.TP 15
+-S|--source
+PolyglotMan tries to automatically determine whether its input
+is source or formatted; use this option to declare source input.
+.TP 15
+-F|--format|--formatted
+PolyglotMan tries to automatically determine whether its input
+is source or formatted; use this option to declare formatted
+input.
+.TP 15
+-l|--title \fIprintf-string \fR
+In HTML mode this sets the <TITLE> of the man pages, given the
+same parameters as \fI-r \fR.
+.TP 15
+-r|--reference|--manref \fIprintf-string \fR
+In HTML and SGML modes this sets the URL form by which to retrieve
+other man pages. The string can use two supplied parameters:
+the man page name and its section. (See the Examples section.)
+If the string is null (as if set from a shell by "-r ''"), `-'
+or `off', then man page references will not be HREFs, just set
+in italics. If your printf supports XPG3 positions specifier,
+this can be quite flexible.
+.TP 15
+-V|--volumes \fI<colon-separated list> \fR
+Set the list of valid volumes to check against when looking for
+cross-references to other man pages. Defaults to \fI1:2:3:4:5:6:7:8:9:o:l:n:p \fR(volume
+names can be multicharacter). If an non-whitespace string in
+the page is immediately followed by a left parenthesis, then
+one of the valid volumes, and ends with optional other characters
+and then a right parenthesis--then that string is reported as
+a reference to another manual page. If this -V string starts
+with an equals sign, then no optional characters are allowed
+between the match to the list of valids and the right parenthesis. (This
+option is needed for SCO UNIX.)
+.PP
+The following options apply only when formatted pages are given
+as input. They do not apply or are always handled correctly with
+the source.
+.TP 15
+-b|--subsections
+Try to recognize subsection titles in addition to section titles.
+This can cause problems on some UNIX flavors.
+.TP 15
+-K|--nobreak
+Indicate manual pages don't have page breaks, so don't look for
+footers and headers around them. (Older nroff -man macros always
+put in page breaks, but lately some vendors have realized that
+printout are made through troff, whereas nroff -man is used to
+format pages for reading on screen, and so have eliminated page
+breaks.) \fIPolyglotMan \fR usually gets this right even without
+this flag.
+.TP 15
+-k|--keep
+Keep headers and footers, as a canonical report at the end of
+the page. changeleft
+Move changebars, such as those found in the Tcl/Tk manual pages,
+to the left. --> notaggressive
+\fIDisable \fR aggressive man page parsing. Aggressive manual,
+which is on by default, page parsing elides headers and footers,
+identifies sections and more. -->
+.TP 15
+-n|--name \fIname \fR
+Set name of man page (used in roff format). If the filename is
+given in the form " \fIname \fR. \fIsection \fR", the name and
+section are automatically determined. If the page is being parsed
+from [tn]roff source and it has a .TH line, this information
+is extracted from that line.
+.TP 15
+-p|--paragraph
+paragraph mode toggle. The filter determines whether lines should
+be linebroken as they were by nroff, or whether lines should
+be flowed together into paragraphs. Mainly for internal use.
+.TP 15
+-s|section \fI# \fR
+Set volume (aka section) number of man page (used in roff format).
+tables
+Turn on aggressive table parsing. -->
+.TP 15
+-t|--tabstops \fI# \fR
+For those macros sets that use tabs in place of spaces where
+possible in order to reduce the number of characters used, set
+tabstops every \fI# \fR columns. Defaults to 8.
+.SH "NOTES ON FILTER TYPES "
+.SS "ROFF "
+Some flavors of UNIX ship man page without [tn]roff source, making
+one's laser printer little more than a laser-powered daisy wheel.
+This filer tries to intuit the original [tn]roff directives,
+which can then be recompiled by [tn]roff.
+.SS "TkMan "
+TkMan, a hypertext man page browser, uses \fIPolyglotMan \fR
+to show man pages without the (usually) useless headers and footers
+on each pages. It also collects section and (optionally) subsection
+heads for direct access from a pulldown menu. TkMan and Tcl/Tk,
+the toolkit in which it's written, are available via anonymous
+ftp from \fIftp://ftp.smli.com/pub/tcl/ \fR
+.SS "Tk "
+This option outputs the text in a series of Tcl lists consisting
+of text-tags pairs, where tag names roughly correspond to HTML.
+This output can be inserted into a Tk text widget by doing an \fI
+eval <textwidget> insert end <text> \fR. This format should be
+relatively easily parsible by other programs that want both the
+text and the tags. Also see ASCII.
+.SS "ASCII "
+When printed on a line printer, man pages try to produce special
+text effects by overstriking characters with themselves (to produce
+bold) and underscores (underlining). Other text processing software,
+such as text editors, searchers, and indexers, must counteract
+this. The ASCII filter strips away this formatting. Piping nroff
+output through \fIcol -b \fR also strips away this formatting,
+but it leaves behind unsightly page headers and footers. Also
+see Tk.
+.SS "Sections "
+Dumps section and (optionally) subsection titles. This might
+be useful for another program that processes man pages.
+.SS "HTML "
+With a simple extention to an HTTP server for Mosaic or other
+World Wide Web browser, \fIPolyglotMan \fR can produce high quality
+HTML on the fly. Several such extensions and pointers to several
+others are included in \fIPolyglotMan \fR's \fIcontrib \fR directory.
+.SS "SGML "
+This is appoaching the Docbook DTD, but I'm hoping that someone
+that someone with a real interest in this will polish the tags
+generated. Try it to see how close the tags are now.
+.SS "MIME "
+MIME (Multipurpose Internet Mail Extensions) as defined by RFC 1563,
+good for consumption by MIME-aware e-mailers or as Emacs (>=19.29)
+enriched documents.
+.SS "LaTeX and LaTeX2e "
+Why not?
+.SS "RTF "
+Use output on Mac or NeXT or whatever. Maybe take random man
+pages and integrate with NeXT's documentation system better.
+Maybe NeXT has own man page macros that do this.
+.SS "PostScript and FrameMaker "
+To produce PostScript, use \fIgroff \fR or \fIpsroff \fR. To
+produce FrameMaker MIF, use FrameMaker's builtin filter. In both
+cases you need \fI[tn]roff \fR source, so if you only have a
+formatted version of the manual page, use \fIPolyglotMan \fR's
+roff filter first.
+.SH "EXAMPLES "
+To convert the \fIformatted \fR man page named \fIls.1 \fR back
+into [tn]roff source form:
+.PP
+\fIrman -f roff /usr/local/man/cat1/ls.1 > /usr/local/man/man1/ls.1 \fR
+.br
+.PP
+Long man pages are often compressed to conserve space (compression
+is especially effective on formatted man pages as many of the
+characters are spaces). As it is a long man page, it probably
+has subsections, which we try to separate out (some macro sets
+don't distinguish subsections well enough for \fIPolyglotMan \fR
+to detect them). Let's convert this to LaTeX format:
+.br
+.PP
+\fIpcat /usr/catman/a_man/cat1/automount.z | rman -b -n automount -s 1 -f
+latex > automount.man \fR
+.br
+.PP
+Alternatively, \fIman 1 automount | rman -b -n automount -s 1 -f
+latex > automount.man \fR
+.br
+.PP
+For HTML/Mosaic users, \fIPolyglotMan \fR can, without modification
+of the source code, produce HTML links that point to other HTML
+man pages either pregenerated or generated on the fly. First
+let's assume pregenerated HTML versions of man pages stored in \fI/usr/man/html \fR.
+Generate these one-by-one with the following form:
+.br
+\fIrman -f html -r 'http:/usr/man/html/%s.%s.html' /usr/man/cat1/ls.1 > /usr/man/html/ls.1.html \fR
+.br
+.PP
+If you've extended your HTML client to generate HTML on the fly
+you should use something like:
+.br
+\fIrman -f html -r 'http:~/bin/man2html?%s:%s' /usr/man/cat1/ls.1 \fR
+.br
+when generating HTML.
+.SH "BUGS/INCOMPATIBILITIES "
+\fIPolyglotMan \fR is not perfect in all cases, but it usually
+does a good job, and in any case reduces the problem of converting
+man pages to light editing.
+.PP
+Tables in formatted pages, especially H-P's, aren't handled very
+well. Be sure to pass in source for the page to recognize tables.
+.PP
+The man pager \fIwoman \fR applies its own idea of formatting
+for man pages, which can confuse \fIPolyglotMan \fR. Bypass \fI
+woman \fR by passing the formatted manual page text directly
+into \fIPolyglotMan \fR.
+.PP
+The [tn]roff output format uses fB to turn on boldface. If your
+macro set requires .B, you'll have to a postprocess the \fIPolyglotMan \fR
+output.
+.SH "SEE ALSO "
+\fItkman(1) \fR, \fIxman(1) \fR, \fIman(1) \fR, \fIman(7) \fR
+or \fIman(5) \fR depending on your flavor of UNIX
+.SH "AUTHOR "
+PolyglotMan
+.br
+by Thomas A. Phelps ( \fIphelps@ACM.org \fR)
+.br
+developed at the
+.br
+University of California, Berkeley
+.br
+Computer Science Division
+.PP
+Manual page last updated on $Date: 2000/07/10 20:49:14 $
diff --git a/xc/extras/rman/rman.c b/xc/extras/rman/rman.c
new file mode 100644
index 000000000..1e20cc254
--- /dev/null
+++ b/xc/extras/rman/rman.c
@@ -0,0 +1,5460 @@
+static char rcsid[] = "Header: /home/cs/phelps/spine/rman/RCS/rman.c,v 1.144 1999/08/10 00:41:55 phelps Exp phelps $";
+
+/*
+ PolyglotMan by Thomas A. Phelps (phelps@ACM.org)
+
+ accept man pages as formatted by (10)
+ Hewlett-Packard HP-UX, AT&T System V, SunOS, Sun Solaris, OSF/1, DEC Ultrix,
+ SGI IRIX, Linux, FreeBSD, SCO
+
+ output as (9)
+ printable ASCII, section headers only, TkMan, [tn]roff, HTML,
+ LaTeX, LaTeX2e, RTF, Perl pod, MIME, and soon SGML
+
+ written March 24, 1993
+ bs2tk transformed into RosettaMan November 4-5, 1993
+ source interpretation added September 24, 1996
+ renamed PolyglotMan due to lawsuit by Rosetta, Inc. August 8, 1997
+*/
+/* $XFree86: xc/extras/rman/rman.c,v 1.9 2000/06/13 23:15:47 dawes Exp $ */
+
+
+/* TO DO ****
+
+ clean up relationship between source and formatted filtering support routines
+
+ output to SGML with Davenport DTD
+
+ don't give SHORTLINE if just finished bullet of bultxt, ended section head, ... other cases?
+ make sure text following bullet is aligned correctly
+
+ output to WinHelp? don't have specs (anybody interested?)
+ collect header and footer until hit blank line?
+ what to do about tables? count second gap of spaces & average gap? ==>
+ good idea but tables too variable for this to work
+ internal, outline-like header section for HTML documents? how to put this *first*? (can't in single pass)
+ one line look ahead to enable better parsing (item lists, et cetera)
+ alluc (==nonlc) flag, copy curline to last line vector (works well with lookahead cache)
+ ?? collect sundry globals into vectors (i.e., arrays and enum indexes)
+ (if compiler has good constant propagation, then shouldn't slow access)
+ collect scattered globals into vectors (e.g., curline[ispcnt]): array + enum
+ curline, lastline, flags, pending, bufs+lens
+*/
+
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <assert.h>
+/* I'm sure I'll need some #ifdef's here to include the right headers */
+/* ... but compiles swell on Solaris, DEC Alpha, HP, SunOS */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#ifdef Lynx
+extern int optind;
+extern char *optarg;
+#endif
+
+/*** make #define's into consts? => can't because compilers not smart enough ***/
+/* maximum number of tags per line */
+#define MAXTAGS 50*100
+/* BUFSIZ = 1024 on Solaris */
+#define MAXBUF 2*5000
+#define MAXLINES 20000
+#define MAXTOC 500
+#define xputchar(c) (fcharout? putchar(c): (c))
+#define sputchar(c) (fcharout? plain[sI++]=(char)c: (char)(c))
+#define stagadd(tag) tagadd(tag,sI,0)
+enum { c_rsquote='\''/*\x27*/, c_lsquote='`'/*\x60*/, c_dagger='\xa7', c_bullet='\xb7', c_plusminus='\xb1' };
+
+
+/*** tag management ***/
+
+enum tagtype { NOTAG, TITLE, ITALICS, BOLD, SYMBOL, SMALLCAPS, BOLDITALICS, MONO, MANREF }; /* MANREF last */
+struct { enum tagtype type; int first; int last; } tags[MAXTAGS];
+int tagc=0;
+struct { char *text; int type; int line; } toc[MAXTOC];
+int tocc=0;
+
+
+/* characters in this list automatically prefixed by a backslash (set in output format function */
+char *escchars="";
+char *vollist = VOLLIST;
+const char *manvalid = "._-+:"; /* in addition to alphanumerics, valid characters to find in a man page name */
+char *manrefname;
+char *manrefsect;
+
+enum command {
+
+ /*BEGINCHARTAGS,*/
+ CHARTAB='\t',
+ CHARPERIOD='.', CHARLSQUOTE='`', CHARRSQUOTE='\'', CHARGT='>', CHARLT='<',
+ CHARAMP='&', CHARBACKSLASH='\\', CHARDASH='-', CHARHAT='^', CHARVBAR='|',
+ CHARNBSP=0xa0, CHARCENT=0xa2, CHARSECT=0xa7, CHARCOPYR=0xa9, CHARNOT=0xac,
+ CHARDAGGER=0xad, CHARREGTM=0xae, CHARDEG=0xb0, CHARPLUSMINUS=0xb1,
+ CHARACUTE=0xb4, CHARBULLET=0xb7, CHAR14=0xbc, CHAR12=0xbd, CHAR34=0xbe,
+ CHARMUL=0xd7, CHARDIV=0xf7,
+ CHANGEBAR=0x100, CHARLQUOTE, CHARRQUOTE, HR,
+ /*ENDCHARTAGS,*/
+
+ /*BEGINFONTTAGS,*/
+ BEGINBOLD, ENDBOLD, BEGINITALICS, ENDITALICS, BEGINBOLDITALICS, ENDBOLDITALICS,
+ BEGINSC, ENDSC, BEGINY, ENDY, BEGINCODE, ENDCODE, BEGINMANREF, ENDMANREF,
+ FONTSIZE,
+ /*ENDFONTTAGS*/
+
+ /*BEGINLAYOUTTAGS,*/
+ ITAB, BEGINCENTER, ENDCENTER,
+ /*ENDLAYOUTTAGS,*/
+
+ /*BEGINSTRUCTTAGS,*/
+ BEGINDOC, ENDDOC, BEGINCOMMENT, ENDCOMMENT, COMMENTLINE, BEGINBODY, ENDBODY,
+ BEGINHEADER, ENDHEADER, BEGINFOOTER, ENDFOOTER, BEGINLINE, ENDLINE, SHORTLINE,
+ BEGINSECTION, ENDSECTION, BEGINSUBSECTION, ENDSUBSECTION,
+ BEGINSECTHEAD, ENDSECTHEAD, BEGINSUBSECTHEAD, ENDSUBSECTHEAD,
+ BEGINBULPAIR, ENDBULPAIR, BEGINBULLET, ENDBULLET, BEGINBULTXT, ENDBULTXT,
+ BEGINTABLE, ENDTABLE, BEGINTABLELINE, ENDTABLELINE, BEGINTABLEENTRY, ENDTABLEENTRY,
+ BEGININDENT, ENDINDENT, BEGINCODEBLOCK, ENDCODEBLOCK,
+
+ BEGINDIFFA, ENDDIFFA, BEGINDIFFD, ENDDIFFD
+ /*,*//*ENDSTRUCTTAGS,*/
+};
+
+const char *tcltkOP[] = { "Command-Line Name", "Database Name", "Database Class" };
+
+
+/* characters that need special handling in any output format, *more than just a backslash* */
+/* characters in this list need a corresponding case statement in each output format */
+/*char *trouble="\t.`'><&\\^|-\xa7\xb7\xb1";*/
+const unsigned char trouble[]= { CHARTAB, CHARPERIOD, CHARLSQUOTE, CHARRSQUOTE,
+ CHARGT, CHARLT, CHARAMP, CHARBACKSLASH, CHARDASH, CHARHAT, CHARVBAR, CHARCENT,
+ CHARSECT, CHARCOPYR, CHARNOT, CHARDAGGER, CHARREGTM, CHARDEG, CHARPLUSMINUS,
+ CHARACUTE, CHARBULLET, CHAR14, CHAR12, CHAR34, CHARMUL, CHARDIV,
+ 0 };
+
+
+enum command tagbeginend[][2] = { /* parallel to enum tagtype */
+ { -1,-1 },
+ { -1,-1 },
+ { BEGINITALICS, ENDITALICS },
+ { BEGINBOLD, ENDBOLD },
+ { BEGINY, ENDY },
+ { BEGINSC, ENDSC },
+ { BEGINBOLDITALICS, ENDBOLDITALICS },
+ { -1,-1 },
+ { BEGINMANREF, ENDMANREF }
+};
+
+void (*fn)(enum command) = NULL;
+enum command prevcmd = BEGINDOC;
+
+
+/*** globals ***/
+/* move all flags into an array?
+enum { fSubsX, fLast };
+int flags[fLast];
+*/
+
+int fSource=-1; /* -1 => not determined yet */
+int fDiff=0;
+FILE *difffd;
+char diffline[MAXBUF];
+char diffline2[MAXBUF];
+char *message = NULL;
+int fontdelta=0;
+int intArg;
+
+int fPara=0; /* line or paragraph groupings of text */
+int fSubsections=0; /* extract subsection titles too? */
+int fChangeleft=0; /* move change bars to left? (-1 => delete them) */
+int fReflow=0;
+int fURL=0; /* scan for URLs too? */
+#if 0
+int fMan=1; /* invoke agressive man page filtering? */
+#endif
+int fQS=0; /* squeeze out spaces (scnt and interword)? */
+int fIQS=0; /* squeeze out initial spaces (controlled separately from fQS) */
+int fILQS=0; /* squeeze out spaces for usual indent */
+int fHeadfoot=0; /* show canonical header and footer at bottom? */
+int falluc=0;
+int itabcnt=0;
+int fQuiet=0;
+int fTclTk=0;
+
+/* patterns observed in section heads that don't conform to first-letter-uppercase-rest-lowercase pattern (stay all uc, or go all lc, or have subsequent uc) */
+int lcexceptionslen = -1; /* computed by system */
+char *lcexceptions[] = {
+/* new rule: double/all consonants == UC? */
+ /* articles, verbs, conjunctions, prepositions, pronouns */
+ "a", "an", "the",
+ "am", "are", "is", "were",
+ "and", "or",
+ "by", "for", "from", "in", "into", "it", "of", "on", "to", "with",
+ "that", "this",
+
+ /* terms */
+ "API", "CD", "GUI", "UI", /*I/O=>I/O already*/ "ID", "IDs", "OO",
+ "IOCTLS", "IPC", "RPC",
+
+ /* system names */
+ "AWK", "cvs", "rcs", "GL", "vi", "PGP", "QuickTime", "DDD", "XPG/3",
+ "NFS", "NIS", "NIS+", "AFS",
+ "UNIX", "SysV",
+ "XFree86", "ICCCM",
+ "MH", "MIME",
+ "TeX", "LaTeX", "PicTeX",
+ "PostScript", "EPS", "EPSF", "EPSI",
+ "HTML", "URL", "WWW",
+
+ /* institution names */
+ "ANSI", "CERN", "GNU", "ISO", "NCSA",
+
+ /* Sun-specific */
+ "MT-Level", "SPARC",
+
+ NULL
+};
+/* what exceptions have you encountered? */
+
+int TabStops=8;
+int hanging=0; /* location of hanging indent (if ==0, none) */
+enum { NAME, SYNOPSIS, DESCRIPTION, SEEALSO, FILES, AUTHOR, RANDOM }; /* RANDOM last */
+char *sectheadname[] = {
+ "NAME", "SYNOPSIS", "DESCRIPTION:INTRODUCTION", "SEE ALSO:RELATED INFORMATION", "FILES", "AUTHOR:AUTHORS", "RANDOM"
+};
+int sectheadid = RANDOM;
+int oldsectheadid = RANDOM;
+
+int fCodeline=0;
+int fNOHY=0; /* re-linebreak so no words are hyphenated; not used by TkMan, but gotta keep for people converting formatted text */
+int fNORM=0; /* normalize? initial space => tabs, no changebars, exactly one blank line between sections */
+const char TABLEOFCONTENTS[] = "Table of Contents";
+const char HEADERANDFOOTER[] = "Header and Footer";
+char manName[80]="man page";
+char manSect[10]="1";
+const char provenance[] =
+ "manual page source format generated by PolyglotMan v" POLYGLOTMANVERSION;
+const char anonftp[] =
+ "available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z";
+const char horizontalrule[] = "------------------------------------------------------------";
+
+const int LINEBREAK=70;
+int linelen=0; /* length of result in plain[] */
+int spcsqz; /* number of spaces squeezed out */
+int ccnt=0; /* # of changebars */
+int scnt,scnt2; /* counts of initial spaces in line */
+int s_sum,s_cnt;
+int bs_sum, bs_cnt;
+int ncnt=0,oncnt=0; /* count of interline newlines */
+int CurLine=1;
+int AbsLine=1-1; /* absolute line number */
+int indent=0; /* global indentation */
+int lindent=0; /* usual local indent */
+int auxindent=0; /* aux indent */
+int I; /* index into line/paragraph */
+int fcharout=1; /* show text or not */
+char lookahead;
+/*int tabgram[MAXBUF];*/ /* histogram of first character positions */
+char buf[MAXBUF];
+char plain[MAXBUF]; /* current text line with control characters stripped out */
+char hitxt[MAXBUF]; /* highlighted text (available at time of BEGIN<highlight> signal */
+char header[MAXBUF]/*=""*/; /* complete line */
+char header2[MAXBUF]/*=""*/; /* SGIs have two lines of headers and footers */
+char header3[MAXBUF]/*=""*/; /* GNU and some others have a third! */
+char footer[MAXBUF]/*=""*/;
+char footer2[MAXBUF]/*=""*/;
+#define CRUFTS 5
+char *cruft[CRUFTS] = { header, header2, header3, footer, footer2 };
+char *File, *in; /* File = pointer to full file contents, in = current file pointer */
+char *argv0;
+int finTable=0;
+char tableSep='\0'; /*\t';*/
+/*int fTable=0;
+int fotable=0;*/
+char *tblcellformat;
+int tblcellspan;
+/*int tblspanmax;*/
+int listtype=-1; /* current list type bogus to begin with */
+enum listtypes { DL, OL, UL };
+
+int fIP=0;
+
+
+
+/*** utility functions ***/
+
+
+/* case insensitive versions of strcmp and strncmp */
+
+static int
+stricmp(const char *s1, const char *s2)
+{
+ assert(s1!=NULL && s2!=NULL);
+ /*strincmp(s1, s2, strlen(s1)+1);*/
+
+ while (tolower(*s1)==tolower(*s2)) {
+ if (*s1=='\0' /*&& *s2=='\0'*/) return 0;
+ s1++; s2++;
+ }
+
+ if (tolower(*s1)<tolower(*s2)) return -1;
+ else return 1;
+}
+
+static int
+lcexceptionscmp(const void *a, const void *b)
+{
+ return stricmp(*(char **)a, *(char **)b);
+}
+
+static int
+strincmp(const char *s1, const char *s2, size_t n)
+{
+ assert(s1!=NULL && s2!=NULL && n>0);
+
+ while (n>0 && tolower(*s1)==tolower(*s2)) {
+ n--; s1++; s2++;
+ }
+ if (n==0) return 0;
+ else if (tolower(*s1)<tolower(*s2)) return -1;
+ else return 1;
+}
+
+/* compare string and a colon-separated list of strings */
+static int
+strcoloncmp2(char *candidate, int end, const char *list, int sen)
+{
+ const char *l = list;
+ char *c,c2;
+
+ assert(candidate!=NULL && list!=NULL);
+ assert(end>=-1 && end<=255);
+ assert(sen==0 || sen==1);
+
+ if (*l==':') l++; /* tolerate a leading colon */
+
+ /* invariant: c and v point to start of strings to compare */
+ while (*l) {
+ assert(l==list || l[-1]==':');
+ for (c=candidate; *c && *l; c++,l++)
+ if ((sen && *c!=*l) || (!sen && tolower(*c)!=tolower(*l)))
+ break;
+
+ /* if candidate matches a valid one as far as valid goes, it's a keeper */
+ if ((*l=='\0' || *l==':') && (*c==end || end==-1)) {
+ if (*c=='\b') {
+ c2 = c[-1];
+ while (*c=='\b' && c[1]==c2) c+=2;
+ }
+ /* no volume qualifiers with digits */
+ if (!isdigit(*c)) return 1;
+ }
+
+ /* bump to start of next valid */
+ while (*l && *l++!=':') /* nada */;
+ }
+
+ return 0;
+}
+
+static int
+strcoloncmp(char *candidate, int end, const char *list)
+{
+ int sen=1;
+ const char *l = list;
+
+ assert(candidate!=NULL && list!=NULL);
+ assert(end>=-1 && end<=255);
+
+ if (*l=='=') l++; else end=-1;
+ if (*l=='i') { sen=0; l++; }
+
+ return strcoloncmp2(candidate, end, l, sen);
+}
+
+/* strdup not universally available */
+static char *
+mystrdup(const char *p)
+{
+ char *q;
+
+ if (p==NULL) return NULL;
+
+ q = malloc(strlen(p)+1); /* +1 gives space for \0 that is not reported by strlen */
+ if (q!=NULL) strcpy(q,p);
+ return q;
+}
+
+
+/* given line of text, return "casified" version in place:
+ if word in exceptions list, return exception conversion
+ else uc first letter, lc rest
+*/
+static void
+casify(char *p)
+{
+ char tmpch, *q, **exp;
+ int fuc;
+
+ for (fuc=1; *p; p++) {
+ if (isspace(*p) || strchr("&/",*p)!=NULL) fuc=1;
+ else if (fuc) {
+ /* usually */
+ if (p[1] && isupper(p[1]) /*&& p[2] && isupper(p[2])*/) fuc=0;
+ /* check for exceptions */
+ for (q=p; *q && !isspace(*q); q++) /*nada*/;
+ tmpch = *q; *q='\0';
+ exp = (char **)bsearch(&p, lcexceptions, lcexceptionslen, sizeof(char *), lcexceptionscmp);
+ *q = tmpch;
+ if (exp!=NULL) {
+ for (q=*exp; *q; q++) *p++=*q;
+ fuc = 1;
+ }
+ } else *p=tolower(*p);
+ }
+}
+
+
+/* add an attribute tag to a range of characters */
+
+static void
+tagadd(int /*enum tagtype--abused in source parsing*/ type, int first, int last)
+{
+ assert(type!=NOTAG);
+
+ if (tagc<MAXTAGS) {
+ tags[tagc].type = type;
+ tags[tagc].first = first;
+ tags[tagc].last = last;
+ tagc++;
+ }
+}
+
+
+/*
+ collect all saves to string table one one place, so that
+ if decide to go with string table instead of multiple malloc, it's easy
+ (probably few enough malloc's that more sophistication is unnecessary)
+*/
+
+static void
+tocadd(char *text, enum command type, int line)
+{
+ char *r;
+
+ assert(text!=NULL && strlen(text)>0);
+ assert(type==BEGINSECTION || type==BEGINSUBSECTION);
+
+ if (tocc<MAXTOC) {
+ r = malloc(strlen(text)+1); if (r==NULL) return;
+ strcpy(r,text);
+ toc[tocc].text = r;
+ toc[tocc].type = type;
+ toc[tocc].line = line;
+ tocc++;
+ }
+}
+
+
+
+char *manTitle = MANTITLEPRINTF;
+char *manRef = MANREFPRINTF;
+char *href;
+int fmanRef=1; /* make 'em links or just show 'em? */
+
+static void
+manrefextract(char *p)
+{
+ char *p0;
+ static char *nonhref = "\">'";
+
+ while (*p==' ') p++;
+ if (strincmp(p,"http",4)==0) {
+ href="%s"; manrefname = p;
+ p+=4;
+ while (*p && !isspace(*p) && !strchr(nonhref,*p)) p++;
+ } else {
+ href = manRef;
+
+ manrefname = p;
+ while (*p && *p!=' ' && *p!='(') p++; *p++='\0';
+ while (*p==' ' || *p=='(') p++; p0=p;
+#ifdef XFree86
+ /* Don't allow a letter after the man section number */
+ p++;
+#else
+ while (*p && *p!=')') p++;
+#endif
+ manrefsect = p0;
+ }
+ *p='\0';
+}
+
+
+
+
+/*
+ * OUTPUT FORMATS
+ * *** break these out so can selectively include them in the binary ***
+ * *** does this save significant space? ***
+ */
+
+static void
+formattedonly(void)
+{
+ fprintf(stderr, "The output formats for Tk and TkMan require nroff-formatted input\n");
+ exit(1);
+}
+
+
+/*
+ * DefaultFormat -- in weak OO inheritance, top of hierarchy for everybody
+ */
+static void
+DefaultFormat(enum command cmd)
+{
+ int i;
+
+ switch (cmd) {
+ case ITAB:
+ for (i=0; i<itabcnt; i++) putchar('\t');
+ break;
+ default:
+ /* nada */
+ break;
+ }
+}
+
+
+/*
+ * DefaultLine -- in weak OO inheritance, top of hierarchy for line-based formats
+ * for output format to "inherit", have "default: DefaultLine(cmd)" and override case statement "methods"
+ */
+
+static void
+DefaultLine(enum command cmd) {
+ switch (cmd) {
+ default:
+ DefaultFormat(cmd);
+ }
+}
+
+
+/*
+ * DefaultPara -- top of hierarchy for output formats that are formatted by their viewers
+ */
+
+static void
+DefaultPara(enum command cmd)
+{
+ switch (cmd) {
+ default:
+ DefaultFormat(cmd);
+ }
+}
+
+
+
+/*
+ * Tk -- just emit list of text-tags pairs
+ */
+
+static void
+Tk(enum command cmd)
+{
+ static int skip=0; /* skip==1 when line has no text */
+ int i;
+
+ if (fSource) formattedonly();
+
+ /* invariant: always ready to insert text */
+
+ switch (cmd) {
+ case BEGINDOC:
+ I=0; CurLine=1;
+ escchars = "\"[]$";
+ printf(/*$t insert end */ "\"");
+ break;
+ case ENDDOC:
+ if (fHeadfoot) {
+/* grr, should have +mark syntax for Tk text widget! -- maybe just just +sect#, +subsect#
+ printf("\\n\\n\" {} \"%s\\n\" {+headfoot h2}\n",HEADERANDFOOTER);
+*/
+ printf("\\n\\n\" {} \"%s\\n\" h2\n",HEADERANDFOOTER);
+ /*printf("$t mark set headfoot %d.0\n",CurLine);*/
+ CurLine++;
+
+ for (i=0; i<CRUFTS; i++) {
+ if (*cruft[i]) {
+ printf(/*$t insert end */"{%s} sc \\n\n",cruft[i]);
+ CurLine++;
+ }
+ }
+ } else printf("\"\n");
+ break;
+
+ case COMMENTLINE: printf("# "); break;
+
+ case BEGINLINE:
+ /*I=0; -- need to do this at end of line so set for filterline() */
+ /* nothing to do at start of line except catch up on newlines */
+ for (i=0; i<ncnt; i++) printf("\\n");
+ CurLine+=ncnt;
+ /*if (fSource) for (i=0; i<indent; i++) putchar('\t');*/
+ break;
+ case ENDLINE:
+ /*if (!fSource) {*/
+ if (!skip) /*if (ncnt)*/ printf("\\n"); /*else xputchar(' ');*/
+ skip=0;
+ CurLine++; I=0;
+ /*
+ } else {
+ putchar(' '); I++;
+ }
+ */
+ break;
+
+ case ENDSECTHEAD:
+ printf("\\n\" h2 \"");
+ tagc=0;
+ skip=1;
+ break;
+ case ENDSUBSECTHEAD:
+ printf("\\n\" h3 \""); /* add h3? */
+ tagc=0;
+ skip=1;
+ break;
+ case HR: /*printf("\\n%s\\n", horizontalrule); CurLine+=2; I=0;*/ break;
+ case BEGINTABLEENTRY:
+ /*if (fSource) putchar('\t');*/
+ break;
+ case BEGINTABLELINE:
+ case ENDTABLEENTRY:
+ break;
+ case ENDTABLELINE:
+ printf("\" tt \"");
+ /*tagadd(MONO, 0, I);*/
+ break;
+
+ case CHANGEBAR: putchar('|'); I++; break;
+ case CHARLQUOTE:
+ case CHARRQUOTE:
+ putchar('\\'); putchar('"'); I++;
+ break;
+ case CHARLSQUOTE:
+ case CHARRSQUOTE:
+ case CHARPERIOD:
+ case CHARTAB:
+ case CHARDASH:
+ case CHARLT:
+ case CHARGT:
+ case CHARHAT:
+ case CHARVBAR:
+ case CHARAMP:
+ case CHARPLUSMINUS:
+ case CHARNBSP:
+ case CHARCENT:
+ case CHARSECT:
+ case CHARCOPYR:
+ case CHARNOT:
+ case CHARREGTM:
+ case CHARDEG:
+ case CHARACUTE:
+ case CHAR14:
+ case CHAR12:
+ case CHAR34:
+ case CHARMUL:
+ case CHARDIV:
+ putchar(cmd); I++; break;
+ case CHARDAGGER:
+ putchar('+'); I++; break;
+ case CHARBACKSLASH: printf("\\\\"); I++; break;
+ case CHARBULLET: printf("\" {} %c symbol \"",c_bullet); I++; break;
+
+
+ case BEGINSECTHEAD:
+ case BEGINSUBSECTHEAD:
+ /*if (fSource && sectheadid!=NAME) { printf("\\n\\n"); CurLine+=2; I=0; }*/
+ tagc=0; /* section and subsection formatting controlled descriptively */
+ /* no break;*/
+
+ case BEGINBOLD:
+ case BEGINITALICS:
+ case BEGINBOLDITALICS:
+ case BEGINCODE:
+ case BEGINY:
+ case BEGINSC:
+ case BEGINMANREF:
+ /* end text, begin attributed text */
+ printf("\" {} \"");
+ break;
+
+ /* rely on the fact that no more than one tag per range of text */
+ case ENDBOLD: printf("\" b \""); break;
+ case ENDITALICS: printf("\" i \""); break;
+ case ENDBOLDITALICS: printf("\" bi \""); break;
+ case ENDCODE: printf("\" tt \""); break;
+ case ENDY: printf("\" symbol \""); break;
+ case ENDSC: printf("\" sc \""); break;
+ case ENDMANREF: printf("\" manref \""); break;
+ /* presentation attributes dealt with at end of line */
+
+ case BEGINBODY:
+ /*if (fSource) { printf("\\n\\n"); CurLine+=2; I=0; }*/
+ break;
+ case SHORTLINE:
+ /*if (fSource) { printf("\\n"); CurLine++; I=0; }*/
+ break;
+ case ENDBODY:
+ case BEGINBULPAIR: case ENDBULPAIR:
+ /*if (fSource) { printf("\\n"); CurLine++; I=0; }*/
+ break;
+ case BEGINBULTXT:
+ /*if (fSource) putchar('\t');*/
+ break;
+ case BEGINBULLET: case ENDBULLET:
+ case ENDBULTXT:
+ case BEGINSECTION: case ENDSECTION:
+ case BEGINSUBSECTION: case ENDSUBSECTION:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case BEGINTABLE: case ENDTABLE:
+ case FONTSIZE:
+ case BEGININDENT: case ENDINDENT:
+ /* no action */
+ break;
+ default:
+ DefaultLine(cmd);
+ }
+}
+
+
+/*
+ * TkMan -- Tk format wrapped with commands
+ */
+
+int linetabcnt[MAXLINES]; /* don't want to bother with realloc */
+int clocnt=0, clo[MAXLINES];
+int paracnt=0, para[MAXLINES];
+int rebuscnt=0, rebus[MAXLINES];
+int rebuspatcnt=0, rebuspatlen[25];
+char *rebuspat[25];
+
+static void
+TkMan(enum command cmd)
+{
+ static int lastscnt=-1;
+ static int lastlinelen=-1;
+ static int lastsect=0;
+ /*static int coalese=0;*/
+ static int finflow=0;
+ int i;
+ char c,*p;
+
+ /* invariant: always ready to insert text */
+
+ switch (cmd) {
+ case BEGINDOC:
+ printf("$t insert end "); /* opening quote supplied in Tk() below */
+ Tk(cmd);
+ break;
+ case ENDDOC:
+ Tk(ENDLINE);
+
+ if (fHeadfoot) {
+/* grr, should have +mark syntax for Tk text widget!
+ printf("\\n\\n\" {} \"%s\\n\" {+headfoot h2}\n", HEADERANDFOOTER);
+*/
+ printf("\\n\\n\" {} \"%s\\n\" h2\n", HEADERANDFOOTER);
+/* printf("$t mark set headfoot end-2l\n");*/
+ CurLine++;
+
+ for (i=0; i<CRUFTS; i++) {
+ if (*cruft[i]) {
+ printf("$t insert end {%s} sc \\n\n",cruft[i]);
+ CurLine++;
+ }
+ }
+ } else printf("\"\n");
+
+/*
+ printf("$t insert 1.0 {");
+ for (i=0; i<MAXBUF; i++) if (tabgram[i]) printf("%d=%d, ", i, tabgram[i]);
+ printf("\\n\\n}\n");
+*/
+
+ printf("set manx(tabcnts) {"); for (i=1; i<CurLine; i++) printf("%d ", linetabcnt[i]); printf("}\n");
+ printf("set manx(clo) {"); for (i=0; i<clocnt; i++) printf("%d ", clo[i]); printf("}\n");
+ printf("set manx(para) {"); for (i=0; i<paracnt; i++) printf("%d ", para[i]); printf("}\n");
+ printf("set manx(reb) {"); for (i=0; i<rebuscnt; i++) printf("%d ", rebus[i]); printf("}\n");
+
+ break;
+
+ case BEGINCOMMENT: fcharout=0; break;
+ case ENDCOMMENT: fcharout=1; break;
+ case COMMENTLINE: break;
+
+ case ENDSECTHEAD:
+ case ENDSUBSECTHEAD:
+ lastsect=1;
+ Tk(cmd);
+ break;
+
+ case BEGINLINE:
+ Tk(cmd);
+ linetabcnt[CurLine] = itabcnt;
+ /* old pattern for command line options "^\\|*\[ \t\]+-\[^-\].*\[^ \t\]" */
+ c = plain[0];
+ if (linelen>=2 && ((c=='-' || c=='%' || c=='\\' || c=='$' /**/ /* not much talk of money in man pages so reasonable */) && (isalnum(plain[1]) /*<= plain[1]!='-'*//*no dash*/ || ncnt/*GNU long option*/) && plain[1]!=' ') ) clo[clocnt++] = CurLine;
+ /*
+ would like to require second letter to be a capital letter to cut down on number of matches,
+ but command names usually start with lowercase letter
+ maybe use a uppercase requirement as secondary strategy, but probably not
+ */
+ if ((ncnt || lastsect) && linelen>0 && scnt>0 && scnt<=5) para[paracnt++] = CurLine;
+ lastsect=0;
+
+
+ /* rebus too, instead of search through whole Tk widget */
+ if (rebuspatcnt && scnt>=5 /* not sect or subsect heads */) {
+ for (p=plain; *p && *p!=' '; p++) /*empty*/; /* never first word */
+ while (*p) {
+ for (i=0; i<rebuspatcnt; i++) {
+ if (tolower(*p) == tolower(*rebuspat[i]) && strincmp(p, rebuspat[i], rebuspatlen[i])==0) {
+ /* don't interfere with man page refs */
+ for (; *p && !isspace(*p); p++) if (*p=='(') continue;
+ rebus[rebuscnt++] = CurLine;
+ p=""; /* break for outer */
+ break; /* just locating any line with any rebus, not exact positions */
+ }
+ }
+ /* just check start of words, though doesn't have to be full word (if did, could use strlen rather than strnlen) */
+ while (*p && *p!=' ') p++;
+ while (*p && *p==' ') p++;
+ }
+ }
+
+
+ if (fReflow && !ncnt && (finflow || lastlinelen>50) && (abs(scnt-lastscnt)<=1 || abs(scnt-hanging)<=1)) {
+ finflow=1;
+ putchar(' ');
+ } else {
+ Tk(ENDLINE);
+ /*if ((CurLine&0x3f)==0x3f) printf("\"\nupdate idletasks\n$t insert end \""); blows up some Tk text buffer, apparently, on long lines*/
+ if ((CurLine&0x1f)==0x1f) printf("\"\nupdate idletasks\n$t insert end \"");
+ finflow=0;
+
+ /*if (fCodeline) printf("CODE");*/
+ }
+ lastlinelen=linelen; lastscnt=scnt;
+ break;
+
+ case ENDLINE:
+ /* don't call Tk(ENDLINE) */
+ break;
+
+ default: /* if not caught above, it's the same as Tk */
+ Tk(cmd);
+ }
+}
+
+
+
+
+/*
+ * ASCII
+ */
+
+static void
+ASCII(enum command cmd)
+{
+ int i;
+
+ switch (cmd) {
+ case ENDDOC:
+ if (fHeadfoot) {
+ printf("\n%s\n", HEADERANDFOOTER);
+ for (i=0; i<CRUFTS; i++) if (*cruft[i]) printf("%s\n",cruft[i]);
+ }
+ break;
+ case CHARRQUOTE:
+ case CHARLQUOTE:
+ putchar('"');
+ break;
+ case CHARLSQUOTE:
+ putchar('`');
+ break;
+ case CHARRSQUOTE:
+ case CHARACUTE:
+ putchar('\'');
+ break;
+ case CHARPERIOD:
+ case CHARTAB:
+ case CHARDASH:
+ case CHARLT:
+ case CHARAMP:
+ case CHARBACKSLASH:
+ case CHARGT:
+ case CHARHAT:
+ case CHARVBAR:
+ case CHARNBSP:
+ putchar(cmd); break;
+ case CHARDAGGER: putchar('+'); break;
+ case CHARBULLET: putchar('*'); break;
+ case CHARPLUSMINUS: printf("+-"); break;
+ case CHANGEBAR: putchar('|'); break;
+ case CHARCENT: putchar('c'); break;
+ case CHARSECT: putchar('S'); break;
+ case CHARCOPYR: printf("(C)"); break;
+ case CHARNOT: putchar('~'); break;
+ case CHARREGTM: printf("(R)"); break;
+ case CHARDEG: putchar('o'); break;
+ case CHAR14: printf("1/4"); break;
+ case CHAR12: printf("1/2"); break;
+ case CHAR34: printf("3/4"); break;
+ case CHARMUL: putchar('X'); break;
+ case CHARDIV: putchar('/'); break;
+ case HR: printf("\n%s\n", horizontalrule); break;
+
+ case BEGINLINE:
+ for (i=0; i<ncnt; i++) putchar('\n');
+ break;
+ case BEGINBODY:
+ case SHORTLINE:
+ if (!fSource) break;
+ case ENDLINE:
+ putchar('\n');
+ CurLine++;
+ break;
+
+ case BEGINDOC:
+ case ENDBODY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case BEGINSECTION: case ENDSECTION:
+ case BEGINSECTHEAD: case ENDSECTHEAD:
+ case BEGINSUBSECTHEAD: case ENDSUBSECTHEAD:
+ case BEGINBULPAIR: case ENDBULPAIR:
+ case BEGINBULLET: case ENDBULLET:
+ case BEGINBULTXT: case ENDBULTXT:
+ case BEGINSUBSECTION: case ENDSUBSECTION:
+
+ case BEGINTABLE: case ENDTABLE:
+ case BEGINTABLELINE: case ENDTABLELINE: case BEGINTABLEENTRY: case ENDTABLEENTRY:
+ case BEGININDENT: case ENDINDENT:
+ case FONTSIZE:
+ case BEGINBOLD: case ENDBOLD:
+ case BEGINCODE: case ENDCODE:
+ case BEGINITALICS: case ENDITALICS:
+ case BEGINMANREF: case ENDMANREF:
+ case BEGINBOLDITALICS: case ENDBOLDITALICS:
+ case BEGINY: case ENDY:
+ case BEGINSC: case ENDSC:
+ /* nothing */
+ break;
+ default:
+ DefaultLine(cmd);
+ }
+}
+
+
+
+/*
+ * Perl 5 pod ("plain old documentation")
+ */
+
+static void
+pod(enum command cmd)
+{
+ static int curindent=0;
+ int i;
+
+ if (hanging==-1) {
+ if (curindent) hanging=curindent; else hanging=5;
+ }
+
+
+ if (cmd==BEGINBULPAIR) {
+ /* want to have multiply indented text */
+ if (curindent && hanging!=curindent) printf("\n=back\n\n");
+ if (hanging!=curindent) printf("\n=over %d\n\n",hanging);
+ curindent=hanging;
+ } else if (cmd==ENDBULPAIR) {
+ /* nothing--wait until next command */
+ } else if (cmd==BEGINLINE && !scnt) {
+ if (curindent) printf("\n=back\n\n");
+ curindent=0;
+ } else if (cmd==BEGINBODY) {
+ if (curindent) {
+ printf("\n=back\n\n");
+ curindent=0;
+ auxindent=0;
+ }
+ }
+/*
+ case BEGINBULPAIR:
+ printf("=over %d\n\n", hanging);
+ break;
+ case ENDBULPAIR:
+ printf("\n=back\n\n");
+ break;
+*/
+ switch (cmd) {
+ case BEGINDOC: I=0; break;
+
+ case BEGINCOMMENT: fcharout=0; break;
+ case ENDCOMMENT: fcharout=1; break;
+ case COMMENTLINE: break;
+
+ case CHARRQUOTE:
+ case CHARLQUOTE:
+ putchar('"');
+ break;
+ case CHARLSQUOTE:
+ putchar('`');
+ break;
+ case CHARRSQUOTE:
+ case CHARACUTE:
+ putchar('\'');
+ break;
+ case CHARPERIOD:
+ case CHARTAB:
+ case CHARDASH:
+ case CHARLT:
+ case CHARAMP:
+ case CHARBACKSLASH:
+ case CHARGT:
+ case CHARHAT:
+ case CHARVBAR:
+ case CHARNBSP:
+ putchar(cmd); break;
+ case CHARDAGGER: putchar('+'); break;
+ case CHARPLUSMINUS: printf("+-"); break;
+ case CHANGEBAR: putchar('|'); break;
+ case CHARCENT: putchar('c'); break;
+ case CHARSECT: putchar('S'); break;
+ case CHARCOPYR: printf("(C)"); break;
+ case CHARNOT: putchar('~'); break;
+ case CHARREGTM: printf("(R)"); break;
+ case CHARDEG: putchar('o'); break;
+ case CHAR14: printf("1/4"); break;
+ case CHAR12: printf("1/2"); break;
+ case CHAR34: printf("3/4"); break;
+ case CHARMUL: putchar('X'); break;
+ case CHARDIV: putchar('/'); break;
+ case HR: printf("\n%s\n", horizontalrule); break;
+ case CHARBULLET: putchar('*'); break;
+
+ case BEGINLINE:
+ for (i=0; i<ncnt; i++) putchar('\n');
+ CurLine+=ncnt;
+ break;
+ case ENDLINE:
+ putchar('\n');
+ CurLine++;
+ I=0;
+ break;
+
+ case BEGINSECTHEAD: printf("=head1 "); break;
+ case BEGINSUBSECTHEAD: printf("=head2 "); break;
+
+ case ENDSECTHEAD:
+ case ENDSUBSECTHEAD:
+ printf("\n");
+ break;
+
+ case BEGINCODE:
+ case BEGINBOLD: printf("B<"); break;
+ case BEGINITALICS: printf("I<"); break;
+ case BEGINMANREF: printf("L<"); break;
+
+ case ENDBOLD:
+ case ENDCODE:
+ case ENDITALICS:
+ case ENDMANREF:
+ printf(">");
+ break;
+
+ case BEGINBULLET:
+ printf("\n=item ");
+ break;
+ case ENDBULLET:
+ printf("\n\n");
+ fcharout=0;
+ break;
+ case BEGINBULTXT:
+ fcharout=1;
+ auxindent=hanging;
+ break;
+ case ENDBULTXT:
+ auxindent=0;
+ break;
+
+
+ case ENDDOC:
+ case BEGINBODY: case ENDBODY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case BEGINSECTION: case ENDSECTION:
+ case BEGINSUBSECTION: case ENDSUBSECTION:
+ case BEGINBULPAIR: case ENDBULPAIR:
+
+ case SHORTLINE:
+ case BEGINTABLE: case ENDTABLE:
+ case BEGINTABLELINE: case ENDTABLELINE: case BEGINTABLEENTRY: case ENDTABLEENTRY:
+ case BEGININDENT: case ENDINDENT:
+ case FONTSIZE:
+ case BEGINBOLDITALICS: case ENDBOLDITALICS:
+ case BEGINY: case ENDY:
+ case BEGINSC: case ENDSC:
+ /* nothing */
+ break;
+ default:
+ DefaultLine(cmd);
+ }
+}
+
+
+
+static void
+Sections(enum command cmd)
+{
+
+ switch (cmd) {
+ case ENDSECTHEAD:
+ case ENDSUBSECTHEAD:
+ putchar('\n');
+ case BEGINDOC:
+ fcharout=0;
+ break;
+
+ case BEGINCOMMENT: fcharout=0; break;
+ case ENDCOMMENT: fcharout=1; break;
+ case COMMENTLINE: break;
+
+ case BEGINSUBSECTHEAD:
+ printf(" ");
+ /* no break */
+ case BEGINSECTHEAD:
+ fcharout=1;
+ break;
+ case CHARRQUOTE:
+ case CHARLQUOTE:
+ xputchar('"');
+ break;
+ case CHARLSQUOTE:
+ xputchar('`');
+ break;
+ case CHARRSQUOTE:
+ case CHARACUTE:
+ xputchar('\'');
+ break;
+ case BEGINTABLE: case ENDTABLE:
+ case BEGINTABLELINE: case ENDTABLELINE: case BEGINTABLEENTRY: case ENDTABLEENTRY:
+ case BEGININDENT: case ENDINDENT:
+ case FONTSIZE:
+ break;
+ case CHARPERIOD:
+ case CHARTAB:
+ case CHARDASH:
+ case CHARBACKSLASH:
+ case CHARLT:
+ case CHARGT:
+ case CHARHAT:
+ case CHARVBAR:
+ case CHARAMP:
+ case CHARNBSP:
+ xputchar(cmd); break;
+ case CHARDAGGER: xputchar('+'); break;
+ case CHARBULLET: xputchar('*'); break;
+ case CHARPLUSMINUS: xputchar('+'); xputchar('-'); break;
+ case CHARCENT: xputchar('c'); break;
+ case CHARSECT: xputchar('S'); break;
+ case CHARCOPYR: xputchar('('); xputchar('C'); xputchar(')'); break;
+ case CHARNOT: xputchar('~'); break;
+ case CHARREGTM: xputchar('('); xputchar('R'); xputchar(')'); break;
+ case CHARDEG: xputchar('o'); break;
+ case CHAR14: xputchar('1'); xputchar('/'); xputchar('4'); break;
+ case CHAR12: xputchar('1'); xputchar('/'); xputchar('2'); break;
+ case CHAR34: xputchar('3'); xputchar('/'); xputchar('4'); break;
+ case CHARMUL: xputchar('X'); break;
+ case CHARDIV: xputchar('/'); break;
+ case ITAB: DefaultLine(cmd); break;
+
+
+ default:
+ /* nothing */
+ break;
+ }
+}
+
+
+
+static void
+Roff(enum command cmd)
+{
+ switch (cmd) {
+ case BEGINDOC:
+ I=1;
+ printf(".TH %s %s \"generated by PolyglotMan\" UCB\n",manName,manSect);
+ printf(".\\\" %s,\n",provenance);
+ printf(".\\\" %s\n",anonftp);
+ CurLine=1;
+ break;
+ case BEGINBODY: printf(".LP\n"); break;
+
+ case BEGINCOMMENT:
+ case ENDCOMMENT:
+ break;
+ case COMMENTLINE: printf("'\\\" "); break;
+
+ case BEGINSECTHEAD: printf(".SH "); break;
+ case BEGINSUBSECTHEAD:printf(".SS "); break;
+ case BEGINBULPAIR: printf(".IP "); break;
+ case SHORTLINE: printf("\n.br"); break;
+ case BEGINBOLD: printf("\\fB"); break; /* \n.B -- grr! */
+ case ENDCODE:
+ case ENDBOLD: printf("\\fR"); break; /* putchar('\n'); */
+ case BEGINITALICS: printf("\\fI"); break;
+ case ENDITALICS: printf("\\fR"); break;
+ case BEGINCODE:
+ case BEGINBOLDITALICS:printf("\\f4"); break;
+ case ENDBOLDITALICS: printf("\\fR"); break;
+
+ case CHARLQUOTE: printf("\\*(rq"); break;
+ case CHARRQUOTE: printf("\\*(lq"); break;
+ case CHARNBSP: printf("\\|"); break;
+ case CHARLSQUOTE: putchar('`'); break;
+ case CHARRSQUOTE: putchar('\''); break;
+ case CHARPERIOD: if (I==1) printf("\\&"); putchar('.'); I++; break;
+ case CHARDASH: printf("\\-"); break;
+ case CHARTAB:
+ case CHARLT:
+ case CHARGT:
+ case CHARHAT:
+ case CHARVBAR:
+ case CHARAMP:
+ putchar(cmd); break;
+ case CHARBULLET: printf("\\(bu"); break;
+ case CHARDAGGER: printf("\\(dg"); break;
+ case CHARPLUSMINUS: printf("\\(+-"); break;
+ case CHANGEBAR: putchar('|'); break;
+ case CHARCENT: printf("\\(ct"); break;
+ case CHARSECT: printf("\\(sc"); break;
+ case CHARCOPYR: printf("\\(co"); break;
+ case CHARNOT: printf("\\(no"); break;
+ case CHARREGTM: printf("\\(rg"); break;
+ case CHARDEG: printf("\\(de"); break;
+ case CHARACUTE: printf("\\(aa"); break;
+ case CHAR14: printf("\\(14"); break;
+ case CHAR12: printf("\\(12"); break;
+ case CHAR34: printf("\\(34"); break;
+ case CHARMUL: printf("\\(mu"); break;
+ case CHARDIV: printf("\\(di"); break;
+ case HR: /*printf("\n%s\n", horizontalrule);*/ break;
+ case CHARBACKSLASH: printf("\\\\"); break; /* correct? */
+
+ case BEGINLINE:
+ /*for (i=0; i<ncnt; i++) putchar('\n');*/
+ break;
+
+ case BEGINBULLET: putchar('"'); break;
+ case ENDBULLET: printf("\"\n"); break;
+
+ case ENDLINE:
+ CurLine++;
+ I=1;
+ /* no break */
+ case ENDSUBSECTHEAD:
+ case ENDSECTHEAD:
+ case ENDDOC:
+ putchar('\n');
+ break;
+
+ case BEGINCODEBLOCK: printf(".nf\n");
+ case ENDCODEBLOCK: printf(".fi\n");
+
+ case ENDBODY:
+ case ENDBULPAIR:
+ case BEGINBULTXT: case ENDBULTXT:
+ case BEGINSECTION: case ENDSECTION:
+ case BEGINSUBSECTION: case ENDSUBSECTION:
+ case BEGINY: case ENDY:
+ case BEGINSC: case ENDSC:
+ case BEGINTABLE: case ENDTABLE:
+ case BEGINTABLELINE: case ENDTABLELINE: case BEGINTABLEENTRY: case ENDTABLEENTRY:
+ case BEGININDENT: case ENDINDENT:
+ case FONTSIZE:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case BEGINMANREF: case ENDMANREF:
+ /* nothing */
+ break;
+ default:
+ DefaultPara(cmd);
+ }
+}
+
+
+/* can't test Ensemble, probably not used, so why take up space? */
+#if 0
+
+/*
+ * Ensemble
+ */
+
+static void
+EnsembleDumpTags(void)
+{
+ int i,tag;
+ int fI=0, fB=0;
+
+ if (!tagc) return;
+
+ /* { */
+ printf("}{}{"); /* } header */
+
+ /* italics */
+ for (i=0; i<tagc; i++) {
+ tag = tags[i].type;
+ if (tag==ITALICS||tag==BOLDITALICS) {
+ if (!fI) {printf("ITALIC=("); fI=1;}
+ printf("(%d,%d,[T])", tags[i].first, tags[i].last);
+ }
+ }
+ if (fI) printf(")");
+
+ /* bold */
+ for (i=0; i<tagc; i++) {
+ tag = tags[i].type;
+ if (tag==BOLD||tag==BOLDITALICS) {
+ if (!fB) {printf(",BOLD=("); fB=1;}
+ printf("(%d,%d,[T])", tags[i].first, tags[i].last);
+ }
+ }
+ if (fB) printf(")");
+
+ /* man ref? */
+/*
+ for (i=0; i<tagc; i++) {
+ tag = tags[i].type;
+ if (tag==MANREF) {
+ if (!fH) {printf(",HYPER=("); fH=1;}
+ printf("(%d,%d,[???])", tags[i].first, tags[i].last);
+ }
+ }
+ if (fH) printf(")");
+*/
+
+ /* { */
+ /* don't put printf("}"); here as trailer -- controlling function expects to close it */
+
+ tagc=0;
+}
+
+static void
+Ensemble(enum command cmd)
+{
+
+ switch (cmd) {
+ case BEGINDOC:
+ I=0;
+ printf("DOCUMENT MANPAGE\n<MANPAGE>\n");
+ escchars = "{}\\";
+ break;
+ case ENDDOC: printf("</MANPAGE>\n"); break;
+
+ case BEGINCOMMENT: printf("\n<!--\n"); break;
+ case ENDCOMMENT: printf("\n-->\n"); break;
+ case COMMENTLINE: break;
+
+ case BEGINBODY:
+ printf("<SUBSECTIONBODY><BODY>{");
+ break;
+ case ENDBODY:
+ CurLine++;
+ EnsembleDumpTags(); printf("}</BODY></SUBSECTIONBODY>\n");
+ tagc=0;
+ break;
+ case BEGINSECTION: printf("<SECTION>"); break;
+ case ENDSECTION: printf("</SECTION>\n"); break;
+ case BEGINSECTHEAD: printf("<SECTHEAD>{"); break;
+ case ENDSECTHEAD: tagc=0; I=0; printf("}</SECTHEAD>\n"); break;
+ case BEGINSUBSECTHEAD: printf("<SUBSECTHEAD>{"); break;
+ case ENDSUBSECTHEAD: tagc=0; I=0; printf("}</SUBSECTHEAD>\n"); break;
+ case BEGINBULPAIR:
+ printf("<SUBSECTIONBODY><LISTELEMENT>");
+ break;
+ case ENDBULPAIR:
+ printf("</LISTELEMENT></SUBSECTIONBODY>\n");
+ break;
+ case BEGINBULLET: printf("<BULLET>{"); break;
+ case ENDBULLET: tagc=0; I=0; printf("}</BULLET>"); break;
+ case BEGINBULTXT: printf("<BULLETTEXT>{"); break;
+ case ENDBULTXT:
+ EnsembleDumpTags();
+ CurLine++;
+ printf("}</BULLETTEXT>");
+ break;
+ case BEGINSUBSECTION: printf("<SUBSECTIONBODY><SUBSECTION>\n"); break;
+ case ENDSUBSECTION: printf("</SUBSECTION></SUBSECTIONBODY>\n"); break;
+ case SHORTLINE: /*poppush(prevcmd);*/ break;
+
+
+ case CHARRQUOTE:
+ case CHARLQUOTE:
+ putchar('"'); I++;
+ break;
+ case CHARLSQUOTE:
+ putchar('\'');
+ break;
+ case CHARRSQUOTE:
+ putchar('\'');
+ break;
+ case CHARPERIOD:
+ case CHARTAB:
+ case CHARDASH:
+ case CHARBACKSLASH:
+ case CHARLT:
+ case CHARGT:
+ case CHARHAT:
+ case CHARVBAR:
+ case CHARAMP:
+ case CHARBULLET:
+ case CHARDAGGER:
+ case CHARPLUSMINUS:
+ case CHARNBSP:
+ case CHARCENT:
+ case CHARSECT:
+ case CHARCOPYR:
+ case CHARNOT:
+ case CHARREGTM:
+ case CHARDEG:
+ case CHARACUTE:
+ case CHAR14:
+ case CHAR12:
+ case CHAR34:
+ case CHARMUL:
+ case CHARDIV:
+ putchar(cmd); I++; break;
+
+ case ENDLINE: putchar(' '); I++; break;
+ case HR: /*printf("\n%s\n", horizontalrule);*/ break;
+ case CHANGEBAR:
+ /* maybe something later */
+ case BEGINLINE:
+ case BEGINY: case ENDY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case BEGINBOLD: case ENDBOLD:
+ case BEGINCODE: case ENDCODE:
+ case BEGINITALICS: case ENDITALICS:
+ case BEGINBOLDITALICS: case ENDBOLDITALICS:
+ case BEGINSC: case ENDSC:
+ case BEGINTABLE: case ENDTABLE:
+ case BEGINTABLELINE: case ENDTABLELINE: case BEGINTABLEENTRY: case ENDTABLEENTRY:
+ case BEGININDENT: case ENDINDENT:
+ case FONTSIZE:
+
+ case BEGINMANREF:
+ case ENDMANREF:
+ /* easy strike for hypertext--want to dynamically generate, though */
+ /* nothing */
+ break;
+ default:
+ DefaultPara(cmd);
+ }
+}
+#endif
+
+
+
+/*
+ * HTML
+ */
+
+static void
+HTML(enum command cmd)
+{
+ static int pre=0;
+ int i;
+ int lasttoc;
+
+ /* always respond to these signals */
+ switch (cmd) {
+ case CHARNBSP: printf("&nbsp;"); I++; break;
+ case CHARTAB: printf("<tt>&#32;</tt>&nbsp;<tt>&#32;</tt>&nbsp;"); break;
+ /* old browsers--who uses these?--don't understand symbolic codes */
+ /*
+ case CHARNBSP: printf("&#160;"); I++; break;
+ case CHARLQUOTE: printf("&#171;"); break;
+ case CHARRQUOTE: printf("&#187;"); break;
+ case CHARTAB: printf("<tt> </tt>&#160;<tt> </tt>&#160;"); break;
+ */
+ case CHARLQUOTE:
+ case CHARRQUOTE:
+ case CHARLSQUOTE:
+ case CHARRSQUOTE:
+ case CHARPERIOD:
+ case CHARDASH:
+ case CHARBACKSLASH:
+ case CHARVBAR: /*printf("&brvbar;"); -- broken bar no good */
+ case CHARHAT:
+ putchar(cmd); break;
+ case CHARDAGGER: printf("*"); break;
+ case CHARBULLET: printf("&#183;"/*"&middot;"*//*&sect;--middot hardly visible*/); break;
+ case CHARPLUSMINUS: printf("&#177;"/*"&plusmn;"*/); break;
+ case CHARGT: printf("&gt;"); break;
+ case CHARLT: printf("&lt;"); break;
+ case CHARAMP: printf("&amp;"); break;
+ case CHARCENT: printf("&#162;"); break; /* translate these to symbolic forms, sometime */
+ case CHARSECT: printf("&#167;"); break;
+ case CHARCOPYR: printf("&#169;"); break;
+ case CHARNOT: printf("&#172;"); break;
+ case CHARREGTM: printf("&#174;"); break;
+ case CHARDEG: printf("&#176;"); break;
+ case CHARACUTE: printf("&#180;"); break;
+ case CHAR14: printf("&#188;"); break;
+ case CHAR12: printf("&#189;"); break;
+ case CHAR34: printf("&#190;"); break;
+ case CHARMUL: printf("&#215;"); break;
+ case CHARDIV: printf("&#247;"); break;
+ default:
+ break;
+ }
+
+ /* while in pre mode... */
+ if (pre) {
+ switch (cmd) {
+ case ENDLINE: I=0; CurLine++; if (!fPara && scnt) printf("<BR>"); printf("\n"); break;
+ case ENDTABLE:
+ if (fSource) {
+ printf("</TABLE>\n");
+ } else {
+ printf("</PRE><BR>\n"); pre=0; fQS=fIQS=fPara=1;
+ }
+ break;
+ case ENDCODEBLOCK: printf("</PRE>"); pre=0; break;
+ case SHORTLINE:
+ case ENDBODY:
+ printf("\n");
+ break;
+ case BEGINBOLD: printf("<B>"); break;
+ case ENDBOLD: printf("</B>"); break;
+ case BEGINITALICS: printf("<I>"); break;
+ case ENDITALICS: printf("</I>"); break;
+ default:
+ /* nothing */
+ break;
+ }
+ return;
+ }
+
+ /* usual operation */
+ switch (cmd) {
+ case BEGINDOC:
+ /* escchars = ... => HTML doesn't backslash-quote metacharacters */
+ printf("<!-- %s, -->\n",provenance);
+ printf("<!-- %s -->\n\n",anonftp);
+ printf("<HTML>\n<HEAD>\n");
+/* printf("<ISINDEX>\n");*/
+ /* better title possible? */
+ printf("<TITLE>"); printf(manTitle, manName, manSect); printf("</TITLE>\n");
+#ifdef XFree86
+ printf("</HEAD>\n<BODY BGCOLOR=\"#efefef\" TEXT=\"black\" "
+ "LINK=\"blue\" VLINK=\"#551A8B\" ALINK=\"red\">\n");
+#else
+ printf("</HEAD>\n<BODY bgcolor=white>\n");
+#endif
+ printf("<A HREF=\"#toc\">%s</A><P>\n", TABLEOFCONTENTS);
+ I=0;
+ break;
+ case ENDDOC:
+ /* header and footer wanted? */
+ printf("<P>\n");
+ if (fHeadfoot) {
+ printf("<HR><H2>%s</H2>\n", HEADERANDFOOTER);
+ for (i=0; i<CRUFTS; i++) if (*cruft[i]) printf("%s<BR>\n",cruft[i]);
+ }
+
+ if (!tocc) {
+ /*printf("\n<H1>ERROR: Empty man page</H1>\n");*/
+ } else {
+ printf("\n<HR><P>\n");
+ printf("<A NAME=\"toc\"><B>%s</B></A><P>\n", TABLEOFCONTENTS);
+ printf("<UL>\n");
+ for (i=0, lasttoc=BEGINSECTION; i<tocc; lasttoc=toc[i].type, i++) {
+ if (lasttoc!=toc[i].type) {
+ if (toc[i].type==BEGINSUBSECTION) printf("<UL>\n");
+ else printf("</UL>\n");
+ }
+ printf("<LI><A NAME=\"toc%d\" HREF=\"#sect%d\">%s</A></LI>\n", i, i, toc[i].text);
+ }
+ if (lasttoc==BEGINSUBSECTION) printf("</UL>");
+ printf("</UL>\n");
+ }
+ printf("</BODY></HTML>\n");
+ break;
+ case BEGINBODY:
+ printf("<P>\n");
+ break;
+ case ENDBODY: break;
+
+ case BEGINCOMMENT: printf("\n<!--\n"); break;
+ case ENDCOMMENT: printf("\n-->\n"); break;
+ case COMMENTLINE: break;
+
+ case BEGINSECTHEAD:
+ printf("\n<H2><A NAME=\"sect%d\" HREF=\"#toc%d\">", tocc, tocc);
+ break;
+ case ENDSECTHEAD:
+ printf("</A></H2>\n");
+ /* useful extraction from FILES, ENVIRONMENT? */
+ break;
+ case BEGINSUBSECTHEAD:
+ printf("\n<H3><A NAME=\"sect%d\" HREF=\"#toc%d\">", tocc, tocc);
+ break;
+ case ENDSUBSECTHEAD:
+ printf("</A></H3>\n");
+ break;
+ case BEGINSECTION: break;
+ case ENDSECTION:
+ if (sectheadid==NAME && message!=NULL) printf(message);
+ break;
+ case BEGINSUBSECTION: break;
+ case ENDSUBSECTION: break;
+
+ case BEGINBULPAIR:
+ if (listtype==OL) printf("\n<OL>\n");
+ else if (listtype==UL) printf("\n<UL>\n");
+ else printf("\n<DL>\n");
+ break;
+ case ENDBULPAIR:
+ if (listtype==OL) printf("\n</OL>\n");
+ else if (listtype==UL) printf("\n</UL>\n");
+ else printf("</DL>\n");
+ break;
+ case BEGINBULLET:
+ if (listtype==OL || listtype==UL) fcharout=0;
+ else printf("\n<DT>");
+ break;
+ case ENDBULLET:
+ if (listtype==OL || listtype==UL) fcharout=1;
+ else printf("</DT>");
+ break;
+ case BEGINBULTXT:
+ if (listtype==OL || listtype==UL) printf("<LI>");
+ else printf("\n<DD>");
+ break;
+ case ENDBULTXT:
+ if (listtype==OL || listtype==UL) printf("</LI>");
+ else printf("</DD>\n");
+ break;
+
+ case BEGINLINE:
+ /* if (ncnt) printf("<P>\n"); -- if haven't already generated structural tag */
+ if (ncnt) printf("<P>\n");
+
+ /* trailing spaces already trimmed off, so look for eol now */
+ if (fCodeline) {
+ printf("<CODE>");
+ for (i=0; i<scnt-indent; i++) printf("&nbsp;"/*&#160;*/); /* ? */
+ tagc=0;
+
+ /* already have .tag=BOLDITALICS, .first=0 */
+ /* would be more elegant, but can't print initial spaces before first tag
+ tags[0].last = linelen;
+ tagc=1;
+ fIQS=0;
+ */
+ }
+
+ break;
+
+ case ENDLINE:
+ /*if (fCodeline) { fIQS=1; fCodeline=0; }*/
+ if (fCodeline) { printf("</CODE><BR>"); fCodeline=0; }
+ I=0; CurLine++; if (!fPara && scnt) printf("<BR>"); printf("\n");
+ break;
+
+ case SHORTLINE:
+ if (fCodeline) { printf("</CODE>"); fCodeline=0; }
+ if (!fIP) printf("<BR>\n");
+ break;
+
+
+ case BEGINTABLE:
+ if (fSource) {
+ /*printf("<CENTER><TABLE BORDER>\n");*/
+ printf("<TABLE BORDER=0>\n");
+ } else {
+ printf("<BR><PRE>\n"); pre=1; fQS=fIQS=fPara=0;
+ }
+ break;
+ case ENDTABLE:
+ if (fSource) {
+ printf("</TABLE>\n");
+ } else {
+ printf("</PRE><BR>\n"); pre=0; fQS=fIQS=fPara=1;
+ }
+ break;
+ case BEGINTABLELINE: printf("<TR>"); break;
+ case ENDTABLELINE: printf("</TR>\n"); break;
+ case BEGINTABLEENTRY:
+ printf("<TD ALIGN=");
+ switch (tblcellformat[0]) {
+ case 'c': printf("CENTER"); break;
+ case 'n': /*printf("DECIMAL"); break; -- fall through to right for now */
+ case 'r': printf("RIGHT"); break;
+ case 'l':
+ default:
+ printf("LEFT");
+ }
+ if (tblcellspan>1) printf(" COLSPAN=%d", tblcellspan);
+ printf(">");
+ break;
+ case ENDTABLEENTRY:
+ printf("</TD>");
+ break;
+
+ /* something better with CSS */
+ case BEGININDENT: printf("<blockquote>"); break;
+ case ENDINDENT: printf("</blockquote>\n"); break;
+
+ case FONTSIZE:
+ /* HTML font step sizes are bigger than troff's */
+ if ((fontdelta+=intArg)!=0) printf("<FONT SIZE=%c1>", (intArg>0)?'+':'-'); else printf("</FONT>\n");
+ break;
+
+ case BEGINBOLD: printf("<B>"); break;
+ case ENDBOLD: printf("</B>"); break;
+ case BEGINITALICS: printf("<I>"); break;
+ case ENDITALICS: printf("</I>"); break;
+ case BEGINBOLDITALICS:
+ case BEGINCODE: printf("<CODE>"); break;
+ case ENDBOLDITALICS:
+ case ENDCODE: printf("</CODE>"); break;
+ case BEGINCODEBLOCK: printf("<PRE>"); pre=1; break; /* wrong for two-column lists in kermit.1, pine.1, perl4.1 */
+ case ENDCODEBLOCK: printf("</PRE>"); pre=0; break;
+ case BEGINCENTER: printf("<CENTER>"); break;
+ case ENDCENTER: printf("</CENTER>"); break;
+ case BEGINMANREF:
+ manrefextract(hitxt);
+ if (fmanRef) { printf("<A HREF=\""); printf(href, manrefname, manrefsect); printf("\">"); }
+ else printf("<I>");
+ break;
+ case ENDMANREF:
+ if (fmanRef) printf("</A>\n"); else printf("</I>");
+ break;
+ case HR: printf("\n<HR>\n"); break;
+
+ /* U (was B, I), strike -- all temporary until HTML 4.0's INS and DEL widespread */
+ case BEGINDIFFA: printf("<INS><U>"); break;
+ case ENDDIFFA: printf("</U></INS>"); break;
+ case BEGINDIFFD: printf("<DEL><strike>"); break;
+ case ENDDIFFD: printf("</strike></DEL>"); break;
+
+ case BEGINSC: case ENDSC:
+ case BEGINY: case ENDY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case CHANGEBAR:
+ /* nothing */
+ break;
+ default:
+ DefaultPara(cmd);
+ }
+}
+
+
+
+/*
+ * SGML
+ */
+
+/* same as HTML but just has man page-specific DTD */
+/* follows the Davenport DocBook DTD v2.3, availble from ftp.ora.com */
+
+/*char *docbookpath = "docbook.dtd";*/
+
+static void
+SGML(enum command cmd)
+{
+ static int pre=0;
+ int i;
+ char *p;
+ static int fRefEntry=0;
+ static int fRefPurpose=0;
+ /*static char *bads => SGML doesn't backslash-quote metacharacters */
+
+/*
+ fprintf(stderr,
+ "The framework for SGML is in place but not done. If you\n"
+ "are familiar with the DocBook DTD, however, it shouldn't be\n"
+ "too difficult to finish it. If you do so, please send your\n"
+ "code to me so that I may share the wealth in the next release.\n"
+ );
+ exit(1);
+*/
+
+ /* always respond to these signals */
+ switch (cmd) {
+ case CHARLQUOTE:
+ case CHARRQUOTE:
+ printf("&quot;");
+ break;
+ case CHARLSQUOTE:
+ case CHARRSQUOTE:
+ case CHARPERIOD:
+ case CHARTAB:
+ case CHARHAT:
+ case CHARVBAR:
+ case CHARBULLET:
+ case CHARDAGGER:
+ case CHARPLUSMINUS:
+ case CHARNBSP:
+ case CHARCENT:
+ case CHARSECT:
+ case CHARCOPYR:
+ case CHARNOT:
+ case CHARREGTM:
+ case CHARDEG:
+ case CHARACUTE:
+ case CHAR14:
+ case CHAR12:
+ case CHAR34:
+ case CHARMUL:
+ case CHARDIV:
+ putchar(cmd); break;
+ case CHARAMP: printf("&amp;"); break;
+ case CHARDASH:
+ if (sectheadid==NAME && !fRefPurpose) {
+ printf("</RefEntry><RefPurpose>");
+ fRefPurpose=1;
+ } else putchar('-');
+ break;
+ case CHARBACKSLASH: putchar('\\'); break;
+ case CHARGT: printf("&gt;"); break;
+ case CHARLT: printf("&lt;"); break;
+ default:
+ break;
+ }
+
+ /* while in pre mode... */
+ if (pre) {
+ switch (cmd) {
+ case ENDLINE: I=0; CurLine++; if (!fPara && scnt) printf("<BR>"); printf("\n"); break;
+ case ENDTABLE:
+ if (fSource) {
+ printf("</TABLE>\n");
+ } else {
+ printf("</PRE><BR>\n"); pre=0; fQS=fIQS=fPara=1;
+ }
+ break;
+ default:
+ /* nothing */
+ break;
+ }
+ return;
+ }
+
+ /* usual operation */
+ switch (cmd) {
+ case BEGINDOC:
+ /*printf("<!DOCTYPE chapter SYSTEM \"%s\">\n", docbookpath);*/
+ printf("<!--\n\n\tI am looking for help to finish SGML.\n\n-->\n");
+
+ printf("<!-- %s\n",provenance);
+ printf(" %s -->\n\n",anonftp);
+ /* better title possible? */
+ printf("<RefEntry ID=%s.%s>\n", manName, manSect);
+ printf("<RefMeta><RefEntryTitle>%s</RefEntryTitle>", manName);
+ printf("<ManVolNum>%s</ManVolNum></RefMeta>\n\n", manSect);
+
+ I=0;
+ break;
+
+ case ENDDOC:
+ /* header and footer wanted? */
+ if (fHeadfoot) {
+ printf("<RefSect1><Title>%s</Title>\n", HEADERANDFOOTER);
+ for (i=0; i<CRUFTS; i++) if (*cruft[i]) printf("<Para>%s\n",cruft[i]);
+ printf("</RefSect1>");
+ }
+
+ /* table of contents, such as found in HTML, can be generated automatically by SGML software */
+
+ printf("</RefEntry>\n");
+ break;
+ case BEGINBODY: printf("\n\n<Para>"); break;
+ case ENDBODY: break;
+
+ case BEGINCOMMENT: printf("\n<!--\n"); break;
+ case ENDCOMMENT: printf("\n-->\n"); break;
+ case COMMENTLINE: break;
+
+ case BEGINSECTHEAD:
+ case BEGINSUBSECTHEAD:
+ printf("<Title>");
+ break;
+ case ENDSECTHEAD:
+ case ENDSUBSECTHEAD:
+ printf("</Title>");
+ break;
+
+ case BEGINSECTION:
+ if (sectheadid==NAME) printf("<RefNameDiv>");
+ /*printf("<RefEntry>"); -- do lotsa parsing here for RefName, RefPurpose*/
+ else if (sectheadid==SYNOPSIS) printf("<RefSynopsisDiv>");
+ else printf("<RefSect1>");
+ break;
+ case ENDSECTION:
+ if (oldsectheadid==NAME) printf("</RefNameDiv>\n\n");
+ else if (oldsectheadid==SYNOPSIS) printf("</RefSynopsisDiv>\n\n");
+ else printf("</RefSect1>\n\n");
+ break;
+
+ case BEGINSUBSECTION: printf("<RefSect2>"); break;
+ case ENDSUBSECTION: printf("</RefSect2>"); break;
+
+ /* need to update this for enumerated and plain lists */
+ case BEGINBULPAIR: printf("<ItemizedList MARK=Bullet>\n"); break;
+ case ENDBULPAIR: printf("</ItemizedList>\n"); break;
+ case BEGINBULLET: printf("<Term>"); break;
+ case ENDBULLET: printf("</Term>"); break;
+ case BEGINBULTXT: printf("<ListItem><Para>"); break;
+ case ENDBULTXT: printf("</Para></ListItem>\n"); break;
+
+ case BEGINLINE:
+ /* remember, get BEGINBODY call at start of paragraph */
+ if (fRefEntry) {
+ if (fRefPurpose) {
+ for (p=plain; *p!='-'; p++) {
+ /* nothing?! */
+ }
+ }
+ }
+
+ break;
+
+ case ENDLINE:
+ /*if (fCodeline) { fIQS=1; fCodeline=0; }*/
+ if (fCodeline) { printf("</CODE><BR>"); fCodeline=0; }
+ I=0; CurLine++; if (!fPara && scnt) printf("<BR>"); printf("\n");
+ break;
+
+ case SHORTLINE:
+ if (fCodeline) { printf("</CODE>"); fCodeline=0; }
+ if (!fIP) printf("<BR>\n");
+ break;
+
+ case BEGINTABLE:
+ if (fSource) {
+ printf("<TABLE>\n");
+ } else {
+ printf("<BR><PRE>\n"); pre=1; fQS=fIQS=fPara=0;
+ }
+ break;
+ case ENDTABLE:
+ if (fSource) {
+ printf("</TABLE>\n");
+ } else {
+ printf("</PRE><BR>\n"); pre=0; fQS=fIQS=fPara=1;
+ }
+ break;
+ case BEGINTABLELINE: printf("<TR>"); break;
+ case ENDTABLELINE: printf("</TR>\n"); break;
+ case BEGINTABLEENTRY: printf("<TD>"); break;
+ case ENDTABLEENTRY: printf("</TD>"); break;
+
+ case BEGININDENT: case ENDINDENT:
+ case FONTSIZE:
+ break;
+
+ /* have to make some guess about bold and italics */
+ case BEGINBOLD: printf("<B>"); break;
+ case ENDBOLD: printf("</B>"); break;
+ case BEGINITALICS: printf("<I>"); break;
+ case ENDITALICS: printf("</I>"); break;
+ case BEGINBOLDITALICS:
+ case BEGINCODE: printf("<CODE>"); break;
+ case ENDBOLDITALICS:
+ case ENDCODE: printf("</CODE>"); break;
+ case BEGINMANREF:
+/*
+ manrefextract(hitxt);
+ if (fmanRef) { printf("<LINK LINKEND=\""); printf(href, manrefname, manrefsect); printf("\">\n"); }
+ else printf("<I>");
+ break;
+*/
+ printf("<Command>");
+ break;
+ case ENDMANREF:
+/* if (fmanRef) printf("</LINK>"); else printf("</I>");*/
+ printf("</Command>");
+ break;
+
+ case HR: /*printf("\n<HR>\n", horizontalrule);*/ break;
+
+ case BEGINSC: case ENDSC:
+ case BEGINY: case ENDY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case CHANGEBAR:
+ /* nothing */
+ break;
+ default:
+ DefaultPara(cmd);
+ }
+}
+
+#if 0
+/*
+ * GNU Texinfo -- somebody should finish this up
+ */
+
+static void
+Texinfo(enum command cmd)
+{
+ static int pre=0;
+ int i;
+
+ /* always respond to these signals */
+ switch (cmd) {
+ case CHARNBSP: printf("&nbsp;"); I++; break;
+ case CHARLQUOTE: printf("&laquo;"); break;
+ case CHARRQUOTE: printf("&raquo;"); break;
+ case CHARTAB: printf("<tt> </tt>&nbsp;<tt> </tt>&nbsp;"); break;
+ /* old browsers--who uses these?--don't understand symbolic codes */
+ /*
+ case CHARNBSP: printf("&#160;"); I++; break;
+ case CHARLQUOTE: printf("&#171;"); break;
+ case CHARRQUOTE: printf("&#187;"); break;
+ case CHARTAB: printf("<tt> </tt>&#160;<tt> </tt>&#160;"); break;
+ */
+ case CHARLSQUOTE:
+ case CHARRSQUOTE:
+ case CHARPERIOD:
+ case CHARDASH:
+ case CHARBACKSLASH:
+ case CHARVBAR: /*printf("&brvbar;"); -- broken bar no good */
+ case CHARHAT:
+ putchar(cmd); break;
+ case CHARDAGGER: printf("*"); break;
+ case CHARBULLET: printf("&#183;"/*"&middot;"*//*&sect;--middot hardly visible*/); break;
+ case CHARPLUSMINUS: printf("&#177;"/*"&plusmn;"*/); break;
+ case CHARGT: printf("&gt;"); break;
+ case CHARLT: printf("&lt;"); break;
+ case CHARAMP: printf("&amp;"); break;
+ case CHARCENT: printf("&#162;"); break; /* translate these to symbolic forms, sometime */
+ case CHARSECT: printf("&#167;"); break;
+ case CHARCOPYR: printf("&#169;"); break;
+ case CHARNOT: printf("&#172;"); break;
+ case CHARREGTM: printf("&#174;"); break;
+ case CHARDEG: printf("&#176;"); break;
+ case CHARACUTE: printf("&#180;"); break;
+ case CHAR14: printf("&#188;"); break;
+ case CHAR12: printf("&#189;"); break;
+ case CHAR34: printf("&#190;"); break;
+ case CHARMUL: printf("&#215;"); break;
+ case CHARDIV: printf("&#247;"); break;
+ default:
+ break;
+ }
+
+ /* while in pre mode... */
+ if (pre) {
+ switch (cmd) {
+ case ENDLINE: I=0; CurLine++; if (!fPara && scnt) printf("<BR>"); printf("\n"); break;
+ case ENDTABLE:
+ if (fSource) {
+ printf("</TABLE>\n");
+ } else {
+ printf("</PRE><BR>\n"); pre=0; fQS=fIQS=fPara=1;
+ }
+ break;
+ default:
+ /* nothing */
+ break;
+ }
+ return;
+ }
+
+ /* usual operation */
+ switch (cmd) {
+ case BEGINDOC:
+ /* escchars = ... => HTML doesn't backslash-quote metacharacters */
+ printf("<!-- %s, -->\n",provenance);
+ printf("<!-- %s -->\n\n",anonftp);
+ printf("<HTML>\n<HEAD>\n");
+/* printf("<ISINDEX>\n");*/
+ /* better title possible? */
+ printf("<TITLE>"); printf(manTitle, manName, manSect); printf("</TITLE>\n");
+ printf("</HEAD>\n<BODY>\n");
+ printf("<A HREF=\"#toc\">%s</A><P>\n", TABLEOFCONTENTS);
+ I=0;
+ break;
+ case ENDDOC:
+ /* header and footer wanted? */
+ printf("<P>\n");
+ if (fHeadfoot) {
+ printf("<HR><H2>%s</H2>\n", HEADERANDFOOTER);
+ for (i=0; i<CRUFTS; i++) if (*cruft[i]) printf("%s<BR>\n",cruft[i]);
+ }
+
+ if (!tocc) {
+ /*printf("\n<H1>ERROR: Empty man page</H1>\n");*/
+ } else {
+ printf("\n<HR><P>\n");
+ printf("<A NAME=\"toc\"><B>%s</B></A><P>\n", TABLEOFCONTENTS);
+ printf("<UL>\n");
+ for (i=0, lasttoc=BEGINSECTION; i<tocc; lasttoc=toc[i].type, i++) {
+ if (lasttoc!=toc[i].type) {
+ if (toc[i].type==BEGINSUBSECTION) printf("<UL>\n");
+ else printf("</UL>\n");
+ }
+ printf("<LI><A NAME=\"toc%d\" HREF=\"#sect%d\">%s</A></LI>\n", i, i, toc[i].text);
+ }
+ if (lasttoc==BEGINSUBSECTION) printf("</UL>");
+ printf("</UL>\n");
+ }
+ printf("</BODY></HTML>\n");
+ break;
+ case BEGINBODY:
+ printf("<P>\n");
+ break;
+ case ENDBODY: break;
+
+ case BEGINCOMMENT:
+ case ENDCOMMENT:
+ break;
+ case COMMENTLINE: printf("@c "); break;
+
+ case BEGINSECTHEAD:
+ break;
+ case ENDSECTHEAD:
+ printf("\n@node %s\n", toc[tocc].text);
+ printf("\n@section %s\n\n", toc[tocc].text);
+ /* useful extraction from FILES, ENVIRONMENT? */
+ break;
+ case BEGINSUBSECTHEAD:
+ break;
+ case ENDSUBSECTHEAD:
+ printf("\n@node %s\n", toc[tocc].text);
+ printf("\n@subsection %s\n\n", toc[tocc].text);
+ break;
+ case BEGINSECTION: break;
+ case ENDSECTION: break;
+ case BEGINSUBSECTION: break;
+ case ENDSUBSECTION: break;
+
+ case BEGINBULPAIR:
+ if (listtype==OL) printf("\n<OL>\n");
+ else if (listtype==UL) printf("\n<UL>\n");
+ else printf("\n<DL>\n");
+ break;
+ case ENDBULPAIR:
+ if (listtype==OL) printf("\n</OL>\n");
+ else if (listtype==UL) printf("\n</UL>\n");
+ else printf("</DL>\n");
+ break;
+ case BEGINBULLET:
+ if (listtype==OL || listtype==UL) fcharout=0;
+ else printf("\n<DT>");
+ break;
+ case ENDBULLET:
+ if (listtype==OL || listtype==UL) fcharout=1;
+ else printf("</DT>");
+ break;
+ case BEGINBULTXT:
+ if (listtype==OL || listtype==UL) printf("<LI>");
+ else printf("\n<DD>");
+ break;
+ case ENDBULTXT:
+ if (listtype==OL || listtype==UL) printf("</LI>");
+ else printf("</DD>\n");
+ break;
+
+ case BEGINLINE:
+ /* if (ncnt) printf("<P>\n");*/
+
+ /* trailing spaces already trimmed off, so look for eol now */
+ if (fCodeline) {
+ printf("<CODE>");
+ for (i=0; i<scnt-indent; i++) printf("&nbsp;"/*&#160;*/); /* ? */
+ tagc=0;
+
+ /* already have .tag=BOLDITALICS, .first=0 */
+ /* would be more elegant, but can't print initial spaces before first tag
+ tags[0].last = linelen;
+ tagc=1;
+ fIQS=0;
+ */
+ }
+
+ break;
+
+ case ENDLINE:
+ /*if (fCodeline) { fIQS=1; fCodeline=0; }*/
+ if (fCodeline) { printf("</CODE><BR>"); fCodeline=0; }
+ I=0; CurLine++; if (!fPara && scnt) printf("<BR>"); printf("\n");
+ break;
+
+ case SHORTLINE:
+ if (fCodeline) { printf("</CODE>"); fCodeline=0; }
+ if (!fIP) printf("<BR>\n");
+ break;
+
+
+ case BEGINTABLE:
+ if (fSource) {
+ /*printf("<CENTER><TABLE BORDER>\n");*/
+ printf("<TABLE BORDER=0>\n");
+ } else {
+ printf("<BR><PRE>\n"); pre=1; fQS=fIQS=fPara=0;
+ }
+ break;
+ case ENDTABLE:
+ if (fSource) {
+ printf("</TABLE>\n");
+ } else {
+ printf("</PRE><BR>\n"); pre=0; fQS=fIQS=fPara=1;
+ }
+ break;
+ case BEGINTABLELINE: printf("<TR>"); break;
+ case ENDTABLELINE: printf("</TR>\n"); break;
+ case BEGINTABLEENTRY:
+ printf("<TD ALIGN=");
+ switch (tblcellformat[0]) {
+ case 'c': printf("CENTER"); break;
+ case 'n': /*printf("DECIMAL"); break; -- fall through to right for now */
+ case 'r': printf("RIGHT"); break;
+ case 'l':
+ default:
+ printf("LEFT");
+ }
+ if (tblcellspan>1) printf(" COLSPAN=%d", tblcellspan);
+ printf(">");
+ break;
+ case ENDTABLEENTRY:
+ printf("</TD>");
+ break;
+
+ /* something better with CSS */
+ case BEGININDENT: printf("<blockquote>"); break;
+ case ENDINDENT: printf("</blockquote>\n"); break;
+
+ case FONTSIZE:
+ /* HTML font step sizes are bigger than troff's */
+ if ((fontdelta+=intArg)!=0) printf("<FONT SIZE=%c1>", (intArg>0)?'+':'-'); else printf("</FONT>\n");
+ break;
+
+ case BEGINBOLD: printf("@b{"); break; /* } */
+ case BEGINITALICS: printf("@i{"); break;
+ case BEGINSC: printf("@sc{"); break; /* } */
+ case ENDITALICS:
+ case ENDBOLD:
+ case ENDSC: /* { */
+ printf("}");
+ break;
+ case BEGINBOLDITALICS:
+ case BEGINCODE: printf("<CODE>"); break;
+ case ENDBOLDITALICS:
+ case ENDCODE: printf("</CODE>"); break;
+ case BEGINMANREF:
+ manrefextract(hitxt);
+ if (fmanRef) { printf("@xref{}"); }
+/*<A HREF=\""); printf(href, manrefname, manrefsect); printf("\">"); }*/
+ else printf("<I>");
+ break;
+ case ENDMANREF:
+ if (fmanRef) printf("</A>\n"); else printf("</I>");
+ break;
+ case HR: printf("\n<HR>\n"); break;
+
+ case BEGINY: case ENDY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case CHANGEBAR:
+ /* nothing */
+ break;
+ default:
+ DefaultPara(cmd);
+ }
+}
+#endif
+
+
+
+/* generates MIME compliant to RFC 1563 */
+
+static void
+MIME(enum command cmd)
+{
+ static int pre=0;
+ int i;
+
+ /* always respond to these signals */
+ switch (cmd) {
+ case CHARDASH:
+ case CHARAMP:
+ case CHARPERIOD:
+ case CHARTAB:
+ putchar(cmd); break;
+ case CHARLSQUOTE: putchar('`'); break;
+ case CHARACUTE:
+ case CHARRSQUOTE: putchar('\''); break;
+ case CHARBULLET: putchar('*'); break;
+ case CHARDAGGER: putchar('|'); break;
+ case CHARPLUSMINUS: printf("+-"); break;
+ case CHARNBSP: putchar(' '); break;
+ case CHARCENT: putchar('c'); break;
+ case CHARSECT: putchar('S'); break;
+ case CHARCOPYR: printf("(C)"); break;
+ case CHARNOT: putchar('~'); break;
+ case CHARREGTM: printf("(R)"); break;
+ case CHARDEG: putchar('o'); break;
+ case CHAR14: printf("1/4"); break;
+ case CHAR12: printf("1/2"); break;
+ case CHAR34: printf("3/4"); break;
+ case CHARMUL: putchar('X'); break;
+ case CHARDIV: putchar('/'); break;
+ case CHARLQUOTE:
+ case CHARRQUOTE:
+ putchar('"');
+ break;
+ case CHARBACKSLASH: /* these should be caught as escaped chars */
+ case CHARGT:
+ case CHARLT:
+#if 0
+ assert(1);
+#endif
+ break;
+ default:
+ break;
+ }
+
+ /* while in pre mode... */
+ if (pre) {
+ switch (cmd) {
+ case ENDLINE: I=0; CurLine++; if (!fPara && scnt) printf("\n\n"); break;
+ case ENDTABLE: printf("</fixed>\n\n"); pre=0; fQS=fIQS=fPara=1; break;
+ default:
+ /* nothing */
+ break;
+ }
+ return;
+ }
+
+ /* usual operation */
+ switch (cmd) {
+ case BEGINDOC:
+ printf("Content-Type: text/enriched\n");
+ printf("Text-Width: 60\n");
+ escchars = "<>\\";
+
+ I=0;
+ break;
+ case ENDDOC:
+ /* header and footer wanted? */
+ printf("\n\n");
+ if (fHeadfoot) {
+ printf("\n");
+ MIME(BEGINSECTHEAD); printf("%s",HEADERANDFOOTER); MIME(ENDSECTHEAD);
+ for (i=0; i<CRUFTS; i++) if (*cruft[i]) printf("\n%s\n",cruft[i]);
+ }
+
+/*
+ printf("\n<comment>\n");
+ printf("%s\n%s\n", provenance, anonftp);
+ printf("</comment>\n\n");
+*/
+
+/*
+ printf("\n<HR><P>\n");
+ printf("<A NAME=\"toc\"><B>%s</B></A><P>\n", TABLEOFCONTENTS);
+ printf("<UL>\n");
+ for (i=0, lasttoc=BEGINSECTION; i<tocc; lasttoc=toc[i].type, i++) {
+ if (lasttoc!=toc[i].type) {
+ if (toc[i].type==BEGINSUBSECTION) printf("<UL>\n");
+ else printf("</UL>\n");
+ }
+ printf("<LI><A NAME=\"toc%d\" HREF=\"#sect%d\">%s</A></LI>\n", i, i, toc[i].text);
+ }
+ if (lasttoc==BEGINSUBSECTION) printf("</UL>");
+ printf("</UL>\n");
+ printf("</BODY></HTML>\n");
+*/
+ break;
+ case BEGINBODY:
+ printf("\n\n");
+ break;
+ case ENDBODY: break;
+
+ case BEGINCOMMENT: fcharout=0; break;
+ case ENDCOMMENT: fcharout=1; break;
+ case COMMENTLINE: break;
+
+ case BEGINSECTHEAD:
+ printf("\n<bigger><bigger><underline>");
+ /*A NAME=\"sect%d\" HREF=\"#toc%d\"><H2>", tocc, tocc);*/
+ break;
+ case ENDSECTHEAD:
+ printf("</underline></bigger></bigger>\n\n<indent>");
+ /* useful extraction from files, environment? */
+ break;
+ case BEGINSUBSECTHEAD:
+ printf("<bigger>");
+ /*\n<A NAME=\"sect%d\" HREF=\"#toc%d\"><H3>", tocc, tocc);*/
+ break;
+ case ENDSUBSECTHEAD:
+ printf("</bigger>\n\n</indent>");
+ break;
+ case BEGINSECTION:
+ case BEGINSUBSECTION:
+ break;
+ case ENDSECTION:
+ case ENDSUBSECTION:
+ printf("</indent>\n");
+ break;
+
+ case BEGINBULPAIR: break;
+ case ENDBULPAIR: break;
+ case BEGINBULLET: printf("<bold>"); break;
+ case ENDBULLET: printf("</bold>\t"); break;
+ case BEGINBULTXT:
+ case BEGININDENT:
+ printf("<indent>");
+ break;
+ case ENDBULTXT:
+ case ENDINDENT:
+ printf("</indent>\n");
+ break;
+
+ case FONTSIZE:
+ if ((fontdelta+=intArg)==0) {
+ if (intArg>0) printf("</smaller>"); else printf("</bigger>");
+ } else {
+ if (intArg>0) printf("<bigger>"); else printf("<smaller>");
+ }
+ break;
+
+ case BEGINLINE: /*if (ncnt) printf("\n\n");*/ break;
+ case ENDLINE: I=0; CurLine++; printf("\n"); break;
+ case SHORTLINE: if (!fIP) printf("\n\n"); break;
+ case BEGINTABLE: printf("<nl><fixed>\n"); pre=1; fQS=fIQS=fPara=0; break;
+ case ENDTABLE: printf("</fixed><nl>\n"); pre=0; fQS=fIQS=fPara=1; break;
+ case BEGINTABLELINE: case ENDTABLELINE: case BEGINTABLEENTRY: case ENDTABLEENTRY:
+ break;
+ /* could use a new list type */
+
+ case BEGINBOLD: printf("<bold>"); break;
+ case ENDBOLD: printf("</bold>"); break;
+ case BEGINITALICS: printf("<italics>"); break;
+ case ENDITALICS: printf("</italics>"); break;
+ case BEGINCODE:
+ case BEGINBOLDITALICS:printf("<bold><italics>"); break;
+ case ENDCODE:
+ case ENDBOLDITALICS: printf("</bold></italics>"); break;
+ case BEGINMANREF:
+ printf("<x-color><param>blue</param>");
+/* how to make this hypertext?
+ manrefextract(hitxt);
+ if (fmanRef) { printf("<A HREF=\""); printf(href, manrefname, manrefsect); printf("\">\n"); }
+ else printf("<I>");
+ break;
+*/
+ break;
+ case ENDMANREF:
+ printf("</x-color>");
+ break;
+
+ case HR: printf("\n\n%s\n\n", horizontalrule); break;
+
+ case BEGINSC: case ENDSC:
+ case BEGINY: case ENDY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case CHANGEBAR:
+ /* nothing */
+ break;
+ default:
+ DefaultPara(cmd);
+ }
+}
+
+
+
+/*
+ * LaTeX
+ */
+
+static void
+LaTeX(enum command cmd)
+{
+
+ switch (cmd) {
+ case BEGINDOC:
+ escchars = "$&%#_{}"; /* and more to come? */
+ printf("%% %s,\n", provenance);
+ printf("%% %s\n\n", anonftp);
+ /* definitions */
+ printf(
+ "\\documentstyle{article}\n"
+ "\\def\\thefootnote{\\fnsymbol{footnote}}\n"
+ "\\setlength{\\parindent}{0pt}\n"
+ "\\setlength{\\parskip}{0.5\\baselineskip plus 2pt minus 1pt}\n"
+ "\\begin{document}\n"
+ );
+ I=0;
+ break;
+ case ENDDOC:
+ /* header and footer wanted? */
+ printf("\n\\end{document}\n");
+
+ break;
+ case BEGINBODY:
+ printf("\n\n");
+ break;
+ case ENDBODY: break;
+
+ case BEGINCOMMENT:
+ case ENDCOMMENT:
+ break;
+ case COMMENTLINE: printf("%% "); break;
+
+
+ case BEGINSECTION: break;
+ case ENDSECTION: break;
+ case BEGINSECTHEAD: printf("\n\\section{"); tagc=0; break;
+ case ENDSECTHEAD:
+ printf("}");
+/*
+ if (CurLine==1) printf("\\footnote{"
+ "\\it conversion to \\LaTeX\ format by PolyglotMan "
+ "available via anonymous ftp from {\\tt ftp.berkeley.edu:/ucb/people/phelps/tcltk}}"
+ );
+*/
+ /* useful extraction from files, environment? */
+ printf("\n");
+ break;
+ case BEGINSUBSECTHEAD:printf("\n\\subsection{"); break;
+ case ENDSUBSECTHEAD:
+ printf("}");
+ break;
+ case BEGINSUBSECTION: break;
+ case ENDSUBSECTION: break;
+ case BEGINBULPAIR: printf("\\begin{itemize}\n"); break;
+ case ENDBULPAIR: printf("\\end{itemize}\n"); break;
+ case BEGINBULLET: printf("\\item ["); break;
+ case ENDBULLET: printf("] "); break;
+ case BEGINLINE: /*if (ncnt) printf("\n\n");*/ break;
+ case ENDLINE: I=0; putchar('\n'); CurLine++; break;
+ case BEGINTABLE: printf("\\begin{verbatim}\n"); break;
+ case ENDTABLE: printf("\\end{verbatim}\n"); break;
+ case BEGINTABLELINE: case ENDTABLELINE: case BEGINTABLEENTRY: case ENDTABLEENTRY:
+ break;
+ case BEGININDENT: case ENDINDENT:
+ case FONTSIZE:
+ break;
+ case SHORTLINE: if (!fIP) printf("\n\n"); break;
+ case BEGINBULTXT: break;
+ case ENDBULTXT: putchar('\n'); break;
+
+ case CHARLQUOTE: printf("``"); break;
+ case CHARRQUOTE: printf("''"); break;
+ case CHARLSQUOTE:
+ case CHARRSQUOTE:
+ case CHARPERIOD:
+ case CHARTAB:
+ case CHARDASH:
+ case CHARNBSP:
+ putchar(cmd); break;
+ case CHARBACKSLASH: printf("$\\backslash$"); break;
+ case CHARGT: printf("$>$"); break;
+ case CHARLT: printf("$<$"); break;
+ case CHARHAT: printf("$\\char94{}$"); break;
+ case CHARVBAR: printf("$|$"); break;
+ case CHARAMP: printf("\\&"); break;
+ case CHARBULLET: printf("$\\bullet$ "); break;
+ case CHARDAGGER: printf("\\dag "); break;
+ case CHARPLUSMINUS: printf("\\pm "); break;
+ case CHARCENT: printf("\\hbox{\\rm\\rlap/c}"); break;
+ case CHARSECT: printf("\\S "); break;
+ case CHARCOPYR: printf("\\copyright "); break;
+ case CHARNOT: printf("$\\neg$"); break;
+ case CHARREGTM: printf("(R)"); break;
+ case CHARDEG: printf("$^\\circ$"); break;
+ case CHARACUTE: putchar('\''); break;
+ case CHAR14: printf("$\\frac{1}{4}$"); break;
+ case CHAR12: printf("$\\frac{1}{2}$"); break;
+ case CHAR34: printf("$\\frac{3}{4}$"); break;
+ case CHARMUL: printf("\\times "); break;
+ case CHARDIV: printf("\\div "); break;
+
+ case BEGINCODE:
+ case BEGINBOLD: printf("{\\bf "); break; /* } */
+ case BEGINSC: printf("{\\sc "); break; /* } */
+ case BEGINITALICS: printf("{\\it "); break; /* } */
+ case BEGINBOLDITALICS:printf("{\\bf\\it "); break; /* } */
+ case BEGINMANREF: printf("{\\sf "); break; /* } */
+ case ENDCODE:
+ case ENDBOLD:
+ case ENDSC:
+ case ENDITALICS:
+ case ENDBOLDITALICS:
+ case ENDMANREF: /* { */
+ putchar('}');
+ break;
+ case HR: /*printf("\n%s\n", horizontalrule);*/ break;
+
+ case BEGINY: case ENDY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case CHANGEBAR:
+ /* nothing */
+ break;
+ default:
+ DefaultPara(cmd);
+ }
+}
+
+
+static void
+LaTeX2e(enum command cmd)
+{
+ switch (cmd) {
+ /* replace selected commands ... */
+ case BEGINDOC:
+ escchars = "$&%#_{}";
+ printf("%% %s,\n", provenance);
+ printf("%% %s\n\n", anonftp);
+ /* definitions */
+ printf(
+ "\\documentclass{article}\n"
+ "\\def\\thefootnote{\\fnsymbol{footnote}}\n"
+ "\\setlength{\\parindent}{0pt}\n"
+ "\\setlength{\\parskip}{0.5\\baselineskip plus 2pt minus 1pt}\n"
+ "\\begin{document}\n"
+ );
+ I=0;
+ break;
+ case BEGINCODE:
+ case BEGINBOLD: printf("\\textbf{"); break; /* } */
+ case BEGINSC: printf("\\textsc{"); break; /* } */
+ case BEGINITALICS: printf("\\textit{"); break; /* } */
+ case BEGINBOLDITALICS:printf("\\textbf{\\textit{"); break; /* }} */
+ case BEGINMANREF: printf("\\textsf{"); break; /* } {{ */
+ case ENDBOLDITALICS: printf("}}"); break;
+
+ /* ... rest same as old LaTeX */
+ default:
+ LaTeX(cmd);
+ }
+}
+
+
+
+/*
+ * Rich Text Format (RTF)
+ */
+
+/* RTF could use more work */
+
+static void
+RTF(enum command cmd)
+{
+
+ switch (cmd) {
+ case BEGINDOC:
+ escchars = "{}";
+ /* definitions */
+ printf(
+ /* fonts */
+ "{\\rtf1\\deff2 {\\fonttbl"
+ "{\\f20\\froman Times;}{\\f150\\fnil I Times Italic;}"
+ "{\\f151\\fnil B Times Bold;}{\\f152\\fnil BI Times BoldItalic;}"
+ "{\\f22\\fmodern Courier;}{\\f23\\ftech Symbol;}"
+ "{\\f135\\fnil I Courier Oblique;}{\\f136\\fnil B Courier Bold;}{\\f137\\fnil BI Courier BoldOblique;}"
+ "{\\f138\\fnil I Helvetica Oblique;}{\\f139\\fnil B Helvetica Bold;}}"
+ "\n"
+
+ /* style sheets */
+ "{\\stylesheet{\\li720\\sa120 \\f20 \\sbasedon222\\snext0 Normal;}"
+ "{\\s2\\sb200\\sa120 \\b\\f3\\fs20 \\sbasedon0\\snext2 section head;}"
+ "{\\s3\\li180\\sa120 \\b\\f20 \\sbasedon0\\snext3 subsection head;}"
+ "{\\s4\\fi-1440\\li2160\\sa240\\tx2160 \\f20 \\sbasedon0\\snext4 detailed list;}}"
+ "\n"
+
+/* more header to come--do undefined values default to nice values? */
+ );
+ I=0;
+ break;
+ case ENDDOC:
+ /* header and footer wanted? */
+ printf("\\par{\\f150 %s,\n%s}", provenance, anonftp);
+ printf("}\n");
+ break;
+ case BEGINBODY:
+ printf("\n\n");
+ break;
+ case ENDBODY:
+ CurLine++;
+ printf("\\par\n");
+ tagc=0;
+ break;
+
+ case BEGINCOMMENT: fcharout=0; break;
+ case ENDCOMMENT: fcharout=1; break;
+ case COMMENTLINE: break;
+
+ case BEGINSECTION: break;
+ case ENDSECTION: printf("\n\\par\n"); break;
+ case BEGINSECTHEAD: printf("{\\s2 "); tagc=0; break;
+ case ENDSECTHEAD:
+ printf("}\\par");
+ /* useful extraction from files, environment? */
+ printf("\n");
+ break;
+ case BEGINSUBSECTHEAD:printf("{\\s3 "); break;
+ case ENDSUBSECTHEAD:
+ printf("}\\par\n");
+ break;
+ case BEGINSUBSECTION: break;
+ case ENDSUBSECTION: break;
+ case BEGINLINE: /*if (ncnt) printf("\n\n");*/ break;
+ case ENDLINE: I=0; putchar(' '); /*putchar('\n'); CurLine++;*/ break;
+ case SHORTLINE: if (!fIP) printf("\\line\n"); break;
+ case BEGINBULPAIR: printf("{\\s4 "); break;
+ case ENDBULPAIR: printf("}\\par\n"); break;
+ case BEGINBULLET: break;
+ case ENDBULLET: printf("\\tab "); fcharout=0; break;
+ case BEGINBULTXT: fcharout=1; break;
+ case ENDBULTXT: break;
+
+ case CHARLQUOTE: printf("``"); break;
+ case CHARRQUOTE: printf("''"); break;
+ case CHARLSQUOTE:
+ case CHARRSQUOTE:
+ case CHARPERIOD:
+ case CHARTAB:
+ case CHARDASH:
+ case CHARBACKSLASH:
+ case CHARGT:
+ case CHARLT:
+ case CHARHAT:
+ case CHARVBAR:
+ case CHARAMP:
+ case CHARNBSP:
+ case CHARCENT:
+ case CHARSECT:
+ case CHARCOPYR:
+ case CHARNOT:
+ case CHARREGTM:
+ case CHARDEG:
+ case CHARACUTE:
+ case CHAR14:
+ case CHAR12:
+ case CHAR34:
+ case CHARMUL:
+ case CHARDIV:
+ putchar(cmd); break;
+ case CHARBULLET: printf("\\bullet "); break;
+ case CHARDAGGER: printf("\\dag "); break;
+ case CHARPLUSMINUS: printf("\\pm "); break;
+
+ case BEGINCODE:
+ case BEGINBOLD: printf("{\\b "); break; /* } */
+ case BEGINSC: printf("{\\fs20 "); break; /* } */
+ case BEGINITALICS: printf("{\\i "); break; /* } */
+ case BEGINBOLDITALICS:printf("{\\b \\i "); break; /* } */
+ case BEGINMANREF: printf("{\\f22 "); break; /* } */
+ case ENDBOLD:
+ case ENDCODE:
+ case ENDSC:
+ case ENDITALICS:
+ case ENDBOLDITALICS:
+ case ENDMANREF: /* { */
+ putchar('}');
+ break;
+ case HR: printf("\n%s\n", horizontalrule); break;
+
+ case BEGINY: case ENDY:
+ case BEGINHEADER: case ENDHEADER:
+ case BEGINFOOTER: case ENDFOOTER:
+ case BEGINTABLE: case ENDTABLE:
+ case BEGINTABLELINE: case ENDTABLELINE: case BEGINTABLEENTRY: case ENDTABLEENTRY:
+ case BEGININDENT: case ENDINDENT:
+ case FONTSIZE:
+ case CHANGEBAR:
+ /* nothing */
+ break;
+ default:
+ DefaultPara(cmd);
+ }
+}
+
+
+
+/*
+ * pointers to existing tools
+ */
+
+static void
+PostScript(enum command cmd)
+{
+ fprintf(stderr, "Use groff or psroff to generate PostScript.\n");
+ exit(1);
+}
+
+
+static void
+FrameMaker(enum command cmd)
+{
+ fprintf(stderr, "FrameMaker comes with filters that convert from roff to MIF.\n");
+ exit(1);
+}
+
+
+
+
+/*
+ * Utilities common to both parses
+ */
+
+
+/*
+ level 0: DOC - need match
+ level 1: SECTION - need match
+ level 2: SUBSECTION | BODY | BULLETPAIR
+ level 3: BODY (within SUB) | BULLETPAIR (within SUB) | BULTXT (within BULLETPAIR)
+ level 4: BULTXT (within BULLETPAIR within SUBSECTION)
+
+ never see: SECTHEAD, SUBSECTHEAD, BULLET
+*/
+
+int Psect=0, Psub=0, Pbp=0, Pbt=0, Pb=0, Pbul=0;
+
+static void
+pop(enum command cmd)
+{
+ assert(cmd==ENDINDENT || cmd==BEGINBULLET || cmd==BEGINBULTXT || cmd==BEGINBULPAIR || cmd==BEGINBODY || cmd==BEGINSECTION || cmd==BEGINSUBSECTION || cmd==ENDDOC);
+/*
+ int i;
+ int p;
+ int match;
+
+ p=cmdp-1;
+ for (i=cmdp-1;i>=0; i--)
+ if (cmd==cmdstack[i]) { match=i; break; }
+*/
+
+ /* if match, pop off all up to and including match */
+ /* otherwise, pop off one level*/
+
+ if (Pbul) {
+ (*fn)(ENDBULLET); Pbul=0;
+ if (cmd==BEGINBULLET) return;
+ } /* else close off ENDBULTXT */
+
+ if (Pbt) { (*fn)(ENDBULTXT); Pbt=0; }
+ if (cmd==BEGINBULTXT || cmd==BEGINBULLET) return;
+
+ if (Pb && cmd==BEGINBULPAIR) { (*fn)(ENDBODY); Pb=0; } /* special */
+ if (Pbp) { (*fn)(ENDBULPAIR); Pbp=0; }
+ if (cmd==BEGINBULPAIR || cmd==ENDINDENT) return;
+
+ if (Pb) { (*fn)(ENDBODY); Pb=0; }
+ if (cmd==BEGINBODY) return;
+
+ if (Psub) { (*fn)(ENDSUBSECTION); Psub=0; }
+ if (cmd==BEGINSUBSECTION) return;
+
+ if (Psect) { (*fn)(ENDSECTION); Psect=0; }
+ if (cmd==BEGINSECTION) return;
+}
+
+
+static void
+poppush(enum command cmd)
+{
+ assert(cmd==ENDINDENT || cmd==BEGINBULLET || cmd==BEGINBULTXT || cmd==BEGINBULPAIR || cmd==BEGINBODY || cmd==BEGINSECTION || cmd==BEGINSUBSECTION);
+
+ pop(cmd);
+
+ switch (cmd) {
+ case BEGINBULLET: Pbul=1; break;
+ case BEGINBULTXT: Pbt=1; break;
+ case BEGINBULPAIR: Pbp=1; break;
+ case BEGINBODY: Pb=1; break;
+ case BEGINSECTION: Psect=1; break;
+ case BEGINSUBSECTION: Psub=1; break;
+ default:
+ if (!fQuiet) fprintf(stderr, "poppush: unrecognized code %d\n", cmd);
+ }
+
+ (*fn)(cmd);
+ prevcmd = cmd;
+}
+
+
+
+/*
+ * PREFORMATTED PAGES PARSING
+ */
+
+/* wrapper for getchar() that expands tabs, and sends maximum of n=40 consecutive spaces */
+
+static int
+getchartab(void)
+{
+ static int tabexp = 0;
+ static int charinline = 0;
+ static int cspccnt = 0;
+ char c;
+
+ c = lookahead;
+ if (tabexp) tabexp--;
+ else if (c=='\n') {
+ charinline=0;
+ cspccnt=0;
+ } else if (c=='\t') {
+ tabexp = TabStops-(charinline%TabStops); if (tabexp==TabStops) tabexp=0;
+ lookahead = c = ' ';
+ } else if (cspccnt>=40) {
+ if (*in==' ') {
+ while (*in==' '||*in=='\t') in++;
+ in--;
+ }
+ cspccnt=0;
+ }
+
+ if (!tabexp && lookahead) lookahead = *in++;
+ if (c=='\b') charinline--; else charinline++;
+ if (c==' ') cspccnt++;
+ return c;
+}
+
+
+/* replace gets. handles hyphenation too */
+static char *
+la_gets(char *buf)
+{
+ static char la_buf[MAXBUF]; /* can lookahead a full line, but nobody does now */
+ static int fla=0, hy=0;
+ char *ret,*p;
+ int c,i;
+
+ assert(buf!=NULL);
+
+ if (fla) {
+ /* could avoid copying if callers used return value */
+ strcpy(buf,la_buf); fla=0;
+ ret=buf; /* correct? */
+ } else {
+ /*ret=gets(buf); -- gets is deprecated (since it can read too much?) */
+ /* could do this...
+ ret=fgets(buf, MAXBUF, stdin);
+ buf[strlen(buf)-1]='\0';
+ ... but don't want to have to rescan line with strlen, so... */
+
+ i=0; p=buf;
+
+ /* recover spaces if re-linebreaking */
+ for (; hy; hy--) { *p++=' '; i++; }
+
+ while (lookahead && (c=getchartab())!='\n' && i<MAXBUF) { *p++=c; i++; }
+ assert(i<MAXBUF);
+
+#if 0
+ lookahead=ungetc(getchar(), stdin); /* only looking ahead one character for now */
+#endif
+
+ /* very special case: if in SEE ALSO section, re-linebreak so references aren't linebroken
+ (also do this if fNOHY flag is set) -- doesn't affect lookahead */
+ /* 0xad is an en dash on Linux? */
+ if ((fPara || sectheadid==SEEALSO || fNOHY) && p>buf && p[-1]=='-' && isspace(lookahead)) {
+ p--; /* zap hyphen */
+ /* zap boldfaced hyphens, gr! */
+ while (p[-1]=='\b' && p[-2]=='-') p-=2;
+
+ /* start getting next line, spaces first ... */
+ while (lookahead && isspace(lookahead) && lookahead!='\n') { getchartab(); hy++; }
+
+ /* ... append next nonspace string to previous ... */
+ while (lookahead && !isspace(lookahead) && i++<MAXBUF) *p++=getchartab();
+
+ /* gobble following spaces (until, perhaps including, end of line) */
+ while (lookahead && isspace(lookahead) && lookahead!='\n') getchartab();
+ if (lookahead=='\n') { getchartab(); hy=0; }
+ }
+
+ *p='\0';
+ ret=(lookahead)?buf:NULL;
+ }
+
+ AbsLine++;
+ return ret; /* change this to line length? (-1==old NULL) */
+}
+
+
+/*** Kong ***/
+/*
+ I hope the compiler has good common subexpression elimination
+ for all the pointer arithmetic.
+*/
+
+
+char phrase[MAXBUF]; /* first "phrase" (space of >=3 spaces) */
+int phraselen;
+
+static void
+filterline(char *buf, char *plain)
+{
+ char *p,*q,*r;
+ char *ph;
+ int iq;
+ int i,j;
+ int hl=-1, hl2=-1;
+ int iscnt=0; /* interword space count */
+ int tagci;
+ int I0;
+ int etype;
+ int efirst;
+ enum tagtype tag = NOTAG;
+
+ assert(buf!=NULL && plain!=NULL);
+
+ etype=NOTAG;
+ efirst=-1;
+ tagci=tagc;
+ ph=phrase; phraselen=0;
+ scnt=scnt2=0;
+ s_sum=s_cnt=0;
+ bs_sum=bs_cnt=0;
+ ccnt=0;
+ spcsqz=0;
+
+ /* strip only certain \x1b's and only at very beginning of line */
+ for (p=buf; *p=='\x1b' && (p[1]=='8'||p[1]=='9'); p+=2)
+ /* nop */;
+
+ strcpy(plain,p);
+ q=&plain[strlen(p)];
+
+ /*** spaces and change bars ***/
+ for (scnt=0,p=plain; *p==' '; p++) scnt++; /* initial space count */
+ if (scnt>200) scnt=130-(q-p);
+
+ assert(*q=='\0');
+ q--;
+ if (fChangeleft)
+ for (; q-40>plain && *q=='|'; q--) { /* change bars */
+ if (fChangeleft!=-1) ccnt++;
+ while (q-2>=plain && q[-1]=='\b' && q[-2]=='|') q-=2; /* boldface changebars! */
+ }
+
+ /*if (q!=&plain[scnt-1])*/ /* zap trailing spaces */
+ for (; *q==' ' && q>plain; q--) /* nop */;
+
+ /* second changebar way out east! HACK HACK HACK */
+ if (q-plain>100 && *q=='|') {
+ while (*q=='|' && q>plain) { q--; if (fChangeleft!=-1) ccnt++; }
+ while ((*q==' ' || *q=='_' || *q=='-') && q>plain) q--;
+ }
+
+ for (r=q; (*r&0xff)==CHARDAGGER; r--) *r='-'; /* convert daggers at end of line to hyphens */
+
+ if (q-plain < scnt) scnt = q-plain+1;
+ q[1]='\0';
+
+ /* set I for tags below */
+ if (indent>=0 && scnt>=indent) scnt-=indent;
+ if (!fPara && !fIQS) {
+ if (fChangeleft) I+=(scnt>ccnt)?scnt:ccnt;
+ else I+=scnt;
+ }
+ I0=I;
+
+ /*** tags and filler spaces ***/
+
+ iq=0; falluc=1;
+ for (q=plain; *p; p++) {
+
+ iscnt=0;
+ if (*p==' ') {
+ for (r=p; *r==' '; r++) { iscnt++; spcsqz++; }
+ s_sum+=iscnt; s_cnt++;
+ if (iscnt>1 && !scnt2 && *p==' ') scnt2=iscnt;
+ if (iscnt>2) { bs_cnt++; bs_sum+=iscnt; } /* keep track of large gaps */
+ iscnt--; /* leave last space for tail portion of loop */
+
+ /* write out spaces */
+ if (fQS && iscnt<3) { p=r-1; iscnt=0; } /* reduce strings of <3 spaces to 1 */
+ /* else if (fQS && iscnt>=3) { replace with tab? } */
+ else {
+ for (i=0; i<iscnt; i++) { p++; *q++=' '; }
+ }
+ } /* need to go through if chain for closing off annotations */
+
+ /** backspace-related filtering **/
+
+ if (*p=='\b' && p[1]=='_' && q>plain && q[-1]=='+') {
+ /* bold plus/minus(!) */
+ q[-1]=c_plusminus;
+ while (*p=='\b' && p[1]=='_') p+=2;
+ continue;
+ } else if ((*p=='_' && p[1]=='\b' && p[2]!='_' && p[3]!='\b')
+ || (*p=='\b' && p[1]=='_')) {
+ /* italics */
+ if (tag!=ITALICS && hl>=0) { tagadd(tag, hl, I+iq); hl=-1; }
+ if (hl==-1) hl=I+iq;
+ tag=ITALICS;
+ p+=2;
+ } else if (*p=='_' && p[2]==p[4] && p[1]=='\b' && p[3]=='\b' && p[2]!='_') {
+ /* bold italics (for Solaris) */
+ for (p+=2; *p==p[2] && p[1]=='\b';) p+=2;
+ if (tag!=BOLDITALICS && hl>=0) { tagadd(tag, hl, I+iq); hl=-1; }
+ if (hl==-1) hl=I+iq;
+ tag=BOLDITALICS;
+ } else if (*p==p[2] && p[1]=='\b') {
+ /* boldface */
+ while (*p==p[2] && p[1]=='\b') p+=2;
+ if (tag!=BOLD && hl>=0) { tagadd(tag, hl, I+iq); hl=-1; }
+ if (hl==-1) hl=I+iq;
+ tag=BOLD;
+ } else if (p[1]=='\b' &&
+ ((*p=='o' && p[2]=='+') ||
+ (*p=='+' && p[2]=='o')) ) {
+ /* bullets */
+ p+=2;
+ while (p[1]=='\b' && (*p=='o' || p[2]=='+') ) p+=2; /* bold bullets(!) */
+ *q++=c_bullet; iq++;
+ continue;
+ } else if (*p=='\b' && p>plain && p[-1]=='o' && p[1]=='+') {
+ /* OSF bullets */
+ while (*p=='\b' && p[1]=='+') p+=2; /* bold bullets(!) */
+ q[-1]=c_bullet; p--;
+ continue;
+ } else if (p[1]=='\b' && *p=='+' && p[2]=='_') {
+ /* plus/minus */
+ p+=2;
+ *q++=c_plusminus; iq++;
+ continue;
+ } else if (p[1]=='\b' && *p=='|' && p[2]=='-') {
+ /* dagger */
+ *q++=c_dagger; iq++;
+ p+=2; continue;
+ } else if (*p=='\b') {
+ /* supress unattended backspaces */
+ continue;
+ } else if (*p=='\x1b' /*&& (p[1]=='9'||p[1]=='8')*/) {
+ p++;
+ if (*p=='[') {
+ p++;
+ if (*p=='1' && hl==-1) {
+ /* stash attributes in "invalid" array element */
+ efirst=I+iq; etype=BOLD;
+ /*hl=I+iq; tag=BOLD; -- faces immediate end of range */
+ } else if (*p=='0' /*&& hl>=0 && hl2==-1 && tags[MAXTAGS].first<I+iq*/) {
+ /* doesn't catch tag if spans line -- just make tag and hl static? */
+ /*tagadd(tags[MAXTAGS].type, tags[MAXTAGS].first, I+iq);*/
+ if (hl==-1 && hl2==-1 && efirst!=-1/*<I+iq*/)
+ tagadd(etype, efirst, I+iq);
+ efirst=-1;
+ } /* else skip unrecognized escape codes like 8/9 */
+ }
+ p+=2; /* gobble 0/1 and mysterious following 'm' */
+ /* following 'm' (why?) gobbled in overarching for */
+ /*continue;*/
+ } else if ((isupper(*p) /*|| *p=='_' || *p=='&'*/) &&
+ (hl>=0 || isupper(p[1]) || (p[1]=='_' && p[2]!='\b') || p[1]=='&')) {
+ if (hl==-1 && efirst==-1) { hl=I+iq; tag=SMALLCAPS; }
+ } else {
+ /* end of tag, one way or another */
+ /* collect tags in this pass, interspersed later if need be */
+ /* can't handle overlapping tags */
+ if (hl>=0) {
+ if (hl2==-1) tagadd(tag, hl, I+iq);
+ hl=-1;
+ }
+ }
+
+ /** non-backspace related filtering **/
+ /* case statement here in place of if chain? */
+/* Tk 3.x's text widget tabs too crazy
+ if (*p==' ' && strncmp(" ",p,5)==0) {
+ xputchar('\t'); i+=5-1; ci++; continue;
+ } else
+*/
+/* copyright symbol: too much work for so little
+ if (p[i]=='o' && (strncmp("opyright (C) 19",&p[i],15)==0
+ || strncmp("opyright (c) 19",&p[i],15)==0)) {
+ printf("opyright \xd3 19");
+ tagadd(SYMBOL, ci+9, ci+10);
+ i+=15-1; ci+=13; continue;
+ } else
+*/
+ if (*p=='(' && q>plain && (isalnum(q[-1])||strchr(manvalid/*"._-+"*/,q[-1])!=NULL)
+ && strcoloncmp(&p[1],')',vollist)
+ /* && p[1]!='s' && p[-1]!='`' && p[-1]!='\'' && p[-1]!='"'*/ ) {
+ hl2=I+iq;
+ for (r=q-1; r>=plain && (isalnum(*r)||strchr(manvalid/*"._-+:"*/,*r)!=NULL); r--)
+ hl2--;
+ /* else ref to a function? */
+ /* maybe save position of opening paren so don't highlight it later */
+ } else if (*p==')' && hl2!=-1) {
+ /* don't overlap tags on man page referenes */
+ while (tagc>0 && tags[tagc-1].last>hl2) tagc--;
+ tagadd(MANREF, hl2, I+iq+1);
+ hl2=hl=-1;
+ } else if (hl2!=-1) {
+ /* section names are alphanumic or '+' for C++ */
+ if (!isalnum(*p) && *p!='+') hl2=-1;
+ }
+
+
+ /*assert(*p!='\0');*/
+ if (!*p) break; /* not just safety check -- check out sgmls.1 */
+
+ *q++=*p;
+/* falluc = falluc && (isupper(*p) || isspace(*p) || isdigit(*p) || strchr("-+&_'/()?!.,;",*p)!=NULL);*/
+ falluc = falluc && !islower(*p);
+ if (!scnt2) { *ph++=*p; phraselen++; }
+ iq+=iscnt+1;
+ }
+ if (hl>=0) tagadd(tag, hl, I+iq);
+ else if (efirst>=0) tagadd(etype, efirst, I+iq);
+ *q=*ph='\0';
+ linelen=iq+ccnt;
+
+
+ /* special case for Solaris:
+ if line has ONLY <CODE> tags AND they SPAN line, convert to one tag */
+ fCodeline=0;
+ if (tagc && tags[0].first==0 && tags[tagc-1].last==linelen) {
+ fCodeline=1;
+ j=0;
+ /* invariant: at start of a tag */
+ for (i=0; fCodeline && i<tagc; i++) {
+ if (tags[i].type!=BOLDITALICS /*&& tags[i].type!=BOLD*/) fCodeline=0;
+ else if ((j=tags[i].last)<linelen) {
+ for (; j < tags[i+1].first ; j++)
+ if (!isspace(plain[j])) { fCodeline=0; break; }
+ }
+ }
+ }
+
+
+ /* verify tag lists -- in production, compiler should kill with dead code elimination */
+ for (i=tagci; i<tagc; i++) {
+ /* verify valid ranges */
+ assert(tags[i].type>NOTAG && tags[i].type<=MANREF);
+ assert(tags[i].first>=I0 && tags[i].last<=linelen+I0);
+ assert(tags[i].first<=tags[i].last);
+
+ /* verify for no overlap with other tags */
+ for (j=i+1; j<tagc; j++) {
+ assert(tags[i].last<=tags[j].first /*|| tags[i].first>=tags[j].last*/);
+ }
+ }
+}
+
+
+/*
+ buf[] == input text (read only)
+ plain[] == output (initial, trailing spaces stripped; tabs=>spaces;
+ underlines, overstrikes => tag array; spaces squeezed, if requested)
+ ccnt = count of changebars
+ scnt = count of initial spaces
+ linelen = length result in plain[]
+*/
+
+/*#define MAXINDENT 15*/
+/*#define HEADFOOTMATCH 20*/
+
+int fHead=0;
+int fFoot=0;
+
+static void
+preformatted_filter(void)
+{
+ const int MINRM=50; /* minimum column for right margin */
+ const int MINMID=20;
+ const int HEADFOOTSKIP=20;
+ const int HEADFOOTMAX=25;
+ int curtag;
+ char *p,*r;
+ char head[MAXBUF]=""; /* first "word" */
+ char foot[MAXBUF]="";
+ int header_m=0, footer_m=0;
+ int headlen=0, footlen=0;
+/* int line=1-1; */
+ int i,j,k,l,off;
+ int sect=0,subsect=0,bulpair=0,osubsect=0;
+ int title=1;
+ int oscnt=-1;
+ int empty=0,oempty;
+ int fcont=0;
+ int Pnew=0,I0;
+ float s_avg=0.0;
+ int spaceout;
+ int skiplines=0;
+ int c;
+
+ /* try to keep tabeginend[][] in parallel with enum tagtype */
+ assert(tagbeginend[ITALICS][0]==BEGINITALICS);
+ assert(tagbeginend[MANREF][1]==ENDMANREF);
+ in++; /* lookahead = current character, in points to following */
+
+ /* for (i=0; i<MAXBUF; i++) tabgram[i]=0;*/
+
+ /*if (fMan) */indent=-1;
+ I=1;
+ CurLine=1;
+ (*fn)(BEGINDOC); I0=I;
+
+ /* run through each line */
+ while (la_gets(buf)!=NULL) {
+ if (title) I=I0;
+ /* strip out Ousterhout box: it's confusing the section line counts in TkMan outlining */
+ if (fNORM && *buf=='_'
+ && strncmp(buf,"_________________________________________________________________",65)==0) {
+ fTclTk = 1;
+ if (fChangeleft==0) fChangeleft=1;
+ skiplines = 2;
+ }
+ if (skiplines) { skiplines--; AbsLine++; continue; }
+ filterline(buf,plain); /* ALL LINES ARE FILTERED */
+
+#if 0
+ /* dealing with tables in formatted pages is hopeless */
+ finTable = fTable &&
+ ((!ncnt && fotable) ||
+ (ncnt && bs_cnt>=2 && bs_cnt<=5 && ((float) bs_sum / (float) bs_cnt)>3.0));
+ if (finTable) {
+ if (!fotable) (*fn)(BEGINTABLE);
+ } else if (fotable) {
+ (*fn)(ENDTABLE);
+ I=I0; tagc=0; filterline(buf,plain); /* rescan first line out of table */
+ }
+#endif
+
+ s_avg=(float) s_sum;
+ if (s_cnt>=2) {
+ /* don't count large second space gap */
+ if (scnt2) s_avg= (float) (s_sum - scnt2) / (float) (s_cnt-1);
+ else s_avg= (float) (s_sum) / (float) (s_cnt);
+ }
+
+ p=plain; /* points to current character in plain */
+
+ /*** determine header and global indentation ***/
+ if (/*fMan && (*/!fHead || indent==-1/*)*/) {
+ if (!linelen) continue;
+ if (!*header) {
+ /* check for missing first header--but this doesn't catch subsequent pages */
+ if (stricmp(p,"NAME")==0 || stricmp(p,"NOMBRE")==0) { /* works because line already filtered */
+ indent=scnt; /*filterline(buf,plain);*/ scnt=0; I=I0; fHead=1;
+ } else {
+ fHead=1;
+ (*fn)(BEGINHEADER);
+ /* grab header and its first word */
+ strcpy(header,p);
+ if ((header_m=HEADFOOTSKIP)>linelen) header_m=0;
+ strcpy(head,phrase); headlen=phraselen;
+ la_gets(buf); filterline(buf,plain);
+ if (linelen) {
+ strcpy(header2,plain);
+ if (strincmp(plain,"Digital",7)==0 || strincmp(plain,"OSF",3)==0) {
+ fFoot=1;
+ fSubsections=0;
+ }
+ }
+ (*fn)(ENDHEADER); tagc=0;
+ continue;
+ }
+ } else {
+ /* some idiot pages have a *third* header line, possibly after a null line */
+ if (*header && scnt>MINMID) { strcpy(header3,p); ncnt=0; continue; }
+ /* indent of first line ("NAME") after header sets global indent */
+ /* check '<' for Plan 9(?) */
+ if (*p!='<') {
+ indent=scnt; I=I0; scnt=0;
+ } else continue;
+ }
+/* if (indent==-1) continue;*/
+ }
+ if (!lindent && scnt) lindent=scnt;
+/*printf("lindent = %d, scnt=%d\n",lindent,scnt);*/
+
+
+ /**** for each ordinary line... *****/
+
+ /*** skip over global indentation */
+ oempty=empty; empty=(linelen==0);
+ if (empty) {ncnt++; continue;}
+
+ /*** strip out per-page titles ***/
+
+ if (/*fMan && (*/scnt==0 || scnt>MINMID/*)*/) {
+/*printf("***ncnt = %d, fFoot = %d, line = %d***", ncnt,fFoot,AbsLine);*/
+ if (!fFoot && !isspace(*p) && (scnt>5 || (*p!='-' && *p!='_')) &&
+ /* don't add ncnt -- AbsLine gets absolute line number */
+ (((ncnt>=2 && AbsLine/*+ncnt*/>=61/*was 58*/ && AbsLine/*+ncnt*/<70)
+ || (ncnt>=4 && AbsLine/*+ncnt*/>=59 && AbsLine/*+ncnt*/<74)
+ || (ncnt && AbsLine/*+ncnt*/>=61 && AbsLine/*+ncnt*/<=66))
+ && (/*lookahead!=' ' ||*/ (s_cnt>=1 && s_avg>1.1) || !falluc) )
+ ) {
+ (*fn)(BEGINFOOTER);
+ /* grab footer and its first word */
+ strcpy(footer,p);
+/* if ((footer_m=linelen-HEADFOOTSKIP)<0) footer_m=0;*/
+ if ((footer_m=HEADFOOTSKIP)>linelen) footer_m=0;
+ /*grabphrase(p);*/ strcpy(foot,phrase); footlen=phraselen;
+ /* permit variations at end, as for SGI "Page N", but keep minimum length */
+ if (footlen>3) footlen--;
+ la_gets(buf); filterline(buf,plain); if (linelen) strcpy(footer2,plain);
+ title=1;
+ (*fn)(ENDFOOTER); tagc=0;
+
+ /* if no header on first page, try again after first footer */
+ if (!fFoot && *header=='\0') fHead=0; /* this is dangerous */
+ fFoot=1;
+ continue;
+ } else
+ /* a lot of work, but only for a few lines (about 4%) */
+ if (fFoot && (scnt==0 || scnt+indent>MINMID) &&
+ ( (headlen && strncmp(head,p,headlen)==0)
+ || strcmp(header2,p)==0 || strcmp(header3,p)==0
+ || (footlen && strncmp(foot,p,footlen)==0)
+ || strcmp(footer2,p)==0
+ /* try to recognize lines with dates and page numbers */
+ /* skip into line */
+ || (header_m && header_m<linelen &&
+ strncmp(&header[header_m],&p[header_m],HEADFOOTMAX)==0)
+ || (footer_m && footer_m<linelen &&
+ strncmp(&footer[footer_m],&p[footer_m],HEADFOOTMAX)==0)
+ /* skip into line allowing for off-by-one */
+ || (header_m && header_m<linelen &&
+ strncmp(&header[header_m],&p[header_m+1],HEADFOOTMAX)==0)
+ || (footer_m && footer_m<linelen &&
+ strncmp(&footer[footer_m],&p[footer_m+1],HEADFOOTMAX)==0)
+ /* or two */
+ || (header_m && header_m<linelen &&
+ strncmp(&header[header_m],&p[header_m+2],HEADFOOTMAX)==0)
+ || (footer_m && footer_m<linelen &&
+ strncmp(&footer[footer_m],&p[footer_m+2],HEADFOOTMAX)==0)
+ /* or with reflected odd and even pages */
+ || (headlen && headlen<linelen &&
+ strncmp(head,&p[linelen-headlen],headlen)==0)
+ || (footlen && footlen<linelen &&
+ strncmp(foot,&p[linelen-footlen],footlen)==0)
+ )) {
+ tagc=0; title=1; continue;
+ }
+
+ /* page numbers at end of line */
+ for(i=0; p[i] && isdigit(p[i]); i++)
+ /* empty */;
+ if (&p[i]!=plain && !p[i]) {title=1; fFoot=1; continue;}
+ }
+
+ /*** interline spacing ***/
+ /* multiple \n: paragraph mode=>new paragraph, line mode=>blank lines */
+ /* need to chop up lines for Roff */
+
+ /*tabgram[scnt]++;*/
+ if (title) ncnt=(scnt!=oscnt || (/*scnt<4 &&*/ isupper(*p)));
+ itabcnt = scnt/5;
+ if (CurLine==1) {ncnt=0; tagc=0;} /* gobble all newlines before first text line */
+ sect = (scnt==0 && isupper(*p));
+ subsect = (fSubsections && (scnt==2||scnt==3));
+ if ((sect || subsect) && ncnt>1) ncnt=1; /* single blank line between sections */
+ (*fn)(BEGINLINE);
+ if (/*fPara &&*/ ncnt) Pnew=1;
+ title=0; /*ncnt=0;--moved down*/
+ /*if (finTable) (*fn)(BEGINTABLELINE);*/
+ oscnt=scnt; /*fotable=finTable;*/
+
+/* let output modules decide what to do at the start of a paragraph
+ if (fPara && !Pnew && (prevcmd==BEGINBODY || prevcmd==BEGINBULTXT)) {
+ putchar(' '); I++;
+ }
+*/
+
+ /*** identify structural sections and notify fn */
+
+ /*if (fMan) {*/
+/* bulpair = (scnt<7 && (*p==c_bullet || *p=='-'));*/
+ /* decode the below */
+ bulpair = ((!auxindent || scnt!=lindent+auxindent) /*!bulpair*/
+ && ((scnt>=2 && scnt2>5) || scnt>=5 || (tagc>0 && tags[0].first==scnt) ) /* scnt>=2?? */
+ && (((*p==c_bullet || strchr("-+.",*p)!=NULL || falluc) && (ncnt || scnt2>4)) ||
+ (scnt2-s_avg>=2 && phrase[phraselen-1]!='.') ||
+ (scnt2>3 && s_cnt==1)
+ ));
+ if (bulpair) {
+ if (tagc>0 && tags[0].first==scnt) {
+ k=tags[0].last;
+ for (l=1; l<tagc; l++) {
+ if (tags[l].first - k <=3)
+ k=tags[l].last;
+ else break;
+ }
+ phraselen=k-scnt;
+ for (k=phraselen; plain[k]==' ' && k<linelen; k++) /* nothing */;
+ if (k>=5 && k<linelen) hanging=k; else hanging=-1;
+ } else if (scnt2) hanging=phraselen+scnt2;
+ else hanging=5;
+ } else hanging=0;
+
+/* hanging = bulpair? phraselen+scnt2 : 0;*/
+/*if (bulpair) printf("hanging = %d\n",hanging);*/
+ /* maybe, bulpair=0 would be best */
+ /*end fMan}*/
+
+ /* certain sections (subsections too?) special, like SEE ALSO */
+ /* to make canonical name as plain, all lowercase */
+ if (sect /*||subsect -- no widespread subsection names*/) {
+ for (j=0; (sectheadid=j)<RANDOM; j++) if (strcoloncmp2(plain,'\0',sectheadname[j],0)) break;
+ }
+
+ /* normalized section headers are put into mixed case */
+ if (/*fNORM &&*/falluc && (sect || subsect)) casify(plain);
+
+ if (sect) {
+ poppush(BEGINSECTION); (*fn)(BEGINSECTHEAD);
+ tocadd(plain, BEGINSECTION, CurLine);
+ } else if (subsect && !osubsect) {
+ poppush(BEGINSUBSECTION); (*fn)(BEGINSUBSECTHEAD);
+ tocadd(plain, BEGINSUBSECTION, CurLine);
+ } else if (bulpair) {
+ /* used to be just poppush(BEGINBULPAIR); */
+ if (!Pbp) poppush(BEGINBULPAIR);
+ (poppush)(BEGINBULLET);
+ fIP=1; /*grabphrase(plain);*/
+ } else if (Pnew) {
+ poppush(BEGINBODY);
+ }
+ Pnew=0;
+ oldsectheadid = sectheadid;
+
+
+ /* move change bars to left */
+ if (fChangeleft && !fNORM) {
+ if (fPara) (*fn)(CHANGEBAR);
+ /* replace initial spaces with changebars */
+ else for (i=0; i<ccnt; i++) { /*xputchar('|'); */ (*fn)(CHANGEBAR); }
+ }
+
+ /* show initial spaces */
+ if (!fIQS && fcharout) {
+ spaceout = (scnt>ccnt)?(scnt-ccnt):0;
+ if (fILQS) { if (spaceout>=lindent) spaceout-=lindent; else spaceout=0; }
+ if (auxindent) { if (spaceout>=auxindent) spaceout-=auxindent; else spaceout=0; }
+ if (fNORM) {
+ if (itabcnt>0) (*fn)(ITAB);
+ for (i=0; i<(scnt%5); i++) putchar(' ');
+ } else printf("%*s",spaceout,"");
+ }
+
+
+ /*** iterate over each character in line, ***/
+ /*** handling underlining, tabbing, copyrights ***/
+
+ off=(!fIQS&&!fPara)?scnt:0;
+ for (i=0, p=plain, curtag=0, fcont=0; *p; p++,i++,fcont=0) {
+ /* interspersed presentation signals */
+ /* start tags in reverse order of addition (so structural first) */
+ if (curtag<tagc && i+I0+off==tags[curtag].first) {
+ for (r=hitxt, j=tags[curtag].last-tags[curtag].first, hitxt[j]='\0'; j; j--)
+ hitxt[j-1]=p[j-1];
+ (*fn)(tagbeginend[tags[curtag].type][0]);
+ }
+
+ /* special characters */
+ switch(*p) {
+ case '"':
+ if (p==plain || isspace(p[-1])) { (*fn)(CHARLQUOTE); fcont=1; }
+ else if (isspace(p[1])) { (*fn)(CHARRQUOTE); fcont=1; }
+ break;
+ case '\'':
+ if (p==plain || isspace(p[-1])) { (*fn)(CHARLSQUOTE); fcont=1; }
+ else if (isspace(p[1])) { (*fn)(CHARRSQUOTE); fcont=1; }
+ break;
+ case '-':
+ /* check for -opt => \-opt */
+ if (p==plain || (isspace(p[-1]) && !isspace(p[1]))) {
+ (*fn)(CHARDASH); fcont=1;
+ }
+ break;
+ }
+
+ /* troublemaker characters */
+ c = (*p)&0xff;
+ if (!fcont && fcharout) {
+ if (strchr(escchars,c)!=NULL) {
+ putchar('\\'); putchar(c); I++;
+ } else if (strchr((char *)trouble,c)!=NULL) {
+ (*fn)(c); fcont=1;
+ } else {
+ putchar(c); I++;
+ }
+ }
+
+/*default:*/
+ if (curtag<tagc && i+I0+off+1==tags[curtag].last) {
+ (*fn)(tagbeginend[tags[curtag].type][1]);
+ curtag++;
+ }
+
+ if (fIP && ((*p==' ' && i==phraselen) || *p=='\0')) {
+ p++; /* needed but why? */
+ (*fn)(ENDBULLET); fIP=0;
+ if (*p!='\0') {
+ /*oscnt+=phraselen;*/
+ oscnt+=i;
+ for (r=p; *r==' '; r++) {
+ oscnt++;
+/*
+ i++;
+ if (fQS || !fcharout) p++;
+*/
+ }
+ }
+ p--; /* to counteract increment in loop */
+
+ poppush(BEGINBULTXT);
+ }
+ }
+
+
+ /*** end of line in buf[] ***/
+ /*** deal with section titles, hyperlinks ***/
+
+ if (sect) { (*fn)(ENDSECTHEAD); Pnew=1; }
+ else if (subsect) { (*fn)(ENDSUBSECTHEAD); Pnew=1; }
+ else if (fIP) { (*fn)(ENDBULLET); fIP=0; poppush(BEGINBULTXT); }
+/* oscnt not right here */
+ else if (scnt+linelen+spcsqz<MINRM /*&& ncnt*/ && lookahead!='\n'
+ && prevcmd!=BEGINBULTXT && prevcmd!=ENDSUBSECTHEAD && prevcmd!=ENDSUBSECTHEAD)
+ (*fn)(SHORTLINE);
+ osubsect=subsect;
+
+ /*if (finTable) (*fn)(ENDTABLELINE);*/
+ /*if (!fPara)*/ (*fn)(ENDLINE); tagc=0;
+ ncnt=0;
+ I0=I; /* save I here in case skipping lines screws it up */
+ }
+
+ /* wrap up at end */
+ pop(ENDDOC); /* clear up all tags on stack */
+ (*fn)(ENDDOC);
+}
+
+
+
+/*
+ * SOURCE CODE PARSING
+ * for better transcription short of full nroff interpreter
+ *
+ * Macros derived empirically, except for weird register ones that were looked up in groff
+ *
+ * to do
+ * X fix up output modules to be aware of Source: they need to do own formatting (Tk, ASCII, ...)
+ * X profile if's and reorder, or centralized id (fast enough already?),
+ * X how to format tables for Tk?
+ * + coalese lists, distinguish DL vs OL vs UL,
+ * + recognize more table ops (differences across flavors)
+ * make lines with tabs into tables (tabs make no sense to HTML)
+ *
+ * buffer usage
+ * buf = incoming text from man page file
+ * plain = "second pass" buffer used to identify man page references
+ *
+ * test pages
+ * Solaris: fdisk.1m, fcntl.2, curs_getwch.3x, locale.5 (numbered lists),
+ * getservbyname.3n (font size changes)
+ */
+
+/* macros */
+/* put as much in here, as opposed to in code, as possible.
+ less expensive and here they can be overridden by other macros */
+/*const int macromax=100; -- dumb compiler */
+#define MACROMAX 1000
+struct { char *key; char *subst; } macro[MACROMAX] = {
+ /* Solaris */
+ {"NA", ".SH NAME"},
+ {"SB", "\\s-2\\fB\\$1\\fR\\s0"},
+ /* HP-UX */
+#if 0
+ {"SM", "\\s-2\\$1\\s0"},
+ {"C", "\\f3\\$1\\fR"},
+ {"CR", "\\f3\\$1\\fR\\$2"},
+ {"CI", "\\f3\\$1\\fI\\$2\\fR"},
+ {"RC", "\\fR\\$1\\f3\\$2\\fR"},
+#endif
+ /* SGI -- doesn't ship man page source */
+
+ /* 4.4BSD - http://intergate.sonyinteractive.com/cgi-bin/manlink/7/mdoc */
+ /* scads more, but for them definition in -mandoc is sufficient */
+#if 0
+ {"Dt", ".TH \\$1 \\$2 \\$3"},
+ {"Sh", ".SH \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9"},
+ {"Ss", ".SS \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9"},
+ {"Pp", ".P"},
+ {"Nm", ".BR \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9"}, /* name */
+ {"Ar", ".IR \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9"},
+#endif
+ { NULL, NULL }
+};
+/* what all can be represented as a macro? */
+int macrocnt=-1; /* length of table counted at start */
+
+char *macnotfound[MACROMAX];
+int macnotcnt=0;
+
+#define SUBSTMAX 1000
+/* "*" or "*(" prefixed */
+struct { char *key; char *subst; } subst[SUBSTMAX] = {
+ {"rq", "'"}, {"lq", "`"}, {"L\"", "``"}, {"R\"", "''"},
+ {"L", "\\f3"}, {"E", "\\f2"}, {"V", "\\f4"}, {"O", "\\f1"}
+};
+int substcnt=8;
+
+#define REGISTERMAX 1000
+struct { char *name; char *value; } reg[REGISTERMAX];
+int regcnt=0;
+
+/* special characters */
+const struct { char key[4]; unsigned char subst[4]; } spec[] = {
+ { "**", "*" },
+ { "+-", { CHARPLUSMINUS, '\0' }},
+ { "12", { CHAR12, '\0' }},
+ { "14", { CHAR14, '\0' }},
+ { "34", { CHAR34, '\0' }},
+ { "aa", { CHARACUTE, '\0' }},
+ { "ap", "~" },
+ { "br", "|" },
+ { "bu", { CHARBULLET, '\0' }},
+ { "bv", "|" },
+ { "ci", "O" },
+ { "co", { CHARCOPYR, '\0' }},
+ { "ct", { CHARCENT, '\0' }},
+ { "de", { CHARDEG, '\0' }},
+ { "dg", { CHARDAGGER, '\0' }},
+ { "di", { CHARDIV, '\0' }},
+ { "em", "--" },
+ { "eq", "=" },
+ { "hy", "-" },
+ { "mi", "-" },
+ { "mu", { CHARMUL, '\0' }},
+ { "no", { CHARNOT, '\0' }},
+ { "or", "|" },
+ { "pl", "+" },
+ { "rg", { CHARREGTM, '\0' }},
+ { "ru", "_" },
+ { "sc", { CHARSECT, '\0' }},
+ { "sl", "/" },
+ { "ua", "^" },
+ { "ul", "_" }
+};
+#define speccnt (sizeof spec / sizeof spec[0])
+
+/* tbl line descriptions */
+char *tbl[20][20]; /* space enough for twenty description lines, twenty parts each */
+int tblc=0;
+int tbli;
+
+int fsourceTab = 0, fosourceTab=0;
+int supresseol=0;
+int finitDoc=0;
+int finlist=0;
+int sublevel=0;
+
+static char *
+source_gets(void)
+{
+ char *p,*q;
+ char *ret = (*in)?buf:NULL;
+ int i;
+ char *begin;
+ char tmpbuf[MAXBUF];
+ char name[3];
+
+ if (!sublevel) AbsLine++;
+
+ p = tmpbuf;
+ falluc = 1;
+ while (1) {
+ /* collect characters in line */
+ while (*in && *in!='\n') {
+ if (p[0]=='\\' && p[1]=='\n') p+=2; /* \<newline> */
+ falluc = falluc && !islower(*in);
+ *p++ = *in++;
+ }
+ if (*in) in++;
+ *p='\0';
+
+ /* normalize commands */
+ p=tmpbuf; q=buf; /* copy from tmpbuf to buf */
+ /* no spaces between command-initiating period and command letters */
+ if (*p=='\'') { *p='.'; } /* what's the difference? */
+ if (*p=='.') { *q++ = *p++; while (isspace(*p)) p++; }
+
+
+ /* convert lines with tabs to tables? */
+ fsourceTab=0;
+
+ /* if comment at start of line, OK */
+ /* dynamically determine iff Tcl/Tk page by scanning comments */
+ begin = p;
+ if (*p=='\\' && *(p+1)=='"') {
+ if (!fTclTk && strstr(p+1,"supplemental macros used in Tcl/Tk")!=NULL) fTclTk=1;
+ if (fTclTk)
+ p+=2;
+ }
+
+ while (*p) {
+ if (*p=='\t') fsourceTab++;
+ if (*p=='\\') {
+ p++;
+ if (*p=='n') {
+ p++;
+ if (*p=='(') {
+ p++; name[0]=*p++; name[1]=*p++; name[2]='\0';
+ } else {
+ name[0]=*p++; name[1]='\0';
+ }
+ *q='0'; *(q+1)='\0'; /* defaults to 0, in case doesn't exist */
+ for (i=0; i<regcnt; i++) {
+ if (strcmp(reg[i].name,name)==0) {
+ strcpy(q, reg[i].value);
+ break;
+ }
+ }
+ q+=strlen(q);
+ } else if (*p=='"' && (p != begin+1)) { /* comment in Digital UNIX, OK elsewhere? */
+ *p='\0';
+ q--; while (q>buf && isspace(*q)) q--; /* trim tailing whitespace */
+ q++; *q='\0';
+ } else {
+ /* verbatim character (often a backslash) */
+ *q++ = '\\'; /* postpone interpretation (not the right thing but...) */
+ *q++ = *p++;
+ }
+ } else *q++ = *p++;
+ }
+
+ /* dumb Digital--later */
+ /*if (q-3>plain && q[-1]=='{' && q[-2]=='\\' && q[-3]==' ') q[-3]='\n'; }*/
+
+ /* close off buf */
+ *q='\0';
+
+#if 0
+ if (q>buf && q[-1]=='\\' && *in=='.') /* append next line * / else break;*/
+#endif
+ break;
+ }
+
+ /*printf("*ret = |%s|\n", ret!=NULL?ret : "NULL");*/
+ return ret;
+}
+
+
+/* dump characters from buffer, signalling right tags along the way */
+/* all this work to introduce an internal second pass to recognize man page references */
+/* now for HTTP references too */
+
+int sI=0;
+/* use int linelen from up top */
+int fFlush=1;
+
+static void
+source_flush(void)
+{
+ int i,j;
+ char *p,*q,*r;
+ int c;
+ int manoff,posn;
+
+ if (!sI) return;
+ plain[sI] = '\0';
+
+ /* flush called often enough that all man page references are at end of text to be flushed */
+ /* find man page ref */
+ if (sI>=4/*+1*/ && (plain[sI-(manoff=1)-1]==')' || plain[sI-(manoff=0)-1]==')')) {
+ for (q=&plain[sI-manoff-1-1]; q>plain && isalnum(*q) && *q!='('; q--) /* nada */;
+ if (*q=='(' && strcoloncmp(&q[1],')',vollist)) {
+ r=q-1;
+ if (*r==' ' && (sectheadid==SEEALSO || /*single letter volume */ *(q+2)==')' || *(q+3)==')')) r--; /* permitted single intervening space */
+ for ( ; r>=plain && (isalnum(*r) || strchr(manvalid,*r)!=NULL); r--) /* nada */;
+ r++;
+ if (isalpha(*r) && r<q) {
+ /* got one: clear out tags and spaces to make normalized form */
+ posn = r-plain;
+ /*while (tagc && tags[tagc-1].first >= posn) tagc--;*/
+
+ /* add MANREF tags */
+ strcpy(hitxt,r);
+ tagadd(BEGINMANREF, posn, 0);
+ tagadd(ENDMANREF, sI-manoff-1+1, 0);
+ }
+ }
+
+ /* HTML hyperlinks */
+ } else if (fURL && sI>=4 && (p=strstr(plain,"http"))!=NULL) {
+ i = p-plain;
+ tagadd(BEGINMANREF, i, 0);
+ for (j=0; i<sI && !isspace(*p) && *p!='"' && *p!='>'; i++,j++) hitxt[j] = *p++;
+ hitxt[j]='\0';
+ tagadd(ENDMANREF, i, 0);
+ }
+
+ if (!fFlush) return;
+
+ /* output text */
+ for (i=0,j=0,p=plain; i<sI && *p; i++,p++) {
+ if (!linelen) (*fn)(BEGINLINE); /* issue BEGINLINE when know will be chars on line */
+
+ /* dump tags */
+ /*for ( ; j<tagc && tags[j].first == i; j++) (*fn)(tags[j].type);*/
+ for (j=0 ; j<tagc; j++) if (tags[j].first == i) (*fn)((enum command)tags[j].type);
+
+ /* dump text */
+ c = (*p)&0xff; /* just make c unsigned? */
+ if (strchr(escchars,c)!=NULL) {
+ xputchar('\\'); xputchar(c);
+ if (fcharout) linelen++;
+ } else if (strchr((char *)trouble,c)!=NULL) {
+ (*fn)(c);
+ } else if (linelen>=LINEBREAK && c==' ') { (*fn)(ENDLINE); linelen=0;
+ } else { /* normal character */
+ xputchar(c);
+ if (fcharout) linelen++;
+ }
+
+ /*if (linelen>=LINEBREAK && c==' ') { (*fn)(ENDLINE); linelen=0; } -- leaves space at end of line*/
+ }
+ /* dump tags at end */
+ /*for ( ; j<tagc && tags[j].first == sI; j++) (*fn)(tags[j].type);*/
+ for (j=0 ; j<tagc; j++) if (tags[j].first==sI) (*fn)((enum command)tags[j].type);
+
+ sI=0; tagc=0;
+}
+
+
+/* source_out stuffs characters in a buffer */
+static char *
+source_out0(const char *pin, char end)
+{
+ /* stack of character formattings */
+ static enum tagtype styles[20];
+ static int style=-1;
+ int funwind=0;
+ int i, j;
+ int len;
+ int sign;
+ char *p, *pstart;
+
+ pstart = p = mystrdup(pin);
+ while (*p && *p!=end) {
+ if (*p=='\\') { /* escape character */
+ switch (*++p) {
+
+ case '&': /* no space. used as a no-op sometimes */
+ case '^': /* 1/12 em space */
+ case '|': /* 1/6 em space */
+ case '%': /* hyphenation indicator */
+ /* just ignore it */
+ p++;
+ break;
+ case '0': /* digit width space */
+ p++;
+ sputchar(' ');
+ break;
+ case ' ': /* unpaddable space */
+ stagadd(CHARNBSP); /* nonbreaking space */
+ /*sputchar(' ');*/
+ p++;
+ break;
+ case 's': /* font size change */
+ p++;
+ sign=1;
+ if (*p=='-' || *p=='+') if (*p++=='-') sign=-1;
+ intArg = sign * ((*p++)-'0');
+ if (intArg==0) intArg = -fontdelta; /* s0 returns to normal height */
+ if (fontdelta || intArg) { source_flush(); (*fn)(FONTSIZE); }
+ break;
+ case 'v': /* vertical motion */
+ case 'h': /* horizontal motion */
+ case 'L': /* vertical line */
+ case 'l': /* horizontal line */
+ /* ignore */
+ p++;
+ if (*p=='\'') { p++; while (*p++!='\''); }
+ break;
+ case '"': /* comment */
+ *p='\0'; /* rest of line is comment */
+ break;
+ case 'f':
+ p++;
+ switch (*p++) {
+ case '3': case 'B': /* boldface */
+ styles[++style] = BOLD;
+ stagadd(BEGINBOLD);
+ break;
+ case '2': case 'I': /* italics */
+ styles[++style] = ITALICS;
+ stagadd(BEGINITALICS);
+ break;
+ case '4': /* bolditalics mode => program code */
+ styles[++style] = BOLDITALICS;
+ stagadd(BEGINBOLDITALICS);
+ break;
+ case '1': case '0': case 'R': case 'P': /* back to Roman */
+ /*sputchar(' '); -- taken out; not needed, I hope */
+ funwind=1;
+ break;
+ case '-':
+ p++;
+ break;
+ }
+ break;
+ case '(': /* multicharacter macros */
+ p++;
+ for (i=0; (unsigned)i<speccnt; i++) {
+ if (p[0]==spec[i].key[0] && p[1]==spec[i].key[1]) {
+ p+=2;
+ for (j=0; spec[i].subst[j]; j++) sputchar(spec[i].subst[j]);
+ break;
+ }
+ }
+ break;
+ case '*': /* strings */
+ p++;
+ if (*p!='(') { /* single character */
+ for (i=0; i<substcnt; i++) {
+ if (*p==subst[i].key[0] && subst[i].key[1]=='\0') {
+ source_out0(subst[i].subst,'\0');
+ break;
+ }
+ }
+ p++;
+ } else { /* multicharacter macros */
+ p++;
+ for (i=0; i<substcnt; i++) {
+ len = strlen(subst[i].key);
+ if (strncmp(p,subst[i].key,len)==0) {
+ source_out0(subst[i].subst,'\0');
+ p+=len;
+ break;
+ }
+ }
+ }
+ break;
+#if 0
+ case '|':
+ stagadd(CHARNBSP); /* nonbreaking space */
+#if 0
+ sputchar(' ');
+#endif
+ p++;
+#endif
+ case 'e': /* escape */
+ sputchar('\\');
+ p++;
+ break;
+ case 'c':
+ /* supress following carriage return-induced space */
+ /* handled in source_gets(); ignore within line => can't because next line might start with a command */
+ supresseol=1;
+ p++;
+ break;
+ case '-': /* minus sign */
+ sputchar(CHARDASH);
+ p++;
+ break;
+#if 0
+ case '^':
+ /* end stylings? (found in Solaris) */
+ p++;
+#endif
+ case 'N':
+ p++;
+ if (*p == '\'') {
+ char *tmp;
+ p++;
+ if ((tmp = strchr(p, '\'')) != NULL) {
+ sputchar(atoi(p));
+ p = tmp + 1;
+ }
+ }
+ break;
+ default: /* unknown escaped character */
+ sputchar(*p++);
+ }
+
+ } else { /* normal character */
+ if (*p) sputchar(*p++);
+ }
+
+
+ /* unwind character formatting stack */
+ if (funwind) {
+ for ( ; style>=0; style--) {
+ if (styles[style]==BOLD) {
+ stagadd(ENDBOLD);
+ } else if (styles[style]==ITALICS) {
+ stagadd(ENDITALICS);
+ } else {
+ stagadd(ENDBOLDITALICS);
+ }
+ } /* else error */
+ assert(style==-1);
+
+ funwind=0;
+ }
+
+ /* check for man page reference and flush buffer if safe */
+ /* postpone check until after following character so catch closing tags */
+ if ((sI>=4+1 && plain[sI-1-1]==')') ||
+ /* (plain[sI-1]==' ' && (q=strchr(plain,' '))!=NULL && q<&plain[sI-1])) */
+ (plain[sI-1]==' ' && !isalnum(plain[sI-1-1]))) {
+ /* regardless, flush buffer */
+ source_flush();
+ }
+ }
+
+ if (*p && *p!=' ') p++; /* skip over end character */
+ free(pstart);
+ return (char *)pin + (p - pstart);
+
+}
+
+/* oh, for function overloading. inlined by compiler, probably */
+static char *
+source_out(const char *p)
+{
+ return source_out0(p,'\0');
+}
+
+
+static char *
+source_out_word(const char *p)
+{
+ char end = ' ';
+
+ while (*p && isspace(*p)) p++;
+ if (*p=='"' /* || *p=='`' ? */) {
+ end = *p;
+ p++;
+ }
+ p = source_out0(p,end);
+ /*while (*p && isspace(*p)) p++;*/
+ return (char *)p;
+}
+
+
+static void
+source_struct(enum command cmd)
+{
+ source_out("\\fR\\s0"); /* don't let run-on stylings run past structural units */
+ source_flush();
+ if (cmd==SHORTLINE) linelen=0;
+ (*fn)(cmd);
+}
+
+#define checkcmd(str) strcmp(cmd,str)==0
+
+int finnf=0;
+
+static void source_line(char *p);
+
+static void
+source_subfile(char *newin)
+{
+ char *p;
+ char *oldin = in;
+
+ sublevel++;
+
+ in = newin;
+ while ((p=source_gets())!=NULL) {
+ source_line(p);
+ }
+ in = oldin;
+
+ sublevel--;
+}
+
+/* have to delay acquisition of list tag */
+static void
+source_list(void)
+{
+ static int oldlisttype; /* OK to have just one because nested lists done with RS/RE */
+ char *q;
+ int i;
+
+ /* guard against empty bullet */
+ for (i=0, q=plain; i<sI && isspace(*q); q++,i++) /* empty */;
+ if (i==sI) return;
+
+ assert(finlist);
+
+ fFlush=1;
+
+ /* try to determine type of list: DL, OL, UL */
+ q=plain; plain[sI]='\0';
+ if (((int)*q&0xff)==CHARBULLET /*||*/) {
+ listtype=UL;
+ q+=4;
+ } else {
+ if (strchr("[(",*q)) q++;
+ while (isdigit(*q)) { listtype=OL; q++; } /* I hope this gives the right number */
+ if (*q=='.') q++;
+ if (strchr(")]",*q)) q++;
+ if (*q=='.') q++;
+ while (isspace(*q)) q++;
+ if (*q) listtype=DL;
+ }
+ oldlisttype = listtype;
+
+ /* interpretation left to output formats based on listtype (HTML: DL, OL, UL) */
+ i = sI; sI=0;
+ if (!Pbp || listtype!=oldlisttype) poppush(BEGINBULPAIR);
+ poppush(BEGINBULLET);
+ /*if (tphp) source_line(p); else source_out_word(p);*/
+ /*if (listtype!=OL && listtype!=UL)*/ sI=i;
+ source_struct(ENDBULLET); Pbul=0; /* handled immediately below */
+ poppush(BEGINBULTXT);
+
+ finlist=0;
+}
+
+static int inComment=0;
+static int isComment=0;
+
+static void
+source_command(char *p)
+{
+ static int lastif=1;
+ int mylastif;
+ char *cmd=p;
+ char *q;
+ int i,j,endch;
+ int fid;
+ struct stat fileinfo;
+ char *sobuf;
+ char *macroArg[9];
+ char endig[10];
+ int err=0;
+ char ch;
+ int tphp=0;
+ int ie=0;
+ int cond,invcond=0;
+ char delim,op;
+ char if0[80], if1[80];
+ float nif0, nif1;
+ int insertat;
+ char macrobuf[MAXBUF]; /* local so can have nested macros */
+ static char ft='\0';
+ static int fTableCenter=0;
+
+ /* should centralize command matching (binary search?), pointer bumping here
+ if for no other reason than to catch conflicts -- and allow overrides? */
+ /* parse out command */
+ while (*p && !isspace(*p)) p++;
+ if (*p) { *p='\0'; p++; }
+ /* should set up argv, argc for command arguments--it's regular enough that everyone doesn't have to do it itself */
+
+ isComment = (/*checkcmd("") ||*/ !strncmp(cmd, "\\\"", 2) || /*DEC triple dot*/checkcmd(".."));
+ if (inComment && !isComment) { source_struct(ENDCOMMENT); inComment=0; } /* special case to handle transition */
+
+ if (isComment) {
+ /* maybe have BEGINCOMMENT, ENDCOMMENT, COMMENTLINE */
+ supresseol=0;
+ if (!inComment) { source_flush(); source_struct(BEGINCOMMENT); inComment=1; }
+ source_struct(COMMENTLINE);
+ printf("%s\n", p); /* could contain --> or other comment closer, but unlikely */
+
+ /* structural commands */
+ } else if (checkcmd("TH")) {
+ /* sample: .TH CC 1 "Dec 1990" */
+ /* overrides command line -- should fix this */
+ if (!finitDoc) {
+ while (isspace(*p)) p++;
+ if (*p) {
+ q=strchr(p, ' ');
+ if (q!=NULL)
+ {
+ *q++='\0';
+ strcpy(manName, p);
+ for (p=q; isspace(*p); p++) /*nada*/;
+ if (*p) {
+ q=strchr(p,' ');
+ if (q!=NULL) *q++='\0';
+ strcpy(manSect, p);
+ }
+ }
+ }
+ sI=0;
+ finitDoc=1;
+ (*fn)(BEGINDOC);
+ /* emit information in .TH line? */
+ } /* else complain about multiple definitions? */
+
+ } else if (checkcmd("SH") || checkcmd("Sh")) { /* section title */
+ while (indent) { source_command("RE"); }
+ source_flush();
+
+ pop(BEGINSECTION); /* before reset sectheadid */
+
+ if (*p) {
+ if (*p=='"') { p++; q=p; while (*q && *q!='"') q++; *q='\0'; }
+ finnf=0;
+ for (j=0; (sectheadid=j)<RANDOM; j++) if (strcoloncmp2(p,'\0',sectheadname[j],0)) break;
+ if (!finitDoc) {
+ /* handle missing .TH */
+ /* if secthead!=NAME -- insist on this?
+ fprintf(stderr, "Bogus man page: no .TH or \".SH NAME\" lines\n");
+ exit(1);
+ */
+ (*fn)(BEGINDOC);
+ finitDoc=1;
+ }
+ poppush(BEGINSECTION); source_struct(BEGINSECTHEAD);
+ fFlush=0;
+ if (falluc) casify(p);
+ source_out(p); /* people forget the quotes around multiple words */
+ while (isspace(plain[--sI])) /*nada*/;
+ plain[++sI]='\0'; tocadd(plain, BEGINSECTION, CurLine); /* flushed with source_struct above */
+ fFlush=1;
+ source_struct(ENDSECTHEAD);
+ }
+ } else if (checkcmd("SS")) { /* subsection title */
+ while (indent) { source_command("RE"); }
+ source_flush();
+
+ if (*p) {
+ if (*p=='"') { p++; q=p; while (*q && *q!='"') q++; *q='\0'; }
+ finnf=0;
+ source_flush();
+ poppush(BEGINSUBSECTION); source_struct(BEGINSUBSECTHEAD);
+ fFlush=0;
+
+ if (falluc) casify(p);
+ source_out(p); /* people forget the quotes around multiple words */
+ while (isspace(plain[--sI])) /*nada*/;
+ plain[++sI]='\0'; tocadd(plain, BEGINSUBSECTION, CurLine);
+ fFlush=1;
+ source_struct(ENDSUBSECTHEAD);
+ }
+
+ } else if (checkcmd("P") || checkcmd("PP") || checkcmd("LP")) { /* new paragraph */
+ source_flush();
+ poppush(BEGINBODY);
+
+ } else if ((tphp=checkcmd("TP")) || (tphp=checkcmd("HP")) || checkcmd("IP") || checkcmd("LI")) {
+ /* TP, HP: indented paragraph, tag on next line (DL list) */
+ /* IP, LI: tag as argument */
+ source_flush();
+ fFlush=0;
+ finlist=1;
+ if (!tphp) { source_out_word(p); source_list(); }
+ /* lists terminated only at start of non-lists */
+ } else if (checkcmd("RS")) { /* set indent */
+ source_struct(BEGININDENT);
+ indent++;
+ } else if (checkcmd("RE")) {
+ if (indent) indent--;
+ pop(ENDINDENT);
+ source_struct(ENDINDENT);
+#if 0
+ } else if (checkcmd("Xr")) {
+ /* 4.4BSD man ref */
+ supresseol=0;
+ p=source_out_word(p);
+ source_out("(");
+ p=source_out_word(p);
+ source_out(")");
+#endif
+
+ } else if (checkcmd("nf")) {
+ source_struct(SHORTLINE);
+ finnf=1;
+ source_struct(BEGINCODEBLOCK);
+ } else if (checkcmd("fi")) {
+ source_struct(ENDCODEBLOCK);
+ finnf=0;
+ } else if (checkcmd("br")) {
+ source_struct(SHORTLINE);
+ } else if (checkcmd("sp") || checkcmd("SP")) { /* blank lines */
+ /*if (!finTable) {*/
+ if (finnf) source_struct(SHORTLINE); else source_struct(BEGINBODY);
+ /*}*/
+ } else if (checkcmd("ta")) { /* set tab stop(s?) */
+ /* argument is tab stop -- handle these as tables => leave to output format */
+ /* HTML handles tables but not tabs, Tk's text tabs but not tables */
+ /* does cause a linebreak */
+ stagadd(BEGINBODY);
+ } else if (checkcmd("ce")) {
+ /* get line count, recursively filter for that many lines */
+ if (sscanf(p, "%d", &i)) {
+ source_struct(BEGINCENTER);
+ for (; i>0 && (p=source_gets())!=NULL; i--) source_line(p);
+ source_struct(ENDCENTER);
+ }
+
+ /* limited selection of control structures */
+ } else if (checkcmd("if") || (checkcmd("ie"))) { /* if <test> cmd, if <test> command and else on next line */
+ supresseol=1;
+ ie = checkcmd("ie");
+ mylastif=lastif;
+
+ if (*p=='!') { invcond=1; p++; }
+
+ if (*p=='n') { cond=1; p++; } /* masquerading as nroff the right thing to do? */
+ else if (*p=='t') { cond=0; p++; }
+ else if (*p=='(' || *p=='-' || *p=='+' || isdigit(*p)) {
+ if (*p=='(') p++;
+ nif0=atof(p);
+ if (*p=='-' || *p=='+') p++; while (isdigit(*p)) p++;
+ op = *p++; /* operator: =, >, < */
+ if (op==' ') {
+ cond = (nif0!=0);
+ } else {
+ nif1=atoi(p);
+ while (isdigit(*p)) p++;
+ if (*p==')') p++;
+ if (op=='=') cond = (nif0==nif1);
+ else if (op=='<') cond = (nif0<nif1);
+ else /* op=='>' -- ignore >=, <= */ cond = (nif0>nif1);
+ }
+ } else if (!isalpha(*p)) { /* usually quote, ^G in Digital UNIX */
+ /* gobble up comparators between delimiters */
+ delim = *p++;
+ q = if0; while (*p!=delim) { *q++=*p++; } *q='\0'; p++;
+ q = if1; while (*p!=delim) { *q++=*p++; } *q='\0'; p++;
+ cond = (strcmp(if0,if1)==0);
+ } else cond=0; /* a guess, seems to be right bettern than half the time */
+ if (invcond) cond=1-cond;
+ while (isspace(*p)) p++;
+
+ lastif = cond;
+ if (strncmp(p,"\\{",2)==0) { /* rather than handle groups here, have turn on/off output flag? */
+ p+=2; while (isspace(*p)) p++; /* {{ */
+ while (strncmp(p,".\\}",3)!=0 || strncmp(p,"\\}",2)!=0 /*Solaris*/) {
+ if (cond) source_line(p);
+ if ((p=source_gets())==NULL) break;
+ }
+ } else if (cond) source_line(p);
+
+ if (ie) source_line(source_gets()); /* do else part with prevailing lastif */
+
+ lastif=mylastif;
+
+ } else if (checkcmd("el")) {
+ mylastif=lastif;
+
+ /* should centralize gobbling of groups */
+ cond = lastif = !lastif;
+ if (strncmp(p,"\\{",2)==0) {
+ p+=2; while (isspace(*p)) p++;
+ while (strncmp(p,".\\}",3)!=0 || strncmp(p,"\\}",2)!=0 /*Solaris*/) {
+ if (cond) source_line(p);
+ if ((p=source_gets())==NULL) break;
+ }
+ } else if (cond) source_line(p);
+
+ lastif=mylastif;
+
+ } else if (checkcmd("ig")) { /* "ignore group" */
+ strcpy(endig,".."); if (*p) { endig[0]='.'; strcpy(&endig[1],p); }
+ while ((p=source_gets())!=NULL) {
+ if (strcmp(p,endig)==0) break;
+ if (!lastif) source_line(p); /* usually ignore line, except in one weird case */
+ }
+
+
+ /* macros and substitutions */
+ } else if (checkcmd("de")) {
+ /* grab key */
+ q=p; while (*q && !isspace(*q)) q++; *q='\0';
+
+ /* if already have a macro of that name, override it */
+ /* could use a good dictionary class */
+ for (insertat=0; insertat<macrocnt; insertat++) {
+ if (strcmp(p,macro[insertat].key)==0) break;
+ }
+ if (insertat==macrocnt) macrocnt++;
+
+ /* should replace one with same name, if one exists */
+ macro[insertat].key = mystrdup(p);
+
+ /* build up macro in plain[] ... */
+ /* everything until ".." line part of macro */
+ q=plain; i=0;
+ while ((p=source_gets())!=NULL) {
+ if (strcmp(p,"..")==0) break;
+ while (*p) { /* append string, interpreting quotes along the way--just double backslash to single now */
+ if (*p=='\\' && p[1]=='\\') p++;
+ *q++=*p++;
+ }
+ *q++='\n';
+ }
+ *q='\0';
+
+ /* ... then copy once have whole thing */
+ macro[insertat].subst = mystrdup(plain);
+ /*fprintf(stderr, "defining macro %s as %s\n", macro[insertat].key, macro[insertat].subst);*/
+ sI=0;
+
+ } else if (checkcmd("rm")) { /* remove macro definition, can have multiple arguments */
+ for (i=0; i<macrocnt; i++) { /* moot as new definitions replace old when conflicts */
+ if (strcmp(p,macro[i].key)) {
+ macro[i] = macro[--macrocnt];
+ break;
+ }
+ }
+
+ } else if (checkcmd("ds")) { /* text substitutions (like macros) */
+ /* /usr/sww/man/man1/CC.1 a good test of this */
+ q = strchr(p,' ');
+ if (q!=NULL) {
+ *q='\0'; q++;
+#if 0
+ while (*++q) /*nada*/;
+#endif
+ if (*q=='"') q++;
+ if (substcnt<SUBSTMAX) {
+ subst[substcnt].key = mystrdup(p); subst[substcnt].subst = mystrdup(q); substcnt++;
+ }
+ /*fprintf(stderr, "defining substitution: name=%s, body=%s\n", p, q);*/
+ }
+
+ } else if (checkcmd("so")) {
+ /* assuming in .../man like nroff, source in file and execute it as nested file, */
+ /* so nested .so's OK */
+
+ err = 1; /* assume error unless successful */
+ if (fTclTk) {
+ err=0;
+ } else if (stat(p, &fileinfo)==0) {
+ sobuf = malloc(fileinfo.st_size + 1);
+ if (sobuf!=NULL) {
+ /* suck in entire file */
+ fid = open(p, O_RDONLY);
+ if (fid!=-1) {
+ if (read(fid, sobuf, fileinfo.st_size) == fileinfo.st_size) {
+ sobuf[fileinfo.st_size]='\0';
+ /* dumb Digital puts \\} closers on same line */
+ /* {{ */
+ for (q=sobuf; (q=strstr(q," \\}"))!=NULL; q+=3) *q='\n';
+ source_subfile(sobuf);
+ err = 0;
+ }
+ close(fid);
+ }
+ free(sobuf);
+ }
+ }
+
+ if (err) {
+ fprintf(stderr, "%s: couldn't read in referenced file %s.\n", argv0, p);
+ if (strchr(p,'/')==NULL) {
+ fprintf(stderr, "\tTry cd'ing into same directory of man page first.\n");
+ } else if (strchr(p,'/')==strrchr(p,'.')) {
+ fprintf(stderr, "\tTry cd'ing into parent directory of man page first.\n");
+ } else {
+ fprintf(stderr, "\tTry cd'ing into ancestor directory that makes relative path valid first.\n");
+ }
+ exit(1);
+ }
+
+
+ /* character formatting */
+ /* reencode m/any as macro definitions? would like to but the below don't have "words" */
+ } else if (checkcmd("ft")) { /* change font, next char is R,I,B. P=previous not supported */
+ if (ft=='B') stagadd(ENDBOLD); else if (ft=='I') stagadd(ENDITALICS);
+ ft = *p++;
+ if (ft=='B') stagadd(BEGINBOLD); else if (ft=='I') stagadd(BEGINITALICS);
+ } else if (checkcmd("B")) {
+ supresseol=0;
+ stagadd(BEGINBOLD); p = source_out_word(p); source_out(p); stagadd(ENDBOLD);
+ if (finnf) source_struct(SHORTLINE);
+ } else if (checkcmd("I")) {
+ supresseol=0;
+ stagadd(BEGINITALICS); p = source_out_word(p); stagadd(ENDITALICS);
+ source_out(p);
+ if (finnf) source_struct(SHORTLINE);
+ } else if (checkcmd("BI")) {
+ supresseol=0;
+ while (*p) {
+ stagadd(BEGINBOLD); p = source_out_word(p); stagadd(ENDBOLD);
+ if (*p) { stagadd(BEGINITALICS); p = source_out_word(p); stagadd(ENDITALICS); }
+ }
+ if (finnf) source_struct(SHORTLINE);
+ } else if (checkcmd("IB")) {
+ supresseol=0;
+ while (*p) {
+ stagadd(BEGINITALICS); p = source_out_word(p); stagadd(ENDITALICS);
+ if (*p) { stagadd(BEGINBOLD); p = source_out_word(p); stagadd(ENDBOLD); }
+ }
+ if (finnf) source_struct(SHORTLINE);
+ } else if (checkcmd("RB")) {
+ supresseol=0;
+ while (*p) {
+ p = source_out_word(p);
+ if (*p) { stagadd(BEGINBOLD); p = source_out_word(p); stagadd(ENDBOLD); }
+ }
+ if (finnf) source_struct(SHORTLINE);
+ } else if (checkcmd("BR")) {
+ supresseol=0;
+ while (*p) {
+ stagadd(BEGINBOLD); p = source_out_word(p); stagadd(ENDBOLD);
+ p = source_out_word(p);
+ }
+ if (finnf) source_struct(SHORTLINE);
+ } else if (checkcmd("IR")) {
+ supresseol=0;
+ while (*p) {
+ stagadd(BEGINITALICS); p=source_out_word(p); stagadd(ENDITALICS);
+ p=source_out_word(p);
+ }
+ if (finnf) source_struct(SHORTLINE);
+ } else if (checkcmd("RI")) {
+ supresseol=0;
+ while (*p) {
+ p=source_out_word(p);
+ stagadd(BEGINITALICS); p=source_out_word(p); stagadd(ENDITALICS);
+ }
+ if (finnf) source_struct(SHORTLINE);
+
+
+ /* HP-UX */
+ } else if (checkcmd("SM")) {
+ supresseol=0; source_out("\\s-1"); while (*p) p=source_out(p); source_out("\\s0");
+ } else if (checkcmd("C")) {
+ supresseol=0;
+ stagadd(BEGINCODE); while (*p) p=source_out_word(p); stagadd(ENDCODE);
+ } else if (checkcmd("CR")) {
+ supresseol=0;
+ while (*p) {
+ stagadd(BEGINCODE); p=source_out_word(p); stagadd(ENDCODE);
+ if (*p) p=source_out_word(p);
+ }
+ } else if (checkcmd("RC")) {
+ supresseol=0;
+ while (*p) {
+ p=source_out_word(p);
+ if (*p) { stagadd(BEGINCODE); p=source_out_word(p); stagadd(ENDCODE); }
+ }
+ } else if (checkcmd("CI")) {
+ supresseol=0;
+ while (*p) {
+ stagadd(BEGINCODE); p=source_out_word(p); stagadd(ENDCODE);
+ if (*p) { stagadd(BEGINITALICS); p=source_out_word(p); stagadd(ENDITALICS); }
+ }
+
+
+ /* tables */
+ } else if (checkcmd("TS")) {
+ tblc=0; /*tblspanmax=0;*/ tableSep='\0'; /* need to reset each time because tabbed lines (.ta) made into tables too */
+ while ((p = source_gets())!=NULL) {
+ if ((q=strstr(p,"tab"))!=NULL) { /* "tab(" or "tab (". table entry separator */
+ p=(q+3); while (isspace(*p)) p++;
+ p++; /* jump over '(' */
+ tableSep=*p;
+ continue;
+ }
+ if (strincmp(p,"center",strlen("center"))==0) { /* center entire table; should look for "left" and "right", probably */
+ fTableCenter=1; source_struct(BEGINCENTER);
+ p+=strlen("center"); while (isspace(*p)) p++;
+ continue;
+ }
+ if (p[strlen(p)-1]==';') { tblc=0; continue; } /* HP has a prequel terminated by ';' */
+
+ for (i=0; *p; i++,p=q) {
+ if (*p=='.') break;
+ if (*p=='f') p+=2; /* DEC sets font here */
+ q=p+1;
+ if (strchr("lrcn",*q)==NULL) { /* dumb DEC doesn't put spaces between them */
+ while (*q && *q!='.' && !isspace(*q)) q++;
+ }
+ ch=*q; *q='\0';
+ tbl[tblc][i] = mystrdup(p);
+ tbl[tblc][i+1] = ""; /* mark end */
+ *q=ch;
+ while (*q && isspace(*q)) q++;
+ }
+ /*if (i>tblspanmax) tblspanmax=i;*/
+ tbl[tblc++][i]=""; /* mark end */
+ if (*p=='.') break;
+ }
+ tbli=0;
+ source_struct(BEGINTABLE);
+
+ while ((p=source_gets())!=NULL) {
+ if (strncmp(p,".TE",3)==0) break;
+ if (*p=='.') { source_line(p); continue; }
+
+ /* count number of entries on line. if >1, can use to set tableSep */
+ insertat=0; for (j=0; *tbl[tbli][j]; j++) if (*tbl[tbli][j]!='s') insertat++;
+ if (!tableSep && insertat>1) { if (fsourceTab) tableSep='\t'; else tableSep='@'; }
+ source_struct(BEGINTABLELINE);
+ if (strcmp(p,"_")==0 || /* double line */ strcmp(p,"=")==0) {
+ source_out(" ");
+ /*stagadd(HR);*/ /* empty row -- need ROWSPAN for HTML */
+ continue;
+ }
+
+ for (i=0; *tbl[tbli][i] && *p; i++) {
+ tblcellspan=1;
+ tblcellformat = tbl[tbli][i];
+ if (*tblcellformat=='^') { /* vertical span => blank entry */
+ tblcellformat="l";
+ } else if (*tblcellformat=='|') {
+ /* stagadd(VBAR); */
+ continue;
+ } else if (strchr("lrcn", *tblcellformat)==NULL) {
+ tblcellformat="l";
+ /*continue;*/
+ }
+
+ while (strncmp(tbl[tbli][i+1],"s",1)==0) { tblcellspan++; i++; }
+
+ source_struct(BEGINTABLEENTRY);
+ if (toupper(tblcellformat[1])=='B') stagadd(BEGINBOLD);
+ else if (toupper(tblcellformat[1])=='I') stagadd(BEGINITALICS);
+ /* not supporting DEC's w(<num><unit>) */
+
+ if (strcmp(p,"T{")==0) { /* DEC, HP */
+ while (strncmp(p=source_gets(),"T}",2)!=0) source_line(p);
+ p+=2; if (*p) p++;
+ } else {
+ p = source_out0(p, tableSep);
+ }
+ if (toupper(tblcellformat[1])=='B') stagadd(ENDBOLD);
+ else if (toupper(tblcellformat[1])=='I') stagadd(ENDITALICS);
+ source_struct(ENDTABLEENTRY);
+ }
+ if (tbli+1<tblc) tbli++;
+ source_struct(ENDTABLELINE);
+ }
+ source_struct(ENDTABLE);
+ if (fTableCenter) { source_struct(ENDCENTER); fTableCenter=0; }
+
+
+ } else if (checkcmd("nr")) {
+ q=p; while (*q && !isspace(*q)) q++; *q='\0'; q++;
+
+ for (insertat=0; insertat<regcnt; insertat++) {
+ if (strcmp(reg[insertat].name,p)==0) break;
+ }
+ if (insertat==regcnt) { regcnt++; reg[insertat].name = mystrdup(p); } /* else use same name */
+ p=q;
+ if (*q=='+' || *q=='-') q++; /* accept signed, floating point numbers */
+ if (*q=='.') q++;
+ if (!*q || isspace(*q)) { *q++='0'; *q++='\0'; }
+ while (isdigit(*q)) { q++; } *q='\0'; /* ignore units */
+ reg[insertat].value = mystrdup(p);
+
+ } else if (checkcmd("EQ")) { /* eqn not supported */
+ source_out("\\s-1\\fBeqn not supported\\fR\\s0");
+ while ((p=source_gets())!=NULL) {
+ if (strncmp(p,".EN",3)==0) break;
+ }
+
+
+
+ /* Tcl/Tk macros */
+ } else if (fTclTk && (checkcmd("VS") || checkcmd("VE"))) {
+ /* nothing for sidebars */
+ } else if (fTclTk && checkcmd("OP")) {
+ source_struct(BEGINBODY);
+ for (i=0; i<3; i++) {
+ if (fcharout) { source_out(tcltkOP[i]); source_out(": "); }
+ stagadd(BEGINBOLD); p=source_out_word(p); stagadd(ENDBOLD);
+ source_struct(SHORTLINE);
+ }
+ source_struct(BEGINBODY);
+
+ } else if (fTclTk && checkcmd("BS")) { /* box */
+ /*source_struct(HR); -- ugh, no Ouster box */
+ } else if (fTclTk && checkcmd("BE")) {
+ /*source_struct(HR);*/
+
+ } else if (fTclTk && (checkcmd("CS")||checkcmd("DS"))) { /* code excerpt */
+ /* respect line ends, set in teletype */
+ /* source_struct(SHORTLINE); -- done as part of CS's ENDLINE */
+ finnf=1;
+ source_struct(SHORTLINE);
+ if (checkcmd("DS")) source_line(".P");
+ stagadd(BEGINCODE);
+ } else if (fTclTk && (checkcmd("CE")||checkcmd("DE"))) {
+ stagadd(ENDCODE);
+ finnf=0;
+
+ } else if (fTclTk && checkcmd("SO")) {
+ source_struct(BEGINSECTION);
+ source_struct(BEGINSECTHEAD); source_out("STANDARD OPTIONS"); source_struct(ENDSECTHEAD);
+ tblc=1; tbl[0][0]=tbl[0][1]=tbl[0][2]="l"; tbl[0][3]="";
+ source_struct(BEGINTABLE);
+ while (1) {
+ p = source_gets();
+ if ((strncmp(p,".SE",3))==0) break;
+ tblcellformat = "l";
+ source_struct(BEGINTABLELINE);
+ if (*p=='.') {
+ source_command(p);
+ } else {
+ while (*p) {
+ source_struct(BEGINTABLEENTRY);
+ p = source_out0(p, '\t');
+ source_struct(ENDTABLEENTRY);
+ }
+ }
+ source_struct(ENDTABLELINE);
+ }
+ source_struct(ENDTABLE);
+ source_struct(ENDSECTION);
+
+ } else if (fTclTk && checkcmd("AP")) { /* arguments */
+ source_struct(BEGINBODY);
+ p = source_out_word(p); source_out(" ");
+ stagadd(BEGINITALICS); p = source_out_word(p); stagadd(ENDITALICS); source_out("\t");
+ source_out("("); p = source_out_word(p); source_out(")");
+ source_struct(SHORTLINE);
+ source_out("\t");
+ } else if (fTclTk && checkcmd("AS")) { /* arguments */
+
+#if 0
+/* let these be defined as macros. if they're not, they're just caught as unrecognized macros */
+ } else if (checkcmd("ll") || checkcmd("IX") ||
+ checkcmd("nh")||checkcmd("hy")||checkcmd("hc")||checkcmd("hw") /* hyphenation */
+ ) { /* unsupported macros -- usually roff specific */
+
+ fprintf(stderr, "macro \"%s\" not supported -- ignoring\n", cmd);
+#endif
+
+ } else { /* could be a macro definition */
+ supresseol=0;
+
+ for (i=0; i<macrocnt; i++) {
+ if (macro[i].key == NULL) continue; /* !!! how does this happen? */
+ if (checkcmd(macro[i].key)) {
+
+ /* it is, collect arguments */
+ for (j=0; j<9; j++) macroArg[j]="";
+ for (j=0; p!=NULL && *p && j<9; j++, p=q) {
+ endch=' '; if (*p=='"') { endch='"'; p++; }
+ q = strchr(p,endch);
+ if (q!=NULL) {
+ *q++='\0';
+ if (*q && endch!=' ') q++;
+ }
+ macroArg[j] = p;
+ }
+
+ /* instantiate that text, substituting \\[1-9]'s */
+ p = macro[i].subst;
+ q = macrobuf; /* allocated on stack */
+ while (*p) {
+ if (*p=='\\') {
+ p++;
+ if (*p=='t') {
+ *q++ = '\t';
+ p++;
+ } else if (*p=='$' && isdigit(p[1])) {
+ j = p[1]-'0'-1; /* convert to ASCII and align with macroArg array */
+ p+=2;
+ /* *q++='"'; -- no */
+ strcpy(q, macroArg[j]); q += strlen(q);
+ /* *q++='"'; -- no */
+
+ } else {
+ *q++ = '\\';
+ }
+ } else {
+ *q++ = *p++;
+ }
+ }
+ *q='\0';
+
+ /* execute that text */
+ /*fprintf(stderr, "for macro %s, substituted text is \n%s\n", macro[i].key, macrobuf);*/
+ source_subfile(macrobuf);
+
+ break;
+ }
+ }
+
+ /* macro not found */
+ if (i==macrocnt) {
+ /* report missing macros only once */
+ for (j=0; j<macnotcnt; j++) if (strcmp(macnotfound[j],cmd)==0) break;
+ if (j==macnotcnt) {
+ if (!fQuiet) fprintf(stderr, "macro \"%s\" not recognized -- ignoring\n", cmd);
+ q = malloc(strlen(cmd)+1); strcpy(q,cmd);
+ macnotfound[macnotcnt++] = q;
+ }
+ }
+ } /* else command is unrecognized -- ignore it: we're not a complete [tn]roff implementation */
+
+ /* popular but meaningless commands: .ne (need <n> lines--on infinite scroll */
+}
+
+
+static void
+source_line(char *p)
+{
+ /*stagadd(BEGINLINE);*/
+ char *cmd=p;
+ if (p==NULL) return; /* bug somewhere else, but where? */
+
+#if 0
+ if (*p!='.' && *p!='\'' && !finlist) {
+ if (fsourceTab && !fosourceTab) {
+ tblc=1; tbli=0; tableSep='\t';
+ tbl[0][0]=tbl[0][1]=tbl[0][2]=tbl[0][3]=tbl[0][4]=tbl[0][5]=tbl[0][6]=tbl[0][7]=tbl[0][8]="l";
+ source_struct(BEGINTABLE); finTable=1;
+ } else if (!fsourceTab && fosourceTab) {
+ source_struct(ENDTABLE); finTable=0;
+ }
+ fosourceTab=fsourceTab;
+ }
+#endif
+
+ if (*p=='.' /*|| *p=='\'' -- normalized */) { /* command == starts with "." */
+ p++;
+ supresseol=1;
+ source_command(p);
+
+ } else if (!*p) { /* blank line */
+ /*source_command("P");*/
+ ncnt=1; source_struct(BEGINLINE); ncnt=0; /* empty line => paragraph break */
+
+#if 0
+ } else if (fsourceTab && !finlist /* && pmode */) { /* can't handle tabs, so try tables */
+ source_struct(BEGINTABLE);
+ tblcellformat = "l";
+ do {
+ source_struct(BEGINTABLELINE);
+ while (*p) {
+ source_struct(BEGINTABLEENTRY);
+ p = source_out0(p, '\t');
+ source_struct(ENDTABLEENTRY);
+ }
+ source_struct(ENDTABLELINE);
+ } while ((p=source_gets())!=NULL && fsourceTab);
+ source_struct(ENDTABLE);
+ source_line(p);
+#endif
+
+ } else { /* otherwise normal text */
+ source_out(p);
+ if (finnf || isspace(*cmd)) source_struct(SHORTLINE);
+ }
+
+ if (!supresseol && !finnf) { source_out(" "); if (finlist) source_list(); }
+ supresseol=0;
+ /*stagadd(ENDLINE);*/
+}
+
+
+static void
+source_filter(void)
+{
+ char *p = in, *q;
+ char *oldv,*newv,*shiftp,*shiftq,*endq;
+ int lenp,lenq;
+ int i,on1,on2,nn1,nn2,first;
+ int insertcnt=0, deletecnt=0, insertcnt0;
+ int nextDiffLine=-1;
+ char diffcmd, tmpc, tmpendq;
+
+ AbsLine=0;
+
+ /* just count length of macro table! */
+ for (i=0; macro[i].key!=NULL; i++) /*empty*/;
+ macrocnt = i;
+
+ /* {{ dumb Digital puts \\} closers on same line */
+ for (p=in; (p=strstr(p," \\}"))!=NULL; p+=3) *p='\n';
+
+ sI=0;
+ /* (*fn)(BEGINDOC); -- done at .TH or first .SH */
+
+
+ /* was: source_subfile(in); */
+ while (fDiff && fgets(diffline, MAXBUF, difffd)!=NULL) {
+ /* requirements: no context lines, no errors in files, ...
+ change-command: 8a12,15 or 5,7c8,10 or 5,7d3
+ < from-file-line
+ < from-file-line...
+ --
+ > to-file-line
+ > to-file-line...
+ */
+ for (q=diffline; ; q++) { diffcmd=*q; if (diffcmd=='a'||diffcmd=='c'||diffcmd=='d') break; }
+ if (sscanf(diffline, "%d,%d", &on1,&on2)==1) on2=on1-1+(diffcmd=='d'||diffcmd=='c');
+ if (sscanf(++q, "%d,%d", &nn1,&nn2)==1) nn2=nn1-1+(diffcmd=='a'||diffcmd=='c');
+
+ deletecnt = on2-on1+1;
+ insertcnt = nn2-nn1+1;
+
+ nextDiffLine = nn1;
+ /*assert(nextDiffLine>=AbsLine); -- can happen if inside a macro? */
+ if (nextDiffLine<AbsLine) continue;
+
+ while (AbsLine<nextDiffLine && (p=source_gets())!=NULL) {
+ source_line(p);
+ }
+
+ insertcnt0=insertcnt+1; /* eat duplicate insert lines and '---' too */
+ diffline2[0] = '\0';
+ while (insertcnt && deletecnt) {
+ if (ungetc(fgetc(difffd),difffd)=='<') { fgetc(difffd); fgetc(difffd); } /* skip '<' */
+ /* fill buffer with old line -- but replace if command */
+ /* stay away from commands -- too careful if .B <word> */
+ do {
+ p = oldv = fgets(diffline, MAXBUF, difffd);
+ p[strlen(p)-1]='\0'; /* fgets's \n ending => \0 */
+ deletecnt--;
+ } while (deletecnt && *p=='.'); /* throw out commands in old version */
+
+ q = newv = source_gets();
+ insertcnt--;
+ while (insertcnt && *q=='.') {
+ source_line(q);
+ insertcnt--;
+ }
+
+ if (*p=='.' || *q=='.') break;
+
+
+ /* make larger chunk for better diff -- but still keep away from commands */
+ lenp=strlen(p); lenq=strlen(q);
+ while (deletecnt && MAXBUF-lenq>80*2) {
+ fgetc(difffd); fgetc(difffd); /* skip '<' */
+ if (ungetc(fgetc(difffd),difffd)=='.') break;
+ p=&diffline[lenp]; *p++=' '; lenp++;
+ fgets(p, MAXBUF-lenp, difffd); p[strlen(p)-1]='\0'; lenp+=strlen(p);
+ deletecnt--;
+ }
+
+ while (insertcnt && *in!='.' && MAXBUF-lenq>80*2) {
+ if (newv!=diffline2) { strcpy(diffline2,q); newv=diffline2; }
+ q=source_gets(); diffline2[lenq]=' '; lenq++;
+ strcpy(&diffline2[lenq],q); lenq+=strlen(q);
+ insertcnt--;
+ }
+
+ /* common endings */
+ p = &p[strlen(oldv)]; q=&q[strlen(newv)];
+ while (p>oldv && q>newv && p[-1]==q[-1]) { p--; q--; }
+ if ((p>oldv && p[-1]=='\\') || (q>newv && q[-1]=='\\'))
+ while (*p && *q && !isspace(*p)) { p++; q++; } /* steer clear of escapes */
+ tmpendq=*q; *p=*q='\0'; endq=q;
+
+ p=oldv; q=newv;
+ while (*p && *q) {
+ /* common starts */
+ newv=q; while (*p && *q && *p==*q) { p++; q++; }
+ if (q>newv) {
+ tmpc=*q; *q='\0'; source_line(newv); *q=tmpc;
+ }
+
+ /* too hard to read */
+ /* difference: try to find hunk of p in remainder of q */
+ if (strlen(p)<15 || (shiftp=strchr(&p[15],' ') /*|| shiftp-p>30*/)==NULL) break;
+ shiftp++; /* include the space */
+ tmpc=*shiftp; *shiftp='\0'; shiftq=strstr(q,p); *shiftp=tmpc; /* includes space */
+ if (shiftq!=NULL) {
+ /* call that part of q inserted */
+ tmpc=*shiftq; *shiftq='\0';
+ stagadd(BEGINDIFFA); source_line(q); stagadd(ENDDIFFA); source_line(" ");
+ *shiftq=tmpc; q=shiftq;
+ } else {
+ /* call that part of p deleted */
+ shiftp--; *shiftp='\0'; /* squash the trailing space */
+ stagadd(BEGINDIFFD); source_line(p); stagadd(ENDDIFFD); source_line(" ");
+ p=shiftp+1;
+ }
+/*#endif*/
+ }
+
+ if (*p) { stagadd(BEGINDIFFD); source_line(p); stagadd(ENDDIFFD); }
+ if (*q) { stagadd(BEGINDIFFA); source_line(q); stagadd(ENDDIFFA); }
+ if (tmpendq!='\0') { *endq=tmpendq; source_line(endq); }
+ source_line(" ");
+ }
+
+ /* even if diffcmd=='c', could still have remaining old version lines */
+ first=1;
+ while (deletecnt--) {
+ fgets(diffline, MAXBUF, difffd);
+ if (diffline[2]!='.') {
+ if (first) { stagadd(BEGINDIFFD); first=0; }
+ source_line(&diffline[2]); /* don't do commands; skip initial '<' */
+ }
+ }
+ if (!first) { stagadd(ENDDIFFD); source_line(" "); }
+
+ /* skip over duplicated from old */
+ if (diffcmd=='c') while (insertcnt0--) fgets(diffline, MAXBUF, difffd);
+
+ /* even if diffcmd=='c', could still have remaining new version lines */
+ first=1;
+ nextDiffLine = AbsLine + insertcnt;
+ while (insertcnt--) fgets(diffline, MAXBUF, difffd); /* eat duplicate text of above */
+ while (/*insertcnt--*/AbsLine<nextDiffLine && (p=source_gets())!=NULL) {
+ if (first && *p!='.') { stagadd(BEGINDIFFA); first=0; }
+ source_line(p);
+ }
+ if (!first) { stagadd(ENDDIFFA); source_line(" "); }
+ }
+ /* finish up remainder (identical to both) */
+ while ((p=source_gets())!=NULL) {
+ source_line(p);
+ }
+
+ source_flush();
+ pop(ENDDOC); (*fn)(ENDDOC);
+}
+
+
+
+/*
+ * STARTUP
+ */
+
+static int
+setFilterDefaults(char *outputformat)
+{
+ static struct {
+ void (*fn)(enum command);
+ int fPara; int fQS; int fIQS; int fNOHY; int fChangeleft; int fURL; char *names;
+ /* (could set parameters at BEGINDOC call...) */
+ } format[] = {
+ /*{default 0par 0qs 0iqs 0hy 0cl 0url "name"},*/
+ { ASCII, 0, 0, 0, 0, 0, 0, "ASCII" },
+ { TkMan, 0, 0, 0, 0, 0, 0, "TkMan" },
+ { Tk, 0, 0, 0, 0, 0, 0, "Tk:Tcl" },
+ { Sections, 0, 0, 0, 0, 0, 0, "sections" },
+ { Roff, 0, 1, 1, 1, -1, 0, "roff:troff:nroff" },
+ { HTML, 1, 1, 1, 1, 1, 1, "HTML:WWW:htm" },
+ { SGML, 1, 1, 1, 1, 1, 1, "SGML:XML" },
+/* { Texinfo, 1, 1, 1, 1, 1, 1, "Texinfo:info:GNU" },*/
+ { MIME, 1, 1, 1, 1, 1, 0, "MIME:Emacs:enriched" },
+ { LaTeX, 1, 1, 1, 1, 1, 0, "LaTeX:LaTeX209:209:TeX" },
+ { LaTeX2e, 1, 1, 1, 1, 1, 0, "LaTeX2e:2e" },
+ { RTF, 1, 1, 1, 1, 1, 0, "RTF" },
+ { pod, 0, 0, 1, 0, -1, 0, "pod:Perl" },
+ /*{ Ensemble, 1, 1, 1, 1, 1, 0, "Ensemble" },*/
+
+ { PostScript, 0, 0, 0, 0, 0, 0, "PostScript:ps" },
+ { FrameMaker, 0, 0, 0, 0, 0, 0, "FrameMaker:Frame:Maker:MIF" },
+
+ { NULL, 0, 0, 0, 0, 0, 0, NULL }
+ };
+
+ int i, found=0;
+ for (i=0; format[i].fn!=NULL; i++) {
+ if (strcoloncmp2(outputformat,'\0',format[i].names,0)) {
+ fn = format[i].fn;
+ fPara = format[i].fPara;
+ fQS = format[i].fQS;
+ fIQS = format[i].fIQS;
+ fNOHY = format[i].fNOHY;
+ fChangeleft = format[i].fChangeleft;
+ fURL = format[i].fURL;
+ found=1;
+ break;
+ }
+ }
+
+ return (found==0);
+}
+
+
+/* read in whole file. caller responsible for freeing memory */
+static char *
+filesuck(FILE *in)
+{
+ const int inc=1024*100; /* what's 100K these days? */
+ int len=0,cnt;
+ char *file = malloc(1); /*NULL -- relloc on NULL not reducing to malloc on some machines? */
+
+ do {
+ file = realloc(file, len+inc+1); /* what's the ANSI way to find the file size? */
+ cnt = fread(&file[len], 1, inc, in);
+ len+=cnt;
+ } while (cnt==inc);
+ file[len]='\0';
+
+ return file;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int c;
+ int i,j;
+ char *p,*oldp;
+ int fname=0;
+ const int helpbreak=75;
+ const int helpispace=4;
+ int helplen=0;
+ int desclen;
+ char **argvch; /* remapped argv */
+ char *argvbuf;
+ char *processing = "stdin";
+/* FILE *macros; -- interpret -man macros? */
+
+ char strgetopt[80];
+ /* options with an arg must have a '<' in the description */
+ static struct { char letter; int arg; char *longnames; char *desc; } option[] = {
+ { 'f', 1, "filter", " <ASCII|roff|TkMan|Tk|Sections|HTML|SGML|MIME|LaTeX|LaTeX2e|RTF|pod>" },
+ { 'S', 0, "source", "(ource of man page passed in)" }, /* autodetected */
+ { 'F', 0, "formatted:format", "(ormatted man page passed in)" }, /* autodetected */
+
+ { 'r', 1, "reference:manref:ref", " <man reference printf string>" },
+ { 'l', 1, "title", " <title printf string>" },
+ { 'V', 1, "volumes:vol", "(olume) <colon-separated list>" },
+ { 'U', 0, "url:urls", "(RLs as hyperlinks)" },
+
+ /* following options apply to formatted pages only */
+ { 'b', 0, "subsections:sub", " (show subsections)" },
+ { 'k', 0, "keep:head:foot:header:footer", "(eep head/foot)" },
+ { 'n', 1, "name", "(ame of man page) <string>" },
+ { 's', 1, "section:sect", "(ection) <string>" },
+ { 'p', 0, "paragraph:para", "(aragraph mode toggle)" },
+ { 't', 1, "tabstop:tabstops", "(abstops spacing) <number>" },
+ { 'N', 0, "normalize:normal", "(ormalize spacing, changebars)" },
+ { 'y', 0, "zap:nohyphens", " (zap hyphens toggle)" },
+ { 'K', 0, "nobreak", " (declare that page has no breaks)" }, /* autodetected */
+ { 'd', 1, "diff", "(iff) <file> (diff of old page source to incorporate)" },
+ { 'M', 1, "message", "(essage) <text> (included verbatim at end of Name section)" },
+ /*{ 'l', 0, "number lines", "... can number lines in a pipe" } */
+ /*{ 'T', 0, "tables", "(able agressive parsing ON)" },*/
+/* { 'c', 0, "changeleft:changebar", "(hangebarstoleft toggle)" }, -- default is perfect */
+ /*{ 'R', 0, "reflow", "(eflow text lines)" },*/
+ { 'R', 1, "rebus", "(ebus words for TkMan)" },
+ { 'C', 0, "TclTk", " (enable Tcl/Tk formatting)" }, /* autodetected */
+
+ /*{ 'D', 0, "debug", "(ebugging mode)" }, -- dump unrecognized macros, e.g.*/
+ { 'o', 0, "noop", " (no op)" },
+ { 'O', 0, "noop", " <arg> (no op with arg)" },
+ { 'q', 0, "quiet", "(uiet--don't report warnings)" },
+ { 'h', 0, "help", "(elp)" },
+ /*{ '?', 0, "help", " (help)" }, -- getopt returns '?' as error flag */
+ { 'v', 0, "version", "(ersion)" },
+ { '\0', 0, "", NULL }
+ };
+
+ /* calculate strgetopt from options list */
+ for (i=0,p=strgetopt; option[i].letter!='\0'; i++) {
+ *p++ = option[i].letter;
+ /* check for duplicate option letters */
+ assert(strchr(strgetopt,option[i].letter)==&p[-1]);
+ if (option[i].arg) *p++=':';
+ }
+ *p='\0';
+
+ /* spot check construction of strgetopt */
+ assert(p<strgetopt+80);
+ assert(strlen(strgetopt)>10);
+ assert(strchr(strgetopt,'f')!=NULL);
+ assert(strchr(strgetopt,'v')!=NULL);
+ assert(strchr(strgetopt,':')!=NULL);
+
+#ifdef macintosh
+ extern void InitToolbox();
+ InitToolbox();
+#endif
+
+ /* count, sort exception strings */
+ for (lcexceptionslen=0; (p=lcexceptions[lcexceptionslen])!=NULL; lcexceptionslen++) /*empty*/;
+ qsort(lcexceptions, lcexceptionslen, sizeof(char*), lcexceptionscmp);
+
+ /* map long option names to single letters for switching */
+ /* (GNU probably has a reusable function to do this...) */
+ /* deep six getopt in favor of integrated long names + letters? */
+ argvch = malloc(argc * sizeof(char*));
+ p = argvbuf = malloc(argc*3 * sizeof(char)); /* either -<char>'\0' or no space used */
+ for (i=0; i<argc; i++) argvch[i]=argv[i]; /* need argvch[0] for getopt? */
+ argv0 = mystrdup(argv[0]);
+ for (i=1; i<argc; i++) {
+ if (argv[i][0]=='-' && argv[i][1]=='-') {
+ if (argv[i][2]=='\0') break; /* end of options */
+ for (j=0; option[j].letter!='\0'; j++) {
+ if (strcoloncmp2(&argv[i][2],'\0',option[j].longnames,0)) {
+ argvch[i] = p;
+ *p++ = '-'; *p++ = option[j].letter; *p++ = '\0';
+ if (option[j].arg) i++; /* skip arguments of options */
+ break;
+ }
+ }
+ if (option[j].letter=='\0') fprintf(stderr, "%s: unknown option %s\n", argv[0], argv[i]);
+ }
+ }
+
+
+
+ /* pass through options to set defaults for chosen format */
+ setFilterDefaults("ASCII"); /* default to ASCII (used by TkMan's Glimpse indexing */
+
+ /* initialize header/footer buffers (save room in binary) */
+ for (i=0; i<CRUFTS; i++) { *cruft[i] = '\0'; } /* automatically done, guaranteed? */
+ /*for (i=0; i<MAXLINES; i++) { linetabcnt[i] = 0; } */
+
+ while ((c=getopt(argc,argvch,strgetopt))!=-1) {
+
+ switch (c) {
+ case 'k': fHeadfoot=1; break;
+ case 'b': fSubsections=1; break;
+/* case 'c': fChangeleft=1; break; -- obsolete */
+ /* case 'R': fReflow=1; break;*/
+ case 'n': strcpy(manName,optarg); fname=1; break; /* name & section for when using stdin */
+ case 's': strcpy(manSect,optarg); break;
+ /*case 'D': docbookpath = optarg; break;*/
+ case 'V': vollist = optarg; break;
+ case 'l': manTitle = optarg; break;
+ case 'r': manRef = optarg;
+ if (strlen(manRef)==0 || strcmp(manRef,"-")==0 || strcmp(manRef,"off")==0) fmanRef=0;
+ break;
+ case 't': TabStops=atoi(optarg); break;
+ /*case 'T': fTable=1; break; -- if preformatted doesn't work, if source automatic */
+ case 'p': fPara=!fPara; break;
+ case 'K': fFoot=1; break;
+ case 'y': fNOHY=1; break;
+ case 'N': fNORM=1; break;
+
+ case 'f': /* set format */
+ if (setFilterDefaults(optarg)) {
+ fprintf(stderr, "%s: unknown format: %s\n", argv0, optarg);
+ exit(1);
+ }
+ break;
+ case 'F': fSource=0; break;
+ case 'S': fSource=1; break;
+
+ case 'd':
+ difffd = fopen(optarg, "r");
+ if (difffd==NULL) { fprintf(stderr, "%s: can't open %s\n", argv0, optarg); exit(1); }
+/* read in a line at a time
+ diff = filesuck(fd);
+ fclose(fd);
+*/
+ fDiff=1;
+ break;
+
+ case 'M': message = optarg; break;
+
+ case 'C': fTclTk=1; break;
+ case 'R':
+ p = malloc(strlen(optarg)+1);
+ strcpy(p, optarg); /* string may not be in writable address space */
+ oldp = "";
+ for (; *p; oldp=p, p++) {
+ if (*oldp=='\0') rebuspat[rebuspatcnt++] = p;
+ if (*p=='|') *p='\0';
+ }
+ for (i=0; i<rebuspatcnt; i++) rebuspatlen[i] = strlen(rebuspat[i]); /* for strnlen() */
+ break;
+
+ case 'q': fQuiet=1; break;
+ case 'o': /*no op*/ break;
+ case 'O': /* no op with arg */ break;
+ case 'h':
+ printf("rman"); helplen=strlen("rman");
+
+ /* linebreak options */
+ assert(helplen>0);
+ for (i=0; option[i].letter!='\0'; i++) {
+ desclen = strlen(option[i].desc);
+ if (helplen+desclen+5 > helpbreak) { printf("\n%*s",helpispace,""); helplen=helpispace; }
+ printf(" [-%c%s]", option[i].letter, option[i].desc);
+ helplen += desclen+5;
+ }
+ if (helplen>helpispace) printf("\n");
+ printf("%*s [<filename>]\n",helpispace,"");
+ exit(0);
+
+ case 'v': /*case '?':*/
+ printf("PolyglotMan v" POLYGLOTMANVERSION "\n");
+ exit(0);
+
+ default:
+ fprintf(stderr, "%s: unidentified option -%c (-h for help)\n",argvch[0],c);
+ exit(2);
+ }
+ }
+
+
+
+ /* read from given file name(s) */
+ if (optind<argc) {
+ processing = argvch[optind];
+
+ if (!fname) { /* if no name given, create from file name */
+ /* take name from tail of path */
+ if ((p=strrchr(argvch[optind],'/'))!=NULL) p++; else p=argvch[optind];
+ strcpy(manName,p);
+
+ /* search backward from end for final dot. split there */
+ if ((p=strrchr(manName,'.'))!=NULL) {
+ strcpy(manSect,p+1);
+ *p='\0';
+ }
+ }
+
+ strcpy(plain,argvch[optind]);
+
+ if (freopen(argvch[optind], "r", stdin)==NULL) {
+ fprintf(stderr, "%s: can't open %s\n", argvch[0],argvch[optind]);
+ exit(1);
+ }
+ }
+
+ /* need to read macros, ok if fail; from /usr/lib/tmac/an => needs to be set in Makefile, maybe a searchpath */
+ /*
+ if ((macros=fopen("/usr/lib/tmac/an", "r"))!=NULL) {
+ in = File = filesuck(macros);
+ lookahead = File[0];
+ source_filter();
+ free(File);
+ }
+ */
+
+ /* suck in whole file and just operate on pointers */
+ in = File = filesuck(stdin);
+
+
+ /* minimal check for roff source: first character dot command or apostrophe comment */
+ /* MUST initialize lookahead here, BEFORE first call to la_gets */
+ if (fSource==-1) {
+ lookahead = File[0];
+ fSource = (lookahead=='.' || lookahead=='\'' || /*dumb HP*/lookahead=='/'
+ /* HP needs this too but causes problems || isalpha(lookahead)--use --source flag*/);
+ }
+
+ if (fDiff && (!fSource || fn!=HTML)) {
+ fprintf(stderr, "diff incorporation supported for man page source, generating HTML\n");
+ exit(1);
+ }
+
+ if (fSource) source_filter(); else preformatted_filter();
+ if (fDiff) fclose(difffd);
+ /*free(File); -- let system clean up, perhaps more efficiently */
+
+ return 0;
+}
diff --git a/xc/extras/rman/rman.html b/xc/extras/rman/rman.html
new file mode 100644
index 000000000..8ff15172b
--- /dev/null
+++ b/xc/extras/rman/rman.html
@@ -0,0 +1,322 @@
+<HTML><HEAD><TITLE>PolyglotMan Manual Page</TITLE></HEAD>
+<BODY>
+<H1>Name</H1>
+
+PolyglotMan, rman - reverse compile man pages from formatted form to a number of source formats
+
+<H1>Synopsis</H1>
+
+rman [<I>options</I>] [<I>file</I>]
+
+<H1>Description</H1>
+
+<P><I>PolyglotMan</I> takes man pages from most of the
+popular flavors of UNIX and transforms them into any of a number of
+text source formats. PolyglotMan was formerly known as RosettaMan.
+The name of the binary is still called <tt>rman</tt>, for scripts
+that depend on that name; mnemonically, just think "reverse man".
+Previously <I>PolyglotMan</I> required pages to
+be formatted by nroff prior to its processing. With version 3.0, it <i>prefers
+[tn]roff source</i> and usually produces results that are better yet.
+And source processing is the only way to translate tables.
+Source format translation is not as mature as formatted, however, so
+try formatted translation as a backup.
+
+<P>In parsing [tn]roff source, one could implement an arbitrarily
+large subset of [tn]roff, which I did not and will not do, so the
+results can be off. I did implement a significant subset of those use
+in man pages, however, including tbl (but not eqn), if tests, and
+general macro definitions, so usually the results look great. If they
+don't, format the page with nroff before sending it to PolyglotMan. If
+PolyglotMan doesn't recognize a key macro used by a large class of
+pages, however, e-mail me the source and a uuencoded nroff-formatted
+page and I'll see what I can do. When running PolyglotMan with man
+page source that includes or redirects to other [tn]roff source using
+the .so (source or inclusion) macro, you should be in the parent
+directory of the page, since pages are written with this assumption.
+For example, if you are translating /usr/man/man1/ls.1, first cd into
+/usr/man.
+
+<P><I>PolyglotMan</I> accepts man pages from: SunOS, Sun Solaris, Hewlett-Packard HP-UX,
+AT&amp;T System V, OSF/1 aka Digital UNIX, DEC Ultrix, SGI IRIX, Linux,
+FreeBSD, SCO. Source processing works for: SunOS, Sun Solaris, Hewlett-Packard HP-UX,
+AT&amp;T System V, OSF/1 aka Digital UNIX, DEC Ultrix.
+It can produce printable ASCII-only (control characters
+stripped), section headers-only,
+Tk, TkMan, [tn]roff (traditional man page source), <!--Ensemble,--> SGML, HTML, MIME,
+LaTeX, LaTeX2e, RTF, Perl 5 POD.
+A modular architecture permits easy addition of additional output
+formats.</P>
+
+<P>The latest version of PolyglotMan is always available from
+<tt>ftp://ftp.cs.berkeley.edu/ucb/people/phelps/tcltk/rman.tar.Z</tt>.
+
+
+<H1>Options</H1>
+
+<P>The following options should not be used with any others and exit PolyglotMan
+without processing any input.
+
+<DL>
+<DT>-h|--help</DT>
+<DD>Show list of command line options and exit.</DD>
+
+<DT>-v|--version</DT>
+<DD>Show version number and exit.</DD>
+</DL>
+
+
+<P><em>You should specify the filter first, as this sets a number of parameters,
+and then specify other options.</em>
+
+<DL>
+<DT>-f|--filter &lt;ASCII|roff|TkMan|Tk|<!--Ensemble|-->Sections|HTML|SGML|MIME|LaTeX|LaTeX2e|RTF|POD&gt;</DT>
+
+<DD>Set the output filter. Defaults to ASCII.
+<!-- If you are converting
+from formatted roff source, it is recommended that you prevent hyphenation by using
+groff, making file with the contents ".hpm 20", can reading this in
+before the roff source, e.g., groff -Tascii -man <hpm-file> <roff-source>.
+-->
+</DD>
+
+<DT>-S|--source</DT>
+<DD>PolyglotMan tries to automatically determine whether its input is source or formatted;
+use this option to declare source input.</DD>
+
+<DT>-F|--format|--formatted</DT>
+<DD>PolyglotMan tries to automatically determine whether its input is source or formatted;
+use this option to declare formatted input.</DD>
+
+<DT>-l|--title <I>printf-string</I></DT>
+<DD>In HTML mode this sets the &lt;TITLE&gt; of the man pages, given the same
+parameters as <tt>-r</tt>.</DD>
+
+<DT>-r|--reference|--manref <I>printf-string</I></DT>
+<DD>In HTML and SGML modes this sets the URL form by which to retrieve other man pages.
+The string can use two supplied parameters: the man page name and its section.
+(See the Examples section.) If the string is null (as if set from a shell
+by "-r ''"), `-' or `off', then man page references will not be HREFs, just set in italics.
+If your printf supports XPG3 positions specifier, this can be quite flexible.</DD>
+
+<DT>-V|--volumes <I>&lt;colon-separated list&gt;</I></DT>
+<DD>Set the list of valid volumes to check against when looking for
+cross-references to other man pages. Defaults to <tt>1:2:3:4:5:6:7:8:9:o:l:n:p</tt>
+(volume names can be multicharacter).
+If an non-whitespace string in the page is immediately followed by a left
+parenthesis, then one of the valid volumes, and ends with optional other
+characters and then a right parenthesis--then that string is reported as
+a reference to another manual page. If this -V string starts with an equals
+sign, then no optional characters are allowed between the match to the list of
+valids and the right parenthesis. (This option is needed for SCO UNIX.)
+</DD>
+
+</DL>
+
+
+<P>The following options apply only when formatted pages are given as input.
+They do not apply or are always handled correctly with the source.
+
+<DL>
+<DT>-b|--subsections</DT>
+<DD>Try to recognize subsection titles in addition to section titles.
+This can cause problems on some UNIX flavors.</DD>
+
+<DT>-K|--nobreak</DT>
+<DD>Indicate manual pages don't have page breaks, so don't look for footers and headers
+around them. (Older nroff -man macros always put in page breaks, but lately
+some vendors have realized that printout are made through troff, whereas
+nroff -man is used to format pages for reading on screen, and so have eliminated
+page breaks.) <I>PolyglotMan</I> usually gets this right even without this flag.</DD>
+
+<DT>-k|--keep</DT>
+<DD>Keep headers and footers, as a canonical report at the end of the page.</DD>
+
+<!-- this done automatically for Tcl/Tk pages; doesn't apply for others
+<DT>-c|--changeleft</DT>
+<DD>Move changebars, such as those found in the Tcl/Tk manual pages,
+to the left.</DD>
+-->
+
+<!-- agressive parsing works so well that this option has been removed
+<DT>-m|--notaggressive</DT>
+<DD><I>Disable</I> aggressive man page parsing. Aggressive manual,
+which is on by default, page parsing elides headers and footers,
+identifies sections and more.</DD>
+-->
+
+<DT>-n|--name <I>name</I></DT>
+<DD>Set name of man page (used in roff format).
+If the filename is given in the form "<I>name</I>.<I>section</I>", the name
+and section are automatically determined. If the page is being parsed from
+[tn]roff source and it has a .TH line, this information is extracted from that line.</DD>
+
+<DT>-p|--paragraph</DT>
+<DD>paragraph mode toggle. The filter determines whether lines should be linebroken
+as they were by nroff, or whether lines should be flowed together into paragraphs.
+Mainly for internal use.</DD>
+
+<DT>-s|section <I>#</I></DT>
+<DD>Set volume (aka section) number of man page (used in roff format).</DD>
+
+<!-- if in source automatic, if in preformatted really doesn't work
+<DT>-T|--tables</DT>
+<DD>Turn on aggressive table parsing.</DD>
+-->
+
+<DT>-t|--tabstops <I>#</I></DT>
+<DD>For those macros sets that use tabs in place of spaces where
+possible in order to reduce the number of characters used, set
+tabstops every <I>#</I> columns. Defaults to 8.</DD>
+
+
+</DL>
+
+
+<H1>Notes on Filter Types</H1>
+
+<H2>ROFF</H2>
+<P>Some flavors of UNIX ship man page without [tn]roff source, making one's laser printer
+little more than a laser-powered daisy wheel. This filer tries to intuit
+the original [tn]roff directives, which can then be recompiled by [tn]roff.</P>
+
+<H2>TkMan</H2>
+<P>TkMan, a hypertext man page browser, uses <I>PolyglotMan</I> to show
+man pages without the (usually) useless headers and footers on each
+pages. It also collects section and (optionally) subsection heads for
+direct access from a pulldown menu. TkMan and Tcl/Tk, the toolkit in
+which it's written, are available via anonymous ftp from
+<tt>ftp://ftp.smli.com/pub/tcl/</tt></P>
+
+<H2>Tk</H2>
+
+<P>This option outputs the text in a series of Tcl lists consisting of
+text-tags pairs, where tag names roughly correspond to HTML. This
+output can be inserted into a Tk text widget by doing an <tt>eval
+&lt;textwidget&gt; insert end &lt;text&gt;</tt>. This format should be relatively
+easily parsible by other programs that want both the text and the
+tags. Also see ASCII.</P>
+
+<!-- hard to track what Ensemble's input format is
+<H2>Ensemble</H2>
+<P>Ensemble, a multimedia editor of structured documents, is currently
+being developed by the research groups of Professors Michael A. Harrison and
+Susan L. Graham at the University of California, Berkeley. With proper
+structure and presentation specifications (schemas), the appearance of
+a manual page can be radically transformed by Ensemble.</P>
+-->
+
+<H2>ASCII</H2>
+<P>When printed on a line printer, man pages try to produce special text effects
+by overstriking characters with themselves (to produce bold) and underscores
+(underlining). Other text processing software, such as text editors, searchers,
+and indexers, must counteract this. The ASCII filter strips away this formatting.
+Piping nroff output through <tt>col -b</tt> also strips away this formatting,
+but it leaves behind unsightly page headers and footers. Also see Tk.</P>
+
+<H2>Sections</H2>
+<P>Dumps section and (optionally) subsection titles. This might be useful for
+another program that processes man pages.</P>
+
+<H2>HTML</H2>
+<P>With a simple extention to an HTTP server for Mosaic or other World Wide Web
+browser, <I>PolyglotMan</I> can produce high quality HTML on the fly.
+Several such extensions and pointers to several others are included in <I>PolyglotMan</I>'s
+<tt>contrib</tt> directory.</P>
+
+<H2>SGML</H2>
+<P>This is appoaching the Docbook DTD, but I'm hoping that someone that someone
+with a real interest in this will polish the tags generated. Try it to see
+how close the tags are now.</P>
+
+<H2>MIME</H2>
+<P>MIME (Multipurpose Internet Mail Extensions) as defined by RFC 1563,
+good for consumption by MIME-aware e-mailers or as Emacs (>=19.29)
+enriched documents.</P>
+
+<H2>LaTeX and LaTeX2e</H2>
+Why not?
+
+<H2>RTF</H2>
+<P>Use output on Mac or NeXT or whatever. Maybe take random man pages
+and integrate with NeXT's documentation system better. Maybe NeXT has
+own man page macros that do this.</P>
+
+<H2>PostScript and FrameMaker</H2>
+<P>To produce PostScript, use <tt>groff</tt> or <tt>psroff</tt>. To produce FrameMaker MIF,
+use FrameMaker's builtin filter. In both cases you need <tt>[tn]roff</tt> source,
+so if you only have a formatted version of the manual page, use <I>PolyglotMan</I>'s
+roff filter first.</P>
+
+
+<H1>Examples</H1>
+
+<P>To convert the <I>formatted</I> man page named <tt>ls.1</tt> back into
+[tn]roff source form:</P>
+
+<P>
+ <tt>rman -f roff /usr/local/man/cat1/ls.1 > /usr/local/man/man1/ls.1</tt><BR>
+
+<P>Long man pages are often compressed to conserve space (compression is
+especially effective on formatted man pages as many of the characters
+are spaces). As it is a long man page, it probably has subsections,
+which we try to separate out (some macro sets don't distinguish
+subsections well enough for <I>PolyglotMan</I> to detect them). Let's convert
+this to LaTeX format:<BR>
+
+<P>
+ <tt>pcat /usr/catman/a_man/cat1/automount.z | rman -b -n automount -s 1 -f latex > automount.man</tt><BR>
+
+<P>Alternatively,
+
+ <tt>man 1 automount | rman -b -n automount -s 1 -f latex > automount.man</tt><BR>
+
+<P>For HTML/Mosaic users, <I>PolyglotMan</I> can, without modification of the
+source code, produce HTML links that point to other HTML man pages
+either pregenerated or generated on the fly. First let's assume
+pregenerated HTML versions of man pages stored in <I>/usr/man/html</I>.
+Generate these one-by-one with the following form:<BR>
+
+ <tt>rman -f html -r 'http:/usr/man/html/%s.%s.html' /usr/man/cat1/ls.1 > /usr/man/html/ls.1.html</tt><BR>
+
+<P>If you've extended your HTML client to generate HTML on the fly you should use
+something like:<BR>
+
+ <tt>rman -f html -r 'http:~/bin/man2html?%s:%s' /usr/man/cat1/ls.1</tt><BR>
+
+when generating HTML.</P>
+
+
+<H1>Bugs/Incompatibilities</H1>
+
+<P><I>PolyglotMan</I> is not perfect in all cases, but it usually does a
+good job, and in any case reduces the problem of converting man pages
+to light editing.</P>
+
+<P>Tables in formatted pages, especially H-P's, aren't handled very well.
+Be sure to pass in source for the page to recognize tables.</P>
+
+<P>The man pager <I>woman</I> applies its own idea of formatting for
+man pages, which can confuse <I>PolyglotMan</I>. Bypass <I>woman</I>
+by passing the formatted manual page text directly into
+<I>PolyglotMan</I>.</P>
+
+<P>The [tn]roff output format uses fB to turn on boldface. If your macro set
+requires .B, you'll have to a postprocess the <I>PolyglotMan</I> output.</P>
+
+
+<H1>See Also</H1>
+
+<tt>tkman(1)</tt>, <tt>xman(1)</tt>, <tt>man(1)</tt>, <tt>man(7)</tt> or <tt>man(5)</tt> depending on your flavor of UNIX
+
+<H1>Author</H1>
+
+<P>PolyglotMan<BR>
+by Thomas A. Phelps (<tt>phelps@ACM.org</tt>)<BR>
+developed at the<BR>
+University of California, Berkeley<BR>
+Computer Science Division
+
+<P>Manual page last updated on $Date: 2000/07/10 20:49:21 $
+
+</BODY></HTML>
diff --git a/xc/lib/GL/mesa/src/drv/ffb/Imakefile b/xc/lib/GL/mesa/src/drv/ffb/Imakefile
new file mode 100644
index 000000000..06fbd148c
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/Imakefile
@@ -0,0 +1,234 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/ffb/Imakefile,v 1.3 2000/06/25 14:44:26 alanh Exp $
+
+#include <Threads.tmpl>
+
+#define DoNormalLib NormalLibGlx
+#define DoSharedLib SharedLibGlx
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines -DDRIVERTS
+ DRI_INCLUDES = -I../../../../dri -I../../../../glx \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
+ -I$(XF86DRIVERSRC)/sunffb \
+ -I../../../include -I../.. -I../../X -I../common \
+ -I../../../dri \
+ -I$(XF86OSSRC)/linux/drm/kernel
+#endif
+
+MESA_INCLUDES = -I. -I.. -I../../include
+
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRISRCS = ../../../dri/dri_mesa.c \
+ ../../../../dri/dri_tmm.c
+
+ DRIOBJS = ../../../dri/dri_mesa.o \
+ ../../../../dri/dri_tmm.o
+
+ DRMSRCS = ../../../../dri/drm/xf86drm.c \
+ ../../../../dri/drm/xf86drmHash.c \
+ ../../../../dri/drm/xf86drmRandom.c \
+ ../../../../dri/drm/xf86drmSL.c
+
+ DRMOBJS = ../../../../dri/drm/xf86drm.o \
+ ../../../../dri/drm/xf86drmHash.o \
+ ../../../../dri/drm/xf86drmRandom.o \
+ ../../../../dri/drm/xf86drmSL.o
+
+ MESASRCS = ../../aatriangle.c \
+ ../../accum.c \
+ ../../alpha.c \
+ ../../alphabuf.c \
+ ../../attrib.c \
+ ../../bbox.c \
+ ../../bitmap.c \
+ ../../blend.c \
+ ../../buffers.c \
+ ../../clip.c \
+ ../../colortab.c \
+ ../../config.c \
+ ../../context.c \
+ ../../copypix.c \
+ ../../cva.c \
+ ../../debug_xform.c \
+ ../../depth.c \
+ ../../dlist.c \
+ ../../drawpix.c \
+ ../../enable.c \
+ ../../enums.c \
+ ../../eval.c \
+ ../../extensions.c \
+ ../../feedback.c \
+ ../../fog.c \
+ ../../get.c \
+ ../../glapi.c \
+ ../../glapinoop.c \
+ ../../glthread.c \
+ ../../hash.c \
+ ../../image.c \
+ ../../imaging.c \
+ ../../light.c \
+ ../../lines.c \
+ ../../logic.c \
+ ../../masking.c \
+ ../../matrix.c \
+ ../../mem.c \
+ ../../mmath.c \
+ ../../pb.c \
+ ../../pipeline.c \
+ ../../pixel.c \
+ ../../pixeltex.c \
+ ../../points.c \
+ ../../polygon.c \
+ ../../quads.c \
+ ../../rastpos.c \
+ ../../readpix.c \
+ ../../rect.c \
+ ../../scissor.c \
+ ../../shade.c \
+ ../../span.c \
+ ../../stages.c \
+ ../../state.c \
+ ../../stencil.c \
+ ../../teximage.c \
+ ../../texobj.c \
+ ../../texstate.c \
+ ../../texture.c \
+ ../../texutil.c \
+ ../../translate.c \
+ ../../triangle.c \
+ ../../varray.c \
+ ../../vb.c \
+ ../../vbcull.c \
+ ../../vbfill.c \
+ ../../vbindirect.c \
+ ../../vbrender.c \
+ ../../vbxform.c \
+ ../../vector.c \
+ ../../vertices.c \
+ ../../winpos.c \
+ ../../xform.c \
+ ../../zoom.c
+
+ MESAOBJS = ../../aatriangle.o \
+ ../../accum.o \
+ ../../alpha.o \
+ ../../alphabuf.o \
+ ../../attrib.o \
+ ../../bbox.o \
+ ../../bitmap.o \
+ ../../blend.o \
+ ../../buffers.o \
+ ../../clip.o \
+ ../../colortab.o \
+ ../../config.o \
+ ../../context.o \
+ ../../copypix.o \
+ ../../cva.o \
+ ../../debug_xform.o \
+ ../../depth.o \
+ ../../dlist.o \
+ ../../drawpix.o \
+ ../../enable.o \
+ ../../enums.o \
+ ../../eval.o \
+ ../../extensions.o \
+ ../../feedback.o \
+ ../../fog.o \
+ ../../get.o \
+ ../../hash.o \
+ ../../hint.o \
+ ../../image.o \
+ ../../imaging.o \
+ ../../light.o \
+ ../../lines.o \
+ ../../logic.o \
+ ../../masking.o \
+ ../../matrix.o \
+ ../../mem.o \
+ ../../mmath.o \
+ ../../pb.o \
+ ../../pipeline.o \
+ ../../pixel.o \
+ ../../pixeltex.o \
+ ../../points.o \
+ ../../polygon.o \
+ ../../quads.o \
+ ../../rastpos.o \
+ ../../readpix.o \
+ ../../rect.o \
+ ../../scissor.o \
+ ../../shade.o \
+ ../../span.o \
+ ../../stages.o \
+ ../../state.o \
+ ../../stencil.o \
+ ../../teximage.o \
+ ../../texobj.o \
+ ../../texstate.o \
+ ../../texture.o \
+ ../../texutil.o \
+ ../../translate.o \
+ ../../triangle.o \
+ ../../varray.o \
+ ../../vb.o \
+ ../../vbcull.o \
+ ../../vbfill.o \
+ ../../vbindirect.o \
+ ../../vbrender.o \
+ ../../vbxform.o \
+ ../../vector.o \
+ ../../vertices.o \
+ ../../winpos.o \
+ ../../xform.o \
+ ../../zoom.o
+
+ FFBSRCS = ffb_dd.c ffb_span.c ffb_depth.c ffb_state.c ffb_clear.c ffb_vb.c \
+ ffb_lines.c ffb_points.c ffb_tris.c ffb_pipeline.c \
+ ffb_stencil.c ffb_xmesa.c
+
+ FFBOBJS = ffb_dd.o ffb_span.o ffb_depth.o ffb_state.o ffb_clear.o ffb_vb.o \
+ ffb_lines.o ffb_points.o ffb_tris.o ffb_pipeline.o \
+ ffb_stencil.o ffb_xmesa.o
+
+ SRCS = $(FFBSRCS) $(DRISRCS) $(DRMSRCS) $(MESASRCS)
+ OBJS = $(FFBOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS)
+
+REQUIREDLIBS += -lm
+#if !GlxBuiltInFfb
+REQUIREDLIBS += -L../../../.. -lGL
+#endif
+
+#if !GlxUseBuiltInDRIDriver
+#undef DoNormalLib NormalLibGlx
+#undef DoExtraLib SharedLibGlx
+#undef DoDebugLib DebugLibGlx
+#undef DoProfileLib ProfileLibGlx
+#endif
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver
+LIBNAME = ffb_dri.so
+ALL_OBJS = $(OBJS)
+ALL_DEPS = DONE
+SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+#endif
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c
new file mode 100644
index 000000000..3f3097327
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c
@@ -0,0 +1,348 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c,v 1.1 2000/06/20 05:08:37 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "vbrender.h"
+
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_clear.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+#include "vb.h"
+#include "dd.h"
+
+#define BOX_AREA(__w, __h) ((int)(__w) * (int)(__h))
+
+/* Compute the page aligned box for a page mode fast fill.
+ * In 'ework' this returns greater than zero if there are some odd
+ * edges to take care of which are outside of the page aligned area.
+ * It will place less than zero there if the box is too small,
+ * indicating that a different method must be used to fill it.
+ */
+#define CreatorPageFillParms(ffp, x, y, w, h, px, py, pw, ph, ework) \
+do { int xdiff, ydiff; \
+ int pf_bh = ffp->pagefill_height; \
+ int pf_bw = ffp->pagefill_width; \
+ py = ((y + (pf_bh - 1)) & ~(pf_bh - 1)); \
+ ydiff = py - y; \
+ px = ffp->Pf_AlignTab[x + (pf_bw - 1)]; \
+ xdiff = px - x; \
+ ph = ((h - ydiff) & ~(pf_bh - 1)); \
+ if(ph <= 0) \
+ ework = -1; \
+ else { \
+ pw = ffp->Pf_AlignTab[w - xdiff]; \
+ if(pw <= 0) { \
+ ework = -1; \
+ } else { \
+ ework = (((xdiff > 0) || \
+ (ydiff > 0) || \
+ ((w - pw) > 0) || \
+ ((h - ph) > 0))) ? 1 : 0; \
+ } \
+ } \
+} while(0);
+
+struct ff_fixups {
+ int x, y, width, height;
+};
+
+/* Compute fixups of non-page aligned areas after a page fill.
+ * Return the number of fixups needed.
+ */
+static __inline__ int
+CreatorComputePageFillFixups(struct ff_fixups *fixups,
+ int x, int y, int w, int h,
+ int paligned_x, int paligned_y,
+ int paligned_w, int paligned_h)
+{
+ int nfixups = 0;
+
+ /* FastFill Left */
+ if(paligned_x != x) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = paligned_y;
+ fixups[nfixups].width = paligned_x - x;
+ fixups[nfixups].height = paligned_h;
+ nfixups++;
+ }
+ /* FastFill Top */
+ if(paligned_y != y) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = y;
+ fixups[nfixups].width = w;
+ fixups[nfixups].height = paligned_y - y;
+ nfixups++;
+ }
+ /* FastFill Right */
+ if((x+w) != (paligned_x+paligned_w)) {
+ fixups[nfixups].x = (paligned_x+paligned_w);
+ fixups[nfixups].y = paligned_y;
+ fixups[nfixups].width = (x+w) - fixups[nfixups].x;
+ fixups[nfixups].height = paligned_h;
+ nfixups++;
+ }
+ /* FastFill Bottom */
+ if((y+h) != (paligned_y+paligned_h)) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = (paligned_y+paligned_h);
+ fixups[nfixups].width = w;
+ fixups[nfixups].height = (y+h) - fixups[nfixups].y;
+ nfixups++;
+ }
+ return nfixups;
+}
+
+static void
+ffb_do_clear(ffbContextPtr fmesa, __DRIdrawablePrivate *dPriv,
+ GLboolean all, GLint cx, GLint cy, GLint cwidth,
+ GLint cheight)
+{
+ FFBDRIPtr gDRIPriv = (FFBDRIPtr) fmesa->driScreen->pDevPriv;
+ ffb_fbcPtr ffb = fmesa->regs;
+ XF86DRIClipRectPtr box = dPriv->pClipRects;
+ int nc = dPriv->numClipRects;
+
+ cy = dPriv->h - cy - cheight;
+ cx += dPriv->x;
+ cy += dPriv->y;
+
+ while (nc--) {
+ GLint x = box[nc].x1;
+ GLint y = box[nc].y1;
+ GLint width = box[nc].x2 - x;
+ GLint height = box[nc].y2 - y;
+ int paligned_y, paligned_x;
+ int paligned_h, paligned_w = 0;
+ int extra_work;
+
+ if (!all) {
+ if (x < cx) {
+ width -= cx - x;
+ x = cx;
+ }
+ if (y < cy) {
+ height -= cy - y;
+ y = cy;
+ }
+ if (x + width > cx + cwidth)
+ width = cx + cwidth - x;
+ if (y + height > cy + cheight)
+ height = cy + cheight - y;
+ if (width <= 0)
+ continue;
+ if (height <= 0)
+ continue;
+ }
+
+ if (BOX_AREA(width, height) < gDRIPriv->fastfill_small_area) {
+ FFBFifo(fmesa, 5);
+ ffb->drawop = FFB_DRAWOP_RECTANGLE;
+ ffb->by = y;
+ ffb->bx = x;
+ ffb->bh = height;
+ ffb->bw = width;
+ continue;
+ }
+
+ FFBFifo(fmesa, 1);
+ ffb->drawop = FFB_DRAWOP_FASTFILL;
+
+ if (gDRIPriv->disable_pagefill ||
+ (width < (gDRIPriv->pagefill_width<<1)) ||
+ (height < (gDRIPriv->pagefill_height<<1)))
+ goto do_fastfill;
+
+ CreatorPageFillParms(gDRIPriv,
+ x, y, width, height,
+ paligned_x, paligned_y,
+ paligned_w, paligned_h, extra_work);
+
+ if (extra_work < 0 ||
+ BOX_AREA(paligned_w, paligned_h) < gDRIPriv->pagefill_small_area) {
+ do_fastfill:
+ FFBFifo(fmesa, 10);
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ ffb->dy = 0;
+ ffb->dx = 0;
+ ffb->bh = gDRIPriv->fastfill_height;
+ ffb->bw = (gDRIPriv->fastfill_width * 4);
+ ffb->by = FFB_FASTFILL_BLOCK;
+ ffb->dy = y;
+ ffb->dx = x;
+ ffb->bh = (height + (y & (gDRIPriv->fastfill_height - 1)));
+ ffb->bx = (width + (x & (gDRIPriv->fastfill_width - 1)));
+ continue;
+ }
+
+ /* Ok, page fill is possible and worth it. */
+ FFBFifo(fmesa, 15);
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ ffb->dy = 0;
+ ffb->dx = 0;
+ ffb->bh = gDRIPriv->fastfill_height;
+ ffb->bw = gDRIPriv->fastfill_width * 4;
+ ffb->by = FFB_FASTFILL_BLOCK_X;
+ ffb->dy = 0;
+ ffb->dx = 0;
+ ffb->bh = gDRIPriv->pagefill_height;
+ ffb->bw = gDRIPriv->pagefill_width * 4;
+ ffb->by = FFB_FASTFILL_PAGE;
+ ffb->dy = paligned_y;
+ ffb->dx = paligned_x;
+ ffb->bh = paligned_h;
+ ffb->bx = paligned_w;
+
+ if (extra_work) {
+ struct ff_fixups local_fixups[4];
+ int nfixups;
+
+ nfixups = CreatorComputePageFillFixups(local_fixups,
+ x, y, width, height,
+ paligned_x, paligned_y,
+ paligned_w, paligned_h);
+ FFBFifo(fmesa, 5 + (nfixups * 5));
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ ffb->dy = 0;
+ ffb->dx = 0;
+ ffb->bh = gDRIPriv->fastfill_height;
+ ffb->bw = gDRIPriv->fastfill_width * 4;
+
+ while (--nfixups >= 0) {
+ int xx, yy, ww, hh;
+
+ xx = local_fixups[nfixups].x;
+ yy = local_fixups[nfixups].y;
+ ffb->dy = yy;
+ ffb->dx = xx;
+ ww = (local_fixups[nfixups].width +
+ (xx & (gDRIPriv->fastfill_width - 1)));
+ hh = (local_fixups[nfixups].height +
+ (yy & (gDRIPriv->fastfill_height - 1)));
+ if (nfixups != 0) {
+ ffb->by = FFB_FASTFILL_BLOCK;
+ ffb->bh = hh;
+ ffb->bw = ww;
+ } else {
+ ffb->bh = hh;
+ ffb->by = FFB_FASTFILL_BLOCK;
+ ffb->bx = ww;
+ }
+ }
+ }
+ }
+}
+
+GLbitfield ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cwidth, GLint cheight)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ unsigned int stcmask = DD_STENCIL_BIT;
+
+ if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS))
+ stcmask = 0;
+
+ if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT | stcmask)) {
+ ffb_fbcPtr ffb = fmesa->regs;
+ unsigned int fbc, ppc;
+
+ fbc = (FFB_FBC_XE_ON);
+ ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE |
+ FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_DISABLE |
+ FFB_PPC_APE_DISABLE | FFB_PPC_XS_WID |
+ FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
+
+ /* Y/X enables must be both on or both off. */
+ if (mask & (DD_DEPTH_BIT | stcmask)) {
+ fbc |= (FFB_FBC_ZE_ON | FFB_FBC_YE_ON | FFB_FBC_WB_C);
+ } else
+ fbc |= FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF;
+
+ /* All RGB enables must be both on or both off. */
+ if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
+ if (mask & DD_FRONT_LEFT_BIT) {
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_WB_B;
+ else
+ fbc |= FFB_FBC_WB_A;
+ }
+ if (mask & DD_BACK_LEFT_BIT) {
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_WB_A;
+ else
+ fbc |= FFB_FBC_WB_B;
+ }
+ fbc |= FFB_FBC_RGBE_ON;
+ } else
+ fbc |= FFB_FBC_RGBE_OFF;
+
+ LOCK_HARDWARE(fmesa);
+
+ if (dPriv->numClipRects) {
+ FFBFifo(fmesa, 8);
+ ffb->fbc = fbc;
+ ffb->ppc = ppc;
+ ffb->xclip = FFB_XCLIP_TEST_ALWAYS;
+ ffb->cmp = 0x80808080;
+ ffb->rop = FFB_ROP_NEW;
+
+ if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT))
+ ffb->fg = fmesa->clear_pixel;
+ if (mask & DD_DEPTH_BIT)
+ ffb->constz = fmesa->clear_depth;
+ if (mask & stcmask)
+ ffb->consty = fmesa->clear_stencil;
+
+ ffb_do_clear(fmesa, dPriv, all, cx, cy, cwidth, cheight);
+
+ FFBFifo(fmesa, 6);
+ ffb->ppc = fmesa->ppc;
+ ffb->fbc = fmesa->fbc;
+ ffb->xclip = fmesa->xclip;
+ ffb->cmp = fmesa->cmp;
+ ffb->rop = fmesa->rop;
+ ffb->drawop = fmesa->drawop;
+ if (mask & stcmask)
+ ffb->consty = fmesa->consty;
+ fmesa->ffbScreen->rp_active = 1;
+ }
+
+ UNLOCK_HARDWARE(fmesa);
+
+ mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT |
+ DD_DEPTH_BIT | stcmask);
+ }
+
+ return mask;
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h
new file mode 100644
index 000000000..29f197399
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h
@@ -0,0 +1,9 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h,v 1.1 2000/06/20 05:08:38 dawes Exp $ */
+
+#ifndef _FFB_CLEAR_H
+#define _FFB_CLEAR_H
+
+extern GLbitfield ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cwidth, GLint cheight);
+
+#endif /* !(_FFB_CLEAR_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h
new file mode 100644
index 000000000..af0d0e2c6
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h
@@ -0,0 +1,197 @@
+#ifndef _FFB_CONTEXT_H
+#define _FFB_CONTEXT_H
+
+#include <X11/Xlibint.h>
+#include "dri_mesaint.h"
+#include "dri_mesa.h"
+
+#include "types.h"
+
+#include "ffb_xmesa.h"
+
+typedef struct ffb_context_t {
+ GLcontext *glCtx;
+ GLuint MonoColor;
+ GLframebuffer *glBuffer;
+
+ ffb_fbcPtr regs;
+ volatile char *sfb32;
+
+ int hw_locked;
+ int SWrender;
+
+ int back_buffer; /* 0 = bufferA, 1 = bufferB */
+
+ /* Because MESA does not send us the raw primitives,
+ * we send everything to the chip as independant lines,
+ * points, tris, and quads. If we could get the real
+ * primitive being used by the user, we can optimize
+ * things a lot. This is particularly useful for
+ * tri strips/fans, and quad strips/fans as FFB
+ * specifically can optimize these cases.
+ *
+ * I suspect MESA does not preserve things to make it's
+ * transformation/clip/cull optimizations simpler.
+ *
+ * Anyways, to try and get around this, we record the
+ * vertices used in the most recent primitive and we
+ * detect tri strips/fans and quad strips/fans this
+ * way. Actually, we only need to record the ffb_vertex
+ * pointers, and this makes the tests cheaper and the
+ * flushing faster (at VB updates and reduced primitive
+ * changes).
+ */
+ void *vtx_cache[4];
+
+ /* This records state bits when a per-fragment attribute has
+ * been set which prevents us from rendering in hardware.
+ *
+ * As attributes change, some of these bits may clear as
+ * we move back within the chips capabilities. If they
+ * all clear, we return to full hw rendering.
+ */
+ unsigned int bad_fragment_attrs;
+#define FFB_BADATTR_FOG 0x00000001 /* Bad fog possible only when < FFB2 */
+#define FFB_BADATTR_BLENDFUNC 0x00000002 /* Any non-const func based upon dst alpha */
+#define FFB_BADATTR_BLENDROP 0x00000004 /* Blend enabled and LogicOP != GL_COPY */
+#define FFB_BADATTR_BLENDEQN 0x00000008 /* Blend equation other than ADD */
+#define FFB_BADATTR_STENCIL 0x00000010 /* Stencil enabled when < FFB2+ */
+
+ unsigned int state_dirty;
+ unsigned int state_fifo_ents;
+#define FFB_STATE_FBC 0x00000001
+#define FFB_STATE_PPC 0x00000002
+#define FFB_STATE_DRAWOP 0x00000004
+#define FFB_STATE_ROP 0x00000008
+#define FFB_STATE_LPAT 0x00000010
+#define FFB_STATE_PMASK 0x00000020
+#define FFB_STATE_XPMASK 0x00000040
+#define FFB_STATE_YPMASK 0x00000080
+#define FFB_STATE_ZPMASK 0x00000100
+#define FFB_STATE_XCLIP 0x00000200
+#define FFB_STATE_CMP 0x00000400
+#define FFB_STATE_MATCHAB 0x00000800
+#define FFB_STATE_MAGNAB 0x00001000
+#define FFB_STATE_MATCHC 0x00002000
+#define FFB_STATE_MAGNC 0x00004000
+#define FFB_STATE_DCUE 0x00008000
+#define FFB_STATE_BLEND 0x00010000
+#define FFB_STATE_CLIP 0x00020000
+#define FFB_STATE_STENCIL 0x00040000
+#define FFB_STATE_APAT 0x00080000
+#define FFB_STATE_WID 0x00100000
+#define FFB_STATE_ALL 0x001fffff
+
+ unsigned int state_all_fifo_ents;
+
+ /* General hw reg state. */
+ unsigned int fbc;
+ unsigned int ppc;
+ unsigned int drawop;
+ unsigned int rop;
+
+ unsigned int lpat;
+#define FFB_LPAT_BAD 0xffffffff
+
+ unsigned int wid;
+ unsigned int pmask;
+ unsigned int xpmask;
+ unsigned int ypmask;
+ unsigned int zpmask;
+ unsigned int xclip;
+ unsigned int cmp;
+ unsigned int matchab;
+ unsigned int magnab;
+ unsigned int matchc;
+ unsigned int magnc;
+
+ /* Depth cue unit hw reg state. */
+ unsigned int dcss; /* All FFB */
+ unsigned int dcsf; /* All FFB */
+ unsigned int dcsb; /* All FFB */
+ unsigned int dczf; /* All FFB */
+ unsigned int dczb; /* All FFB */
+ unsigned int dcss1; /* >=FFB2 only */
+ unsigned int dcss2; /* >=FFB2 only */
+ unsigned int dcss3; /* >=FFB2 only */
+ unsigned int dcs2; /* >=FFB2 only */
+ unsigned int dcs3; /* >=FFB2 only */
+ unsigned int dcs4; /* >=FFB2 only */
+ unsigned int dcd2; /* >=FFB2 only */
+ unsigned int dcd3; /* >=FFB2 only */
+ unsigned int dcd4; /* >=FFB2 only */
+
+ /* Blend unit hw reg state. */
+ unsigned int blendc;
+ unsigned int blendc1;
+ unsigned int blendc2;
+
+ /* ViewPort clipping hw reg state. */
+ unsigned int vclipmin;
+ unsigned int vclipmax;
+ unsigned int vclipzmin;
+ unsigned int vclipzmax;
+ struct {
+ unsigned int min;
+ unsigned int max;
+ } aux_clips[4];
+
+ /* Stencil control hw reg state. >=FFB2+ only. */
+ unsigned int stencil;
+ unsigned int stencilctl;
+ unsigned int consty; /* Stencil Ref */
+
+ /* Area pattern (used for polygon stipples). */
+ unsigned int pattern[32];
+
+ /* Fog state. */
+ float Znear, Zfar;
+
+ drmContext hHWContext;
+ drmLock *driHwLock;
+ int driFd;
+ Display *display;
+
+ unsigned int clear_pixel;
+ unsigned int clear_depth;
+ unsigned int clear_stencil;
+
+ unsigned int setupindex;
+ unsigned int setupdone;
+
+ /* Rendering functions. */
+ points_func PointsFunc;
+ line_func LineFunc;
+ triangle_func TriangleFunc;
+ quad_func QuadFunc;
+
+ __DRIdrawablePrivate *driDrawable;
+ __DRIscreenPrivate *driScreen;
+ ffbScreenPrivate *ffbScreen;
+ ffb_dri_state_t *ffb_sarea;
+} ffbContextRec, *ffbContextPtr;
+
+#define FFB_CONTEXT(ctx) ((ffbContextPtr)((ctx)->DriverCtx))
+
+/* We want the depth values written during software rendering
+ * to match what the hardware is going to put there when we
+ * hw render.
+ *
+ * The Z buffer is 28 bits deep. Smooth shaded primitives
+ * specify a 2:30 signed fixed point Z value in the range 0.0
+ * to 1.0 inclusive.
+ *
+ * So for example, when hw rendering, the largest Z value of
+ * 1.0 would produce a value of 0x0fffffff in the actual Z
+ * buffer, which is the maximum value.
+ *
+ * Mesa's depth type is a 32-bit int, so we use the following macro
+ * to convert to/from FFB hw Z values. Note we also have to clear
+ * out the top bits as that is where the Y (stencil) buffer is stored
+ * and during hw Z buffer reads it is always there. (During writes
+ * we tell the hw to discard those top 4 bits).
+ */
+#define Z_TO_MESA(VAL) ((GLdepth)(((VAL) & 0x0fffffff) << (32 - 28)))
+#define Z_FROM_MESA(VAL) (((GLuint)(VAL)) >> (32 - 28))
+
+#endif /* !(_FFB_CONTEXT_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c
new file mode 100644
index 000000000..8b06ef77b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c
@@ -0,0 +1,123 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c,v 1.1 2000/06/20 05:08:38 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "vbrender.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_clear.h"
+#include "ffb_pipeline.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+#include "vb.h"
+#include "dd.h"
+
+/* Mesa's Driver Functions */
+
+static const GLubyte *ffbDDGetString(GLcontext *ctx, GLenum name)
+{
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *) "David S. Miller";
+ case GL_RENDERER:
+ return (GLubyte *) "DRI-FFB";
+ default:
+ return NULL;
+ };
+}
+
+static GLint ffbGetParameteri(const GLcontext *ctx, GLint param)
+{
+ switch (param) {
+ case DD_HAVE_HARDWARE_FOG:
+ /* XXX We have per-fragment fog, once fog code is done,
+ * XXX set this.
+ */
+ return 0;
+ default:
+#if 0
+ ffbError("ffbGetParameteri(): unknown parameter!\n");
+#endif
+ return 0;
+ };
+}
+
+static void ffbBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+/* LOCK_HARDWARE(fmesa); */
+ *width = fmesa->driDrawable->w;
+ *height = fmesa->driDrawable->h;
+/* UNLOCK_HARDWARE(fmesa); */
+}
+
+void ffbDDExtensionsInit(GLcontext *ctx)
+{
+ /* Nothing for now until we start to add
+ * real acceleration. -DaveM
+ */
+
+ /* XXX Need to turn off GL_EXT_blend_func_separate for one.
+ * XXX Also BlendEquation should be turned off too, what
+ * XXX EXT is that assosciated with?
+ */
+}
+
+static void ffbDDFinish(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ LOCK_HARDWARE(fmesa);
+ FFBWait(fmesa, fmesa->regs);
+ UNLOCK_HARDWARE(fmesa);
+}
+
+void ffbDDInitDriverFuncs(GLcontext *ctx)
+{
+ ctx->Driver.GetBufferSize = ffbBufferSize;
+ ctx->Driver.GetString = ffbDDGetString;
+ ctx->Driver.GetParameteri = ffbGetParameteri;
+ ctx->Driver.Clear = ffbDDClear;
+
+ ctx->Driver.Finish = ffbDDFinish;
+
+ /* VB hooks */
+ ctx->Driver.RegisterVB = ffbDDRegisterVB;
+ ctx->Driver.UnregisterVB = ffbDDUnregisterVB;
+
+ ctx->Driver.BuildPrecalcPipeline = ffbDDBuildPrecalcPipeline;
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.h
new file mode 100644
index 000000000..4ffcbe666
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.h
@@ -0,0 +1,36 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_dd.h,v 1.1 2000/06/20 05:08:38 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D.
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#ifndef _FFB_DD_H
+#define _FFB_DD_H
+
+#include "context.h"
+
+void ffbDDInitDriverFuncs(GLcontext *ctx);
+void ffbDDExtensionsInit(GLcontext *ctx);
+
+#endif /* !(_FFB_DD_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c
new file mode 100644
index 000000000..678dfff7f
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c
@@ -0,0 +1,192 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c,v 1.1 2000/06/20 05:08:38 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_context.h"
+#include "ffb_depth.h"
+#include "ffb_lock.h"
+
+static void
+FFBWriteDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLdepth depth[], const GLubyte mask[])
+{
+ if (ctx->Depth.Mask) {
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint *zptr;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_ON |
+ FFB_FBC_YE_OFF | FFB_FBC_RGBE_OFF);
+ fmesa->regs->ppc = FFB_PPC_ZS_VAR;
+ FFBWait(fmesa, fmesa->regs);
+
+ y = (dPriv->h - y);
+ zptr = (GLuint *)
+ ((char *)fmesa->sfb32 +
+ ((dPriv->x + x) << 2) +
+ ((dPriv->y + y) << 13));
+
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ *zptr = Z_FROM_MESA(depth[i]);
+ }
+ zptr++;
+ }
+
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->regs->ppc = fmesa->ppc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+ }
+}
+
+static void
+FFBWriteDepthPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
+ const GLdepth depth[], const GLubyte mask[])
+{
+ if (ctx->Depth.Mask) {
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ char *zbase;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_ON |
+ FFB_FBC_YE_OFF | FFB_FBC_RGBE_OFF);
+ fmesa->regs->ppc = FFB_PPC_ZS_VAR;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ zbase = ((char *)fmesa->sfb32 +
+ (dPriv->x << 2) + (dPriv->y << 13));
+
+ for (i = 0; i < n; i++) {
+ GLint y1 = (dPriv->h - y[i]);
+ GLint x1 = x[i];
+ GLuint *zptr;
+
+ zptr = (GLuint *)
+ (zbase + (x1 << 2) + (y1 << 13));
+ if (mask[i])
+ *zptr = Z_FROM_MESA(depth[i]);
+ }
+
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->regs->ppc = fmesa->ppc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+ }
+}
+
+static void
+FFBReadDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth depth[])
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint *zptr;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = FFB_FBC_RB_C;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ y = (dPriv->h - y);
+ zptr = (GLuint *)
+ ((char *)fmesa->sfb32 +
+ ((dPriv->x + x) << 2) +
+ ((dPriv->y + y) << 13));
+
+ for (i = 0; i < n; i++) {
+ depth[i] = Z_TO_MESA(*zptr);
+ zptr++;
+ }
+
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+}
+
+static void
+FFBReadDepthPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
+ GLdepth depth[])
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ char *zbase;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = FFB_FBC_RB_C;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ zbase = ((char *)fmesa->sfb32 +
+ (dPriv->x << 2) + (dPriv->y << 13));
+
+ for (i = 0; i < n; i++) {
+ GLint y1 = (dPriv->h - y[i]);
+ GLint x1 = x[i];
+ GLuint *zptr;
+
+ zptr = (GLuint *)
+ (zbase + (x1 << 2) + (y1 << 13));
+ depth[i] = Z_TO_MESA(*zptr);
+ }
+
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+}
+
+void ffbDDInitDepthFuncs(GLcontext *ctx)
+{
+ ctx->Driver.WriteDepthSpan = FFBWriteDepthSpan;
+ ctx->Driver.ReadDepthSpan = FFBReadDepthSpan;
+ ctx->Driver.WriteDepthPixels = FFBWriteDepthPixels;
+ ctx->Driver.ReadDepthPixels = FFBReadDepthPixels;
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.h
new file mode 100644
index 000000000..a098bfcc2
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_depth.h,v 1.1 2000/06/20 05:08:38 dawes Exp $ */
+
+#ifndef _FFB_DEPTH_H
+#define _FFB_DEPTH_H
+
+extern void ffbDDInitDepthFuncs(GLcontext *ctx);
+
+#endif /* !(_FFB_DEPTH_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h
new file mode 100644
index 000000000..b78c7e5b6
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h
@@ -0,0 +1,28 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h,v 1.1 2000/06/20 05:08:38 dawes Exp $ */
+
+#ifndef _FFB_FIFO_H
+#define _FFB_FIFO_H
+
+#define FFBFifo(__fmesa, __n) \
+do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \
+ int __cur_slots = __fScrn->fifo_cache; \
+ if ((__cur_slots - (__n)) < 0) { \
+ ffb_fbcPtr __ffb = __fmesa->regs; \
+ do { __cur_slots = (((int)__ffb->ucsr & FFB_UCSR_FIFO_MASK) - 4); \
+ } while ((__cur_slots - (__n)) < 0); \
+ } (__fScrn)->fifo_cache = (__cur_slots - (__n)); \
+} while(0)
+
+#define FFBWait(__fmesa, __ffb) \
+do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \
+ if (__fScrn->rp_active) { \
+ unsigned int __regval = (__ffb)->ucsr; \
+ while((__regval & FFB_UCSR_RP_BUSY) != 0) { \
+ __regval = (__ffb)->ucsr; \
+ } \
+ __fScrn->fifo_cache = ((int)(__regval & FFB_UCSR_FIFO_MASK)) - 4; \
+ __fScrn->rp_active = 0; \
+ } \
+} while(0)
+
+#endif /* !(_FFB_FIFO_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_fog.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_fog.c
new file mode 100644
index 000000000..e6eca2390
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_fog.c
@@ -0,0 +1,73 @@
+
+/* FFB fog support:
+ *
+ * There are two levels of support for FOG in the Creator3D series.
+ * Both involve a depth cue unit and 1 or 4 slope factors and scales
+ * for varying the pixel intensity.
+ *
+ * Chips prior to FFB2 only have a single set of such settings, FFB2
+ * and later have 4 settings.
+ *
+ * The basic depth cueing equation is:
+ *
+ * C_final = dcsf(z) * C_orig + (1 - dcsf(z)) * C_fog
+ *
+ * C_final -- The final color passed to blend unit or frame
+ * buffer (if blending is disabled).
+ *
+ * C_orig -- The color we start with, which comes either from
+ * the raster processor or cpu writes to the smart
+ * framebuffer aperture.
+ *
+ * C_fog -- This is the "fog" color, ie. the desired color
+ * at the deepest Z.
+ *
+ * dcsf(z) -- The depth cue scale as a function of Z.
+ *
+ * With pre-FFB2 chips there are four parameters to control the depth
+ * cue scaling. Here is a diagram:
+ *
+ * 1.0 -------------
+ * | | | |
+ * | | | |
+ * Sfront XXXXX---+---+
+ * | |X | |
+ * dcsf(z) | | X | |
+ * | | X| |
+ * Sback +---+---XXXXX
+ * | | | |
+ * 0.0 -------------
+ * 0.0 Zf Zb 1.0
+ *
+ * z
+ * Therefore:
+ *
+ * for Zf < z < Zb
+ *
+ * dcsf(z) = Sback + ((Sfront - Sback) / (Zf - Zb)) * (Zb - z)
+ *
+ * for z <= Zf
+ *
+ * dcsf(z) = Sfront
+ *
+ * for z >= Zb
+ *
+ * dcsf(z) = Sback
+ *
+ * With FFB2 and later, 3 more slope regions are provided, the first of
+ * them starts at the end of the region defined above and ends at a
+ * specified depth value, the next slop region starts there and ends
+ * at the next specified depth value, and so on. Each of the 3 slope
+ * regions also have scale and slope settings of their own.
+ *
+ * The C_fog color is programmed into the alpha blending unit color1
+ * and color2 registers as follows:
+ *
+ * color1: -(C_fog)
+ * color2: C_fog - bg
+ *
+ * If alpha blending is disabled, the bg factor is zero. Note that
+ * the alpha blending color registers specify each of the RGB values
+ * as 9 bit 1:8 signed numbers in the range -1.00 to 0.ff inclusive.
+ * (ie. 0x100 == -1.00 and 0x0ff == +0.ff)
+ */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c
new file mode 100644
index 000000000..180f10422
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c
@@ -0,0 +1,275 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c,v 1.1 2000/06/20 05:08:38 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "vbrender.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_lines.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+#include "vb.h"
+#include "dd.h"
+#include "pipeline.h"
+
+#define FFB_LINE_FLAT_BIT 0x01
+#define FFB_LINE_TWOSIDE_BIT 0x02
+#define FFB_LINE_OFFSET_BIT 0x04
+#define FFB_LINE_WIDE_BIT 0x08
+#define FFB_LINE_ALPHA_BIT 0x10
+#define FFB_LINE_FALLBACK_BIT 0x20
+
+static line_func ffb_line_tab[0x40];
+
+/* If the line is not wide, we can support all of the line
+ * patterning and smooth shading features of OpenGL fully.
+ * If it is wide we use triangles to render them and as such
+ * we lose the capability to do the patterning+shading in HW.
+ *
+ * XXX Actually, with the triangle method we can probably do
+ * XXX the shading/antialiasing too if we are careful. It might
+ * XXX not work, need to investigate this. -DaveM
+ */
+
+#define IND (0)
+#define TAG(x) x
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_TWOSIDE_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_WIDE_BIT)
+#define TAG(x) x##_wide
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_wide_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_OFFSET_BIT)
+#define TAG(x) x##_wide_offset
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_wide_offset_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT)
+#define TAG(x) x##_wide_twoside
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_wide_twoside_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT)
+#define TAG(x) x##_wide_twoside_offset
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_wide_twoside_offset_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_OFFSET_BIT)
+#define TAG(x) x##_alpha_offset
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_offset_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_TWOSIDE_BIT)
+#define TAG(x) x##_alpha_twoside
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_twoside_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT)
+#define TAG(x) x##_alpha_twoside_offset
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_twoside_offset_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT)
+#define TAG(x) x##_alpha_wide
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_wide_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_OFFSET_BIT)
+#define TAG(x) x##_alpha_wide_offset
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_wide_offset_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT)
+#define TAG(x) x##_alpha_wide_twoside
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_wide_twoside_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT)
+#define TAG(x) x##_alpha_wide_twoside_offset
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_wide_twoside_offset_flat
+#include "ffb_linetmp.h"
+
+void ffbDDLinefuncInit(void)
+{
+ init();
+ init_flat();
+ init_offset();
+ init_offset_flat();
+ init_twoside();
+ init_twoside_flat();
+ init_twoside_offset();
+ init_twoside_offset_flat();
+ init_wide();
+ init_wide_flat();
+ init_wide_offset();
+ init_wide_offset_flat();
+ init_wide_twoside();
+ init_wide_twoside_flat();
+ init_wide_twoside_offset();
+ init_wide_twoside_offset_flat();
+ init_alpha();
+ init_alpha_flat();
+ init_alpha_offset();
+ init_alpha_offset_flat();
+ init_alpha_twoside();
+ init_alpha_twoside_flat();
+ init_alpha_twoside_offset();
+ init_alpha_twoside_offset_flat();
+ init_alpha_wide();
+ init_alpha_wide_flat();
+ init_alpha_wide_offset();
+ init_alpha_wide_offset_flat();
+ init_alpha_wide_twoside();
+ init_alpha_wide_twoside_flat();
+ init_alpha_wide_twoside_offset();
+ init_alpha_wide_twoside_offset_flat();
+}
+
+/* Our caller makes sure TriangleCaps is non-zero and that
+ * we are not doing feedback/selection (Mesa handles those
+ * cases).
+ */
+void ffbDDChooseLineRenderState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint flags = ctx->TriangleCaps;
+ GLuint ind = 0;
+
+ if (!flags) {
+ fmesa->LineFunc = ffb_line_tab[0];
+ return;
+ }
+
+ if (flags & DD_FLATSHADE)
+ ind |= FFB_LINE_FLAT_BIT;
+ if (flags & DD_TRI_OFFSET)
+ ind |= FFB_LINE_OFFSET_BIT;
+ if (flags & DD_TRI_LIGHT_TWOSIDE)
+ ind |= FFB_LINE_TWOSIDE_BIT;
+ if (flags & DD_LINE_WIDTH) {
+ /* We cannot currently do wide lines with stipples
+ * or antialiased in HW.
+ */
+ if ((flags & DD_LINE_STIPPLE) != 0 ||
+ ctx->Line.SmoothFlag)
+ ind |= FFB_LINE_FALLBACK_BIT;
+ else
+ ind |= FFB_LINE_WIDE_BIT;
+ } else {
+ if ((flags & DD_LINE_STIPPLE) != 0 &&
+ fmesa->lpat == FFB_LPAT_BAD)
+ ind |= FFB_LINE_FALLBACK_BIT;
+ }
+
+ /* If blending or the alpha test is enabled we need to
+ * provide alpha components to the chip, else we can
+ * do without it and thus feed vertex data to the chip
+ * more efficiently.
+ */
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ ind |= FFB_LINE_ALPHA_BIT;
+
+ fmesa->LineFunc = ffb_line_tab[ind];
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h
new file mode 100644
index 000000000..7c5e0b284
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h
@@ -0,0 +1,9 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h,v 1.1 2000/06/20 05:08:38 dawes Exp $ */
+
+#ifndef _FFB_LINES_H
+#define _FFB_LINES_H
+
+extern void ffbDDLinefuncInit(void);
+extern void ffbDDChooseLineRenderState(GLcontext *);
+
+#endif /* !(_FFB_LINES_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h
new file mode 100644
index 000000000..593637008
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h
@@ -0,0 +1,261 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h,v 1.1 2000/06/20 05:08:38 dawes Exp $ */
+
+static void TAG(ffb_line)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint pv)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+ struct vertex_buffer *VB = ctx->VB;
+ ffb_vertex *ffbVB = FFB_DRIVER_DATA(VB)->verts;
+ const ffb_vertex *v0 = &ffbVB[e0];
+ const ffb_vertex *v1 = &ffbVB[e1];
+#if (IND & FFB_LINE_OFFSET_BIT)
+ GLuint ffb_zoffset = FFB_Z_FROM_FLOAT(ctx->LineZoffset);
+#endif
+#if (IND & FFB_LINE_TWOSIDE_BIT)
+ const int which_color = (VB->ColorPtr == VB->Color[0]) ? 0 : 1;
+#else
+ const int which_color = 0;
+#endif
+#if (IND & FFB_LINE_FLAT_BIT)
+ const GLuint const_fg = (((GLuint)VB->Color[which_color]->data[pv][0] << 0) |
+ ((GLuint)VB->Color[which_color]->data[pv][1] << 8) |
+ ((GLuint)VB->Color[which_color]->data[pv][2] << 16) |
+ ((GLuint)VB->Color[which_color]->data[pv][3] << 24));
+#endif
+
+#if (IND & FFB_LINE_FLAT_BIT)
+ FFBFifo(fmesa, 1);
+ ffb->fg = const_fg;
+#endif
+
+#if !(IND & FFB_LINE_WIDE_BIT)
+ /* We actually need to do the LINE_LOOP/LINE_STRIP optimization
+ * in this case so that the line pattern works out correctly.
+ * Really, Mesa should be fixed so it sends us the real primitive.
+ */
+ if (v0 == fmesa->vtx_cache[1] &&
+ v1 != fmesa->vtx_cache[0]) {
+#if (IND & FFB_LINE_FLAT_BIT)
+ FFBFifo(fmesa, 3);
+#else
+#if (IND & FFB_LINE_ALPHA_BIT)
+ FFBFifo(fmesa, 7);
+#else
+ FFBFifo(fmesa, 6);
+#endif
+#endif
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = v1->color[which_color].alpha;
+#endif
+ ffb->red = v1->color[which_color].red;
+ ffb->green = v1->color[which_color].green;
+ ffb->blue = v1->color[which_color].blue;
+#endif
+#if (IND & FFB_LINE_OFFSET_BIT)
+ ffb->z = v1->z + ffb_zoffset;
+#else
+ ffb->z = v1->z;
+#endif
+ ffb->y = v1->y;
+ ffb->x = v1->x;
+
+ fmesa->vtx_cache[0] = (void *)v0;
+ fmesa->vtx_cache[1] = (void *)v1;
+ fmesa->ffbScreen->rp_active = 1;
+ return;
+ } else {
+ fmesa->vtx_cache[0] = (void *)v0;
+ fmesa->vtx_cache[1] = (void *)v1;
+ }
+#endif
+
+#if (IND & FFB_LINE_FLAT_BIT)
+#if !(IND & FFB_LINE_WIDE_BIT)
+ /* (2 * 3) + 1 */
+ FFBFifo(fmesa, 7);
+#else
+ /* (4 * 3) */
+ FFBFifo(fmesa, 12);
+#endif
+#else
+#if !(IND & FFB_LINE_WIDE_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ /* (2 * 7) + 1 */
+ FFBFifo(fmesa, 15);
+#else
+ /* (2 * 6) + 1 */
+ FFBFifo(fmesa, 13);
+#endif
+#else
+#if (IND & FFB_LINE_ALPHA_BIT)
+ /* (4 * 7) */
+ FFBFifo(fmesa, 28);
+#else
+ /* (4 * 6) */
+ FFBFifo(fmesa, 24);
+#endif
+#endif
+#endif
+
+#if !(IND & FFB_LINE_WIDE_BIT)
+ /* Using DDLINE or AALINE, init the line pattern state. */
+ ffb->lpat = fmesa->lpat;
+
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = v0->color[which_color].alpha;
+#endif
+ ffb->red = v0->color[which_color].red;
+ ffb->green = v0->color[which_color].green;
+ ffb->blue = v0->color[which_color].blue;
+#endif
+#if (IND & FFB_LINE_OFFSET_BIT)
+ ffb->z = v0->z + ffb_zoffset;
+#else
+ ffb->z = v0->z;
+#endif
+ ffb->ryf = v0->y;
+ ffb->rxf = v0->x;
+
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = v1->color[which_color].alpha;
+#endif
+ ffb->red = v1->color[which_color].red;
+ ffb->green = v1->color[which_color].green;
+ ffb->blue = v1->color[which_color].blue;
+#endif
+#if (IND & FFB_LINE_OFFSET_BIT)
+ ffb->z = v1->z + ffb_zoffset;
+#else
+ ffb->z = v1->z;
+#endif
+ ffb->y = v1->y;
+ ffb->x = v1->x;
+
+#else /* FFB_LINE_WIDE_BIT */
+ /* Doing wide lines via triangles. */
+ {
+ float width = ctx->Line.Width;
+ float dx, dy;
+ GLuint ix, iy;
+
+ /* It might be possible to precalculate this stuff in
+ * our vertex-buffer code. That code works with
+ * screen coordinates so it might work. One problem
+ * could be that due to potentially drawing polygons
+ * as lines, it would be very difficult to really
+ * determine if the calculations were necessary or not.
+ */
+ dx = VB->Win.data[e0][0] - VB->Win.data[e1][0];
+ dy = VB->Win.data[e0][1] - VB->Win.data[e1][1];
+ ix = FFB_COORD_FROM_FLOAT(width * 0.5f);
+ iy = 0;
+ if ((dx * dx) > (dy * dy)) {
+ iy = ix;
+ ix = 0;
+ }
+
+ /* The vertex sequence using isolated triangles would
+ * be:
+ *
+ * Vertex0: line vertex0 - I RXF/RYF
+ * Vertex1: line vertex1 + I DOXF/DOYF
+ * Vertex2: line vertex0 + I DOXF/DOYF
+ * Vertex3: line vertex0 - I RXF/RYF
+ * Vertex4: line vertex1 - I DOXF/DOYF
+ * Vertex5: line vertex1 + I DOXF/DOYF
+ *
+ * Using star chaining we can optimize this into a
+ * four vertex sequence, as follows:
+ *
+ * Vertex0: line vertex0 - I RXF/RYF
+ * Vertex1: line vertex0 + I DOXF/DOYF
+ * Vertex2: line vertex1 + I DOXF/DOYF
+ * Vertex3: line vertex1 - I DMXF/DMYF
+ *
+ * The DMXF/DMYF vertex means "replace middle vertex
+ * with new vertex and draw".
+ */
+
+ /* Vertex0: line vertex0 - I, RXF/RYF */
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = v0->color[which_color].alpha;
+#endif
+ ffb->red = v0->color[which_color].red;
+ ffb->green = v0->color[which_color].green;
+ ffb->blue = v0->color[which_color].blue;
+#endif
+#if (IND & FFB_LINE_OFFSET_BIT)
+ ffb->z = v0->z + ffb_zoffset;
+#else
+ ffb->z = v0->z;
+#endif
+ ffb->ryf = v0->y - iy;
+ ffb->rxf = v0->x - ix;
+
+ /* Vertex1: line vertex0 + I, DOXF/DOYF */
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = v0->color[which_color].alpha;
+#endif
+ ffb->red = v0->color[which_color].red;
+ ffb->green = v0->color[which_color].green;
+ ffb->blue = v0->color[which_color].blue;
+#endif
+#if (IND & FFB_LINE_OFFSET_BIT)
+ ffb->z = v0->z + ffb_zoffset;
+#else
+ ffb->z = v0->z;
+#endif
+ ffb->y = v0->y + iy;
+ ffb->x = v0->x + ix;
+
+ /* Vertex2: line vertex1 + I, DOXF/DOYF */
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = v1->color[which_color].alpha;
+#endif
+ ffb->red = v1->color[which_color].red;
+ ffb->green = v1->color[which_color].green;
+ ffb->blue = v1->color[which_color].blue;
+#endif
+#if (IND & FFB_LINE_OFFSET_BIT)
+ ffb->z = v1->z + ffb_zoffset;
+#else
+ ffb->z = v1->z;
+#endif
+ ffb->y = v1->y + iy;
+ ffb->x = v1->x + ix;
+
+ /* Vertex3: line vertex1 - I, DMXF/DMYF */
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = v1->color[which_color].alpha;
+#endif
+ ffb->red = v1->color[which_color].red;
+ ffb->green = v1->color[which_color].green;
+ ffb->blue = v1->color[which_color].blue;
+#endif
+#if (IND & FFB_LINE_OFFSET_BIT)
+ ffb->z = v1->z + ffb_zoffset;
+#else
+ ffb->z = v1->z;
+#endif
+ ffb->dmyf = v1->y - iy;
+ ffb->dmxf = v1->x - ix;
+ }
+#endif /* !(FFB_LINE_WIDE_BIT) */
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(init)(void)
+{
+ ffb_line_tab[IND] = TAG(ffb_line);
+}
+
+#undef IND
+#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h
new file mode 100644
index 000000000..1042ee407
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h
@@ -0,0 +1,28 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h,v 1.1 2000/06/20 05:08:38 dawes Exp $ */
+
+#ifndef _FFB_LOCK_H
+#define _FFB_LOCK_H
+
+#include "ffb_context.h"
+
+extern void ffbXMesaUpdateState(ffbContextPtr fmesa);
+#define FFB_UPDATE_STATE(fmesa) ffbXMesaUpdateState(fmesa)
+
+/* Lock the hardware and validate our state. */
+#define LOCK_HARDWARE(fmesa) \
+ do { \
+ int __ret=0; \
+ DRM_CAS(fmesa->driHwLock, fmesa->hHWContext, \
+ (DRM_LOCK_HELD | fmesa->hHWContext), __ret);\
+ if (__ret) { \
+ drmGetLock(fmesa->driFd, fmesa->hHWContext, 0); \
+ FFB_UPDATE_STATE(fmesa); \
+ } \
+ } while (0)
+
+
+/* Unlock the hardware. */
+#define UNLOCK_HARDWARE(fmesa) \
+ DRM_UNLOCK(fmesa->driFd, fmesa->driHwLock, fmesa->hHWContext);
+
+#endif /* !(_FFB_LOCK_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c
new file mode 100644
index 000000000..88c5b3dd3
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c
@@ -0,0 +1,84 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c,v 1.1 2000/06/20 05:08:39 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "ffb_xmesa.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_pipeline.h"
+
+#include "stages.h"
+#include "pipeline.h"
+
+GLboolean ffbDDBuildPrecalcPipeline(GLcontext *ctx)
+{
+ /* This doesn't do anything interesting yet. */
+ return 0;
+}
+
+static void ffbDDCheckRasterSetup(GLcontext *ctx, struct gl_pipeline_stage *d)
+{
+ d->type = PIPE_IMMEDIATE|PIPE_PRECALC;
+ d->inputs = ctx->RenderFlags;
+ d->outputs = VERT_SETUP_FULL;
+
+ if (ctx->IndirectTriangles & DD_SW_SETUP)
+ d->type = PIPE_IMMEDIATE;
+}
+
+GLuint ffbDDRegisterPipelineStages(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_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 = ffbDDCheckPartialRasterSetup;
+ out[o].run = ffbDDPartialRasterSetup;
+ o++;
+ break;
+
+ case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
+ out[o] = in[i];
+ out[o].check = ffbDDCheckRasterSetup;
+ out[o].run = ffbDDDoRasterSetup;
+ o++;
+ break;
+
+ default:
+ out[o++] = in[i];
+ break;
+ };
+ }
+
+ return o;
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h
new file mode 100644
index 000000000..b7910d288
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h
@@ -0,0 +1,11 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+
+#ifndef _FFB_PIPELINE_H
+#define _FFB_PIPELINE_H
+
+extern GLboolean ffbDDBuildPrecalcPipeline(GLcontext *);
+extern GLuint ffbDDRegisterPipelineStages(struct gl_pipeline_stage *,
+ const struct gl_pipeline_stage *,
+ GLuint);
+
+#endif /* !(_FFB_PIPELINE_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c
new file mode 100644
index 000000000..d459ed3f3
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c
@@ -0,0 +1,155 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_points.c,v 1.1 2000/06/20 05:08:39 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "vbrender.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_lines.h"
+#include "ffb_points.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+#include "vb.h"
+#include "dd.h"
+#include "pipeline.h"
+
+#define FFB_POINT_OFFSET_BIT 0x01
+#define FFB_POINT_AA_BIT 0x02
+#define FFB_POINT_BIG_BIT 0x04
+#define FFB_POINT_ALPHA_BIT 0x08
+#define FFB_POINT_FALLBACK_BIT 0x10
+
+static points_func ffb_points_tab[0x20];
+
+#define IND (0)
+#define TAG(x) x
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_AA_BIT)
+#define TAG(x) x##_aa
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_OFFSET_BIT|FFB_POINT_AA_BIT)
+#define TAG(x) x##_offset_aa
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_BIG_BIT)
+#define TAG(x) x##_big
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_BIG_BIT|FFB_POINT_OFFSET_BIT)
+#define TAG(x) x##_big_offset
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_OFFSET_BIT)
+#define TAG(x) x##_alpha_offset
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_AA_BIT)
+#define TAG(x) x##_alpha_aa
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_OFFSET_BIT|FFB_POINT_AA_BIT)
+#define TAG(x) x##_alpha_offset_aa
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_BIG_BIT)
+#define TAG(x) x##_alpha_big
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_BIG_BIT|FFB_POINT_OFFSET_BIT)
+#define TAG(x) x##_alpha_big_offset
+#include "ffb_pointtmp.h"
+
+void ffbDDPointfuncInit(void)
+{
+ init();
+ init_offset();
+ init_aa();
+ init_offset_aa();
+ init_big();
+ init_big_offset();
+ init_alpha();
+ init_alpha_offset();
+ init_alpha_aa();
+ init_alpha_offset_aa();
+ init_alpha_big();
+ init_alpha_big_offset();
+}
+
+/* Our caller makes sure TriangleCaps is non-zero and that
+ * we are not doing feedback/selection (Mesa handles those
+ * cases).
+ */
+void ffbDDChoosePointRenderState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint flags = ctx->TriangleCaps;
+ GLuint ind = 0;
+
+ if (!flags) {
+ fmesa->PointsFunc = ffb_points_tab[0];
+ return;
+ }
+
+ if (flags & DD_TRI_OFFSET)
+ ind |= FFB_POINT_OFFSET_BIT;
+ if (flags & DD_POINT_SIZE) {
+ if (ctx->Point.SmoothFlag)
+ ind |= FFB_POINT_FALLBACK_BIT;
+ else
+ ind |= FFB_POINT_BIG_BIT;
+ } else if (ctx->Point.SmoothFlag) {
+ ind |= FFB_POINT_AA_BIT;
+ }
+
+ /* If blending or the alpha test is enabled we need to
+ * provide alpha components to the chip, else we can
+ * do without it and thus feed vertex data to the chip
+ * more efficiently.
+ */
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ ind |= FFB_POINT_ALPHA_BIT;
+
+ fmesa->PointsFunc = ffb_points_tab[ind];
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_points.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.h
new file mode 100644
index 000000000..b3a078e8a
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.h
@@ -0,0 +1,9 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_points.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+
+#ifndef _FFB_POINTS_H
+#define _FFB_POINTS_H
+
+extern void ffbDDPointfuncInit(void);
+extern void ffbDDChoosePointRenderState(GLcontext *);
+
+#endif /* !(_FFB_POINTS_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h
new file mode 100644
index 000000000..c7d3b1e8e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h
@@ -0,0 +1,114 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+
+static void TAG(ffb_points)(GLcontext *ctx, GLuint first, GLuint last)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+ struct vertex_buffer *VB = ctx->VB;
+ ffb_vertex *ffbVB = FFB_DRIVER_DATA(VB)->verts;
+#if (IND & FFB_POINT_OFFSET_BIT)
+#if (IND & FFB_POINT_AA_BIT)
+ GLuint ffb_zoffset = FFB_Z_FROM_FLOAT(ctx->PointZoffset);
+#else
+ GLuint ffb_zoffset = Z_FROM_MESA(ctx->PointZoffset);
+#endif
+#endif
+#if (IND & FFB_POINT_BIG_BIT)
+ GLuint sz = FFB_COORD_FROM_FLOAT(ctx->Point.Size * 0.5f);
+#endif
+ int i;
+
+ for (i = first; i <= last; i++) {
+ if (VB->ClipMask[i] == 0) {
+ ffb_vertex *tmp = &ffbVB[i];
+#if !(IND & FFB_POINT_BIG_BIT)
+#if (IND & FFB_POINT_AA_BIT)
+ FFBFifo(fmesa, 4);
+ ffb->fg = (((GLuint)VB->Color[0]->data[i][0] << 0) |
+ ((GLuint)VB->Color[0]->data[i][1] << 8) |
+ ((GLuint)VB->Color[0]->data[i][2] << 16) |
+ ((GLuint)VB->Color[0]->data[i][3] << 24));
+#if (IND & FFB_POINT_OFFSET_BIT)
+ ffb->z = tmp->z + ffb_zoffset;
+#else
+ ffb->z = tmp->z;
+#endif
+ ffb->y = tmp->y + 0x8000;
+ ffb->x = tmp->x + 0x8000;
+#else
+ FFBFifo(fmesa, 4);
+ ffb->fg = (((GLuint)VB->Color[0]->data[i][0] << 0) |
+ ((GLuint)VB->Color[0]->data[i][1] << 8) |
+ ((GLuint)VB->Color[0]->data[i][2] << 16) |
+ ((GLuint)VB->Color[0]->data[i][3] << 24));
+#if (IND & FFB_POINT_OFFSET_BIT)
+ ffb->constz =
+ (Z_FROM_MESA(VB->Win.data[i][2]) + ffb_zoffset);
+#else
+ ffb->constz = Z_FROM_MESA(VB->Win.data[i][2]);
+#endif
+ ffb->bh = tmp->y >> 16;
+ ffb->bw = tmp->x >> 16;
+#endif
+#else /* FFB_POINT_BIG_BIT */
+ /* Doing big points via triangles. */
+ FFBFifo(fmesa, 10);
+
+ ffb->fg = (((GLuint)VB->Color[0]->data[i][0] << 0) |
+ ((GLuint)VB->Color[0]->data[i][1] << 8) |
+ ((GLuint)VB->Color[0]->data[i][2] << 16) |
+ ((GLuint)VB->Color[0]->data[i][3] << 24));
+#if (IND & FFB_POINT_OFFSET_BIT)
+ ffb->constz =
+ (Z_FROM_MESA(VB->Win.data[i][2]) + ffb_zoffset);
+#else
+ ffb->constz = Z_FROM_MESA(VB->Win.data[i][2]);
+#endif
+
+ /* The vertex sequence using isolated triangles would
+ * be:
+ * Vertex0: VX - sz, VY - sz RXF/RYF
+ * Vertex1: VX + sz, VY - sz DOXF/DOYF
+ * Vertex2: VX + sz, VY + sz DOXF/DOYF
+ * Vertex3: VX + sz, VY + sz RXF/RYF
+ * Vertex4: VX - sz, VY + sz DOXF/DOYF
+ * Vertex5: VX - sz, VY - sz DOXF/DOYF
+ *
+ * Using star chaining we can optimize this into a
+ * four vertex sequence, as follows:
+ *
+ * Vertex0: VX - sz, VY - sz RXF/RYF
+ * Vertex1: VX + sz, VY - sz DOXF/DOYF
+ * Vertex2: VX + sz, VY + sz DOXF/DOYF
+ * Vertex3: VX - sz, VY + sz DMXF/DMYF
+ */
+
+ /* Vertex0: VX - sz, VY - sz, RXF/RYF */
+ ffb->ryf = tmp->y - sz;
+ ffb->rxf = tmp->x - sz;
+
+ /* Vertex1: VX + sz, VY - sz, DOXF/DOYF */
+ ffb->y = tmp->y - sz;
+ ffb->x = tmp->x + sz;
+
+ /* Vertex2: VX + sz, VY + sz, DOXF/DOYF */
+ ffb->y = tmp->y + sz;
+ ffb->x = tmp->x + sz;
+
+ /* Vertex3: VX - sz, VY + sz, DMXF/DMYF */
+ ffb->dmyf = tmp->y + sz;
+ ffb->dmxf = tmp->x - sz;
+#endif /* !(FFB_POINT_BIG_BIT) */
+ }
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(init)(void)
+{
+ ffb_points_tab[IND] = TAG(ffb_points);
+}
+
+#undef IND
+#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_span.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_span.c
new file mode 100644
index 000000000..dbae8df6b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_span.c
@@ -0,0 +1,133 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_span.c,v 1.1 2000/06/20 05:08:39 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_context.h"
+#include "ffb_lock.h"
+
+#define DBG 0
+
+#define HW_LOCK() \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ if (!fmesa->hw_locked) \
+ LOCK_HARDWARE(fmesa);
+
+#define HW_UNLOCK() \
+ if (!fmesa->hw_locked) \
+ UNLOCK_HARDWARE(fmesa); \
+
+#define LOCAL_VARS \
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
+ GLuint height = dPriv->h; \
+ char *buf
+
+#define INIT_MONO_PIXEL(p) \
+ GLuint p = fmesa->MonoColor;
+
+/* We use WID clipping, so this test always passes. */
+#define CLIPPIXEL(__x, __y) (1)
+
+/* And also, due to WID clipping, we need not do anything
+ * special here.
+ */
+#define CLIPSPAN(__x,__y,__n,__x1,__n1,__i) \
+ __n1 = __n; \
+ __x1 = __x; \
+
+#define HW_CLIPLOOP() \
+do { unsigned int fbc, ppc, cmp; \
+ FFBWait(fmesa, fmesa->regs); \
+ fbc = fmesa->regs->fbc; ppc = fmesa->regs->ppc; cmp = fmesa->regs->cmp; \
+ fmesa->regs->fbc = ((fbc & \
+ ~(FFB_FBC_WB_C | FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK)) \
+ | (FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK)); \
+ fmesa->regs->ppc = ((ppc & \
+ ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK | FFB_PPC_DCE_MASK | \
+ FFB_PPC_APE_MASK | FFB_PPC_CS_MASK)) \
+ | (FFB_PPC_XS_WID | FFB_PPC_ABE_DISABLE | \
+ FFB_PPC_DCE_DISABLE | FFB_PPC_APE_DISABLE | \
+ FFB_PPC_CS_VAR)); \
+ fmesa->regs->cmp = ((cmp & ~(0xff << 16)) | (0x80 << 16)); \
+ fmesa->ffbScreen->rp_active = 1; \
+ FFBWait(fmesa, fmesa->regs); \
+ buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13));\
+ if (dPriv->numClipRects) {
+
+#define HW_ENDCLIPLOOP() \
+ } \
+ fmesa->regs->fbc = fbc; \
+ fmesa->regs->ppc = ppc; \
+ fmesa->regs->cmp = cmp; \
+ fmesa->ffbScreen->rp_active = 1; \
+} while(0)
+
+#define Y_FLIP(__y) (height - __y)
+
+#define READ_RGBA(rgba,__x,__y) \
+do { GLuint p = *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)); \
+ rgba[0] = (p >> 0) & 0xff; \
+ rgba[1] = (p >> 8) & 0xff; \
+ rgba[2] = (p >> 16) & 0xff; \
+ rgba[3] = 0xff; \
+} while(0)
+
+#define WRITE_RGBA(__x, __y, __r, __g, __b, __a) \
+ *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = \
+ ((((__r) & 0xff) << 0) | \
+ (((__g) & 0xff) << 8) | \
+ (((__b) & 0xff) << 16))
+
+#define WRITE_PIXEL(__x, __y, __p) \
+ *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = (__p)
+
+#define TAG(x) ffb##x##_888
+
+#include <spantmp.h>
+
+void ffbDDInitSpanFuncs(GLcontext *ctx)
+{
+ ctx->Driver.WriteRGBASpan = ffbWriteRGBASpan_888;
+ ctx->Driver.WriteRGBSpan = ffbWriteRGBSpan_888;
+ ctx->Driver.WriteRGBAPixels = ffbWriteRGBAPixels_888;
+ ctx->Driver.WriteMonoRGBASpan = ffbWriteMonoRGBASpan_888;
+ ctx->Driver.WriteMonoRGBAPixels = ffbWriteMonoRGBAPixels_888;
+ ctx->Driver.ReadRGBASpan = ffbReadRGBASpan_888;
+ ctx->Driver.ReadRGBAPixels = ffbReadRGBAPixels_888;
+
+ /* We don't support color index mode yet, but it will be
+ * very easy to do. -DaveM
+ */
+ 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;
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_span.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_span.h
new file mode 100644
index 000000000..00501e823
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_span.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_span.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+
+#ifndef _FFB_SPAN_H
+#define _FFB_SPAN_H
+
+extern void ffbDDInitSpanFuncs(GLcontext *ctx);
+
+#endif /* !(_FFB_SPAN_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c
new file mode 100644
index 000000000..b083533e3
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c
@@ -0,0 +1,1400 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_state.c,v 1.1 2000/06/20 05:08:39 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "vbrender.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_lines.h"
+#include "ffb_points.h"
+#include "ffb_state.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+#include "vb.h"
+#include "dd.h"
+#include "enums.h"
+#include "pipeline.h"
+#include "pb.h"
+
+#undef STATE_TRACE
+
+static unsigned int ffbComputeAlphaFunc(GLcontext *ctx)
+{
+ unsigned int xclip;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDAlphaFunc: func(%s) ref(%02x)\n",
+ gl_lookup_enum_by_nr(ctx->Color.AlphaFunc),
+ ctx->Color.AlphaRef & 0xff);
+#endif
+
+ switch (ctx->Color.AlphaFunc) {
+ case GL_NEVER: xclip = FFB_XCLIP_TEST_NEVER; break;
+ case GL_LESS: xclip = FFB_XCLIP_TEST_LT; break;
+ case GL_EQUAL: xclip = FFB_XCLIP_TEST_EQ; break;
+ case GL_LEQUAL: xclip = FFB_XCLIP_TEST_LE; break;
+ case GL_GREATER: xclip = FFB_XCLIP_TEST_GT; break;
+ case GL_NOTEQUAL: xclip = FFB_XCLIP_TEST_NE; break;
+ case GL_GEQUAL: xclip = FFB_XCLIP_TEST_GE; break;
+ case GL_ALWAYS: xclip = FFB_XCLIP_TEST_ALWAYS; break;
+
+ default:
+ return FFB_XCLIP_TEST_ALWAYS | 0x00;
+ }
+
+ xclip |= (ctx->Color.AlphaRef & 0xff);
+
+ return xclip;
+}
+
+static void ffbDDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (ctx->Color.AlphaEnabled) {
+ unsigned int xclip = ffbComputeAlphaFunc(ctx);
+
+ if (fmesa->xclip != xclip) {
+ fmesa->xclip = xclip;
+ fmesa->state_dirty |= FFB_STATE_XCLIP;
+ fmesa->state_fifo_ents += 1;
+ }
+ }
+}
+
+static void ffbDDBlendEquation(GLcontext *ctx, GLenum mode)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDBlendEquation: mode(%s)\n", gl_lookup_enum_by_nr(mode));
+#endif
+ if (mode != GL_FUNC_ADD_EXT)
+ fmesa->bad_fragment_attrs |= FFB_BADATTR_BLENDEQN;
+ else
+ fmesa->bad_fragment_attrs &= ~FFB_BADATTR_BLENDEQN;
+}
+
+static void ffbDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int blendc = 1 << 4;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDBlendFunc: sfactor(%s) dfactor(%s)\n",
+ gl_lookup_enum_by_nr(sfactor), gl_lookup_enum_by_nr(dfactor));
+#endif
+ switch (ctx->Color.BlendSrcRGB) {
+ case GL_ZERO:
+ blendc |= (0 << 0);
+ break;
+
+ case GL_ONE:
+ blendc |= (1 << 0);
+ break;
+
+ case GL_ONE_MINUS_SRC_ALPHA:
+ blendc |= (2 << 0);
+ break;
+
+ case GL_SRC_ALPHA:
+ blendc |= (3 << 0);
+ break;
+
+ default:
+ if (ctx->Color.BlendEnabled)
+ fmesa->bad_fragment_attrs |= FFB_BADATTR_BLENDFUNC;
+ return;
+ };
+
+ switch (ctx->Color.BlendDstRGB) {
+ case GL_ZERO:
+ blendc |= (0 << 2);
+ break;
+
+ case GL_ONE:
+ blendc |= (1 << 2);
+ break;
+
+ case GL_ONE_MINUS_SRC_ALPHA:
+ blendc |= (2 << 2);
+ break;
+
+ case GL_SRC_ALPHA:
+ blendc |= (3 << 2);
+ break;
+
+ default:
+ if (ctx->Color.BlendEnabled)
+ fmesa->bad_fragment_attrs |= FFB_BADATTR_BLENDFUNC;
+ return;
+ };
+
+ if (ctx->Color.BlendEnabled &&
+ ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY) {
+ /* We could avoid this if sfactor is GL_ONE and
+ * dfactor is GL_ZERO. I do not think that is even
+ * worthwhile to check because if someone is using
+ * blending they use more interesting settings and
+ * also it would add more state tracking to a lot
+ * of the code in this file.
+ */
+ fmesa->bad_fragment_attrs |= FFB_BADATTR_BLENDROP;
+ return;
+ }
+
+ fmesa->bad_fragment_attrs &= ~(FFB_BADATTR_BLENDFUNC |
+ FFB_BADATTR_BLENDROP);
+
+ if (blendc != fmesa->blendc) {
+ fmesa->blendc = blendc;
+ fmesa->state_dirty |= FFB_STATE_BLEND;
+ fmesa->state_fifo_ents += 1;
+ }
+}
+
+static void ffbDDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA)
+{
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDBlendFuncSeparate: sRGB(%s) dRGB(%s) sA(%s) dA(%s)\n",
+ gl_lookup_enum_by_nr(sfactorRGB),
+ gl_lookup_enum_by_nr(dfactorRGB),
+ gl_lookup_enum_by_nr(sfactorA),
+ gl_lookup_enum_by_nr(dfactorA));
+#endif
+
+ ffbDDBlendFunc(ctx, sfactorRGB, dfactorRGB);
+}
+
+static void ffbDDDepthFunc(GLcontext *ctx, GLenum func)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint cmp;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDDepthFunc: func(%s)\n",
+ gl_lookup_enum_by_nr(func));
+#endif
+
+ switch (func) {
+ case GL_NEVER:
+ cmp = FFB_CMP_MAGN_NEVER;
+ break;
+ case GL_ALWAYS:
+ cmp = FFB_CMP_MAGN_ALWAYS;
+ break;
+ case GL_LESS:
+ cmp = FFB_CMP_MAGN_LT;
+ break;
+ case GL_LEQUAL:
+ cmp = FFB_CMP_MAGN_LE;
+ break;
+ case GL_EQUAL:
+ cmp = FFB_CMP_MAGN_EQ;
+ break;
+ case GL_GREATER:
+ cmp = FFB_CMP_MAGN_GT;
+ break;
+ case GL_GEQUAL:
+ cmp = FFB_CMP_MAGN_GE;
+ break;
+ case GL_NOTEQUAL:
+ cmp = FFB_CMP_MAGN_NE;
+ break;
+ default:
+ return;
+ };
+
+ if (! ctx->Depth.Test)
+ cmp = FFB_CMP_MAGN_ALWAYS;
+
+ cmp <<= 16;
+ cmp = (fmesa->cmp & ~(0xff<<16)) | cmp;
+ if (cmp != fmesa->cmp) {
+ fmesa->cmp = cmp;
+ fmesa->state_dirty |= FFB_STATE_CMP;
+ fmesa->state_fifo_ents += 1;
+ }
+}
+
+static void ffbDDDepthMask(GLcontext *ctx, GLboolean flag)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint fbc = fmesa->fbc;
+ GLboolean enabled_now;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDDepthMask: flag(%d)\n", flag);
+#endif
+
+ if ((fbc & FFB_FBC_ZE_MASK) == FFB_FBC_ZE_OFF)
+ enabled_now = GL_FALSE;
+ else
+ enabled_now = GL_TRUE;
+
+ if (flag != enabled_now) {
+ fbc &= ~FFB_FBC_ZE_MASK;
+ if (flag) {
+ fbc |= FFB_FBC_WB_C | FFB_FBC_ZE_ON;
+ } else {
+ fbc |= FFB_FBC_ZE_OFF;
+ fbc &= ~FFB_FBC_WB_C;
+ }
+ fmesa->fbc = fbc;
+ fmesa->state_dirty |= FFB_STATE_FBC;
+ fmesa->state_fifo_ents += 1;
+ }
+}
+
+static void ffbDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, GLuint mask)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int stencil, stencilctl, consty;
+
+ /* We will properly update sw/hw state when stenciling is
+ * enabled.
+ */
+ if (! ctx->Stencil.Enabled)
+ return;
+
+ stencilctl = fmesa->stencilctl;
+ stencilctl &= ~(7 << 16);
+
+ switch (func) {
+ case GL_ALWAYS: stencilctl |= (0 << 16); break;
+ case GL_GREATER: stencilctl |= (1 << 16); break;
+ case GL_EQUAL: stencilctl |= (2 << 16); break;
+ case GL_GEQUAL: stencilctl |= (3 << 16); break;
+ case GL_NEVER: stencilctl |= (4 << 16); break;
+ case GL_LEQUAL: stencilctl |= (5 << 16); break;
+ case GL_NOTEQUAL: stencilctl |= (6 << 16); break;
+ case GL_LESS: stencilctl |= (7 << 16); break;
+
+ default:
+ return;
+ };
+
+ consty = ref & 0xf;
+
+ stencil = fmesa->stencil;
+ stencil &= ~(0xf << 20);
+ stencil |= (mask & 0xf) << 20;
+
+ if (fmesa->stencil != stencil ||
+ fmesa->stencilctl != stencilctl ||
+ fmesa->consty != consty) {
+ fmesa->stencil = stencil;
+ fmesa->stencilctl = stencilctl;
+ fmesa->consty = consty;
+ fmesa->state_dirty |= FFB_STATE_STENCIL;
+ fmesa->state_fifo_ents += 6;
+ }
+}
+
+static void ffbDDStencilMask(GLcontext *ctx, GLuint mask)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ mask &= 0xf;
+ if (fmesa->ypmask != mask) {
+ fmesa->ypmask = mask;
+ fmesa->state_dirty |= FFB_STATE_YPMASK;
+ fmesa->state_fifo_ents += 1;
+ }
+}
+
+static void ffbDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int stencilctl;
+
+ /* We will properly update sw/hw state when stenciling is
+ * enabled.
+ */
+ if (! ctx->Stencil.Enabled)
+ return;
+
+ stencilctl = fmesa->stencilctl;
+ stencilctl &= ~(0xfff00000);
+
+ switch (fail) {
+ case GL_ZERO: stencilctl |= (0 << 28); break;
+ case GL_KEEP: stencilctl |= (1 << 28); break;
+ case GL_INVERT: stencilctl |= (2 << 28); break;
+ case GL_REPLACE: stencilctl |= (3 << 28); break;
+ case GL_INCR: stencilctl |= (4 << 28); break;
+ case GL_DECR: stencilctl |= (5 << 28); break;
+
+ default:
+ return;
+ };
+
+ switch (zfail) {
+ case GL_ZERO: stencilctl |= (0 << 24); break;
+ case GL_KEEP: stencilctl |= (1 << 24); break;
+ case GL_INVERT: stencilctl |= (2 << 24); break;
+ case GL_REPLACE: stencilctl |= (3 << 24); break;
+ case GL_INCR: stencilctl |= (4 << 24); break;
+ case GL_DECR: stencilctl |= (5 << 24); break;
+
+ default:
+ return;
+ };
+
+ switch (zpass) {
+ case GL_ZERO: stencilctl |= (0 << 20); break;
+ case GL_KEEP: stencilctl |= (1 << 20); break;
+ case GL_INVERT: stencilctl |= (2 << 20); break;
+ case GL_REPLACE: stencilctl |= (3 << 20); break;
+ case GL_INCR: stencilctl |= (4 << 20); break;
+ case GL_DECR: stencilctl |= (5 << 20); break;
+
+ default:
+ return;
+ };
+
+ if (fmesa->stencilctl != stencilctl) {
+ fmesa->stencilctl = stencilctl;
+ fmesa->state_dirty |= FFB_STATE_STENCIL;
+ fmesa->state_fifo_ents += 6;
+ }
+}
+
+void ffbDDScissor(GLcontext *ctx, GLint cx, GLint cy,
+ GLsizei cw, GLsizei ch)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLint x, y;
+ unsigned int vcmin, vcmax;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDScissor: x(%x) y(%x) w(%x) h(%x)\n",
+ cx, cy, cw, ch);
+#endif
+ x = cx + dPriv->x;
+ y = dPriv->y + (cy - ch);
+ vcmin = ((y & 0xffff) << 16) | (x & 0xffff);
+ vcmax = ((((y + ch) & 0xffff) << 16) |
+ (((x + cw) & 0xffff)));
+ if (fmesa->vclipmin != vcmin ||
+ fmesa->vclipmax != vcmax) {
+ fmesa->vclipmin = vcmin;
+ fmesa->vclipmax = vcmax;
+ fmesa->state_dirty |= FFB_STATE_CLIP;
+ fmesa->state_fifo_ents += 4 + (4 * 2);
+ }
+}
+
+static GLboolean ffbDDSetDrawBuffer(GLcontext *ctx, GLenum buffer)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int fbc = fmesa->fbc;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDSetDrawBuffer: mode(%s)\n",
+ gl_lookup_enum_by_nr(buffer));
+#endif
+ fbc &= ~(FFB_FBC_WB_AB);
+ switch (buffer) {
+ case GL_FRONT_LEFT:
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_WB_B;
+ else
+ fbc |= FFB_FBC_WB_A;
+ break;
+
+ case GL_BACK_LEFT:
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_WB_A;
+ else
+ fbc |= FFB_FBC_WB_B;
+ break;
+
+ case GL_FRONT_AND_BACK:
+ fbc |= FFB_FBC_WB_AB;
+ break;
+
+ default:
+ return GL_FALSE;
+ };
+
+ if (fbc != fmesa->fbc) {
+ fmesa->fbc = fbc;
+ fmesa->state_dirty |= FFB_STATE_FBC;
+ fmesa->state_fifo_ents += 1;
+ }
+
+ return GL_TRUE;
+}
+
+static void ffbDDSetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum buffer)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int fbc = fmesa->fbc;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDSetReadBuffer: mode(%s)\n",
+ gl_lookup_enum_by_nr(buffer));
+#endif
+ fbc &= ~(FFB_FBC_RB_MASK);
+ switch (buffer) {
+ case GL_FRONT_LEFT:
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_RB_B;
+ else
+ fbc |= FFB_FBC_RB_A;
+ break;
+
+ case GL_BACK_LEFT:
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_RB_A;
+ else
+ fbc |= FFB_FBC_RB_B;
+ break;
+
+ default:
+ return;
+ };
+
+ if (fbc != fmesa->fbc) {
+ fmesa->fbc = fbc;
+ fmesa->state_dirty |= FFB_STATE_FBC;
+ fmesa->state_fifo_ents += 1;
+ }
+}
+
+static void ffbDDSetColor(GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ fmesa->MonoColor = ((r << 0) |
+ (g << 8) |
+ (b << 16));
+}
+
+static void ffbDDClearColor(GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ fmesa->clear_pixel = ((r << 0) |
+ (g << 8) |
+ (b << 16));
+}
+
+static void ffbDDClearDepth(GLcontext *ctx, GLclampd depth)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ fmesa->clear_depth = Z_FROM_MESA(depth * 4294967295.0f);
+}
+
+static void ffbDDClearStencil(GLcontext *ctx, GLint stencil)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ fmesa->clear_stencil = stencil & 0xf;
+}
+
+static void ffbDDReducedPrimitiveChange(GLcontext *ctx, GLenum prim)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint drawop, fbc, ppc;
+ int do_sw = 0;
+
+ drawop = fmesa->drawop;
+ fbc = fmesa->fbc;
+ ppc = fmesa->ppc & ~(FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK);
+
+#ifdef STATE_TRACE
+ fprintf(stderr,
+ "ffbDDReducedPrimitiveChange: prim(%d) ", prim);
+#endif
+ switch(prim) {
+ case GL_POINTS:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_POINTS ");
+#endif
+ if (ctx->IndirectTriangles & DD_POINT_SW_RASTERIZE) {
+ do_sw = 1;
+ break;
+ }
+
+ if (ctx->TriangleCaps & DD_POINT_SIZE) {
+ ppc |= FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST;
+ drawop = FFB_DRAWOP_TRIANGLE;
+ } else {
+ if (ctx->Point.SmoothFlag) {
+ ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST);
+ drawop = FFB_DRAWOP_AADOT;
+ } else {
+ ppc |= (FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
+ drawop = FFB_DRAWOP_DOT;
+ }
+ }
+ break;
+
+ case GL_LINES:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_LINES ");
+#endif
+ if (ctx->IndirectTriangles & DD_LINE_SW_RASTERIZE) {
+ do_sw = 1;
+ break;
+ }
+
+ if (ctx->TriangleCaps & DD_FLATSHADE) {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
+ } else {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
+ }
+ if (ctx->TriangleCaps & DD_LINE_WIDTH) {
+ drawop = FFB_DRAWOP_TRIANGLE;
+ } else {
+ if (ctx->Line.SmoothFlag)
+ drawop = FFB_DRAWOP_AALINE;
+ else
+ drawop = FFB_DRAWOP_DDLINE;
+ }
+ break;
+
+ case GL_POLYGON:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_POLYGON ");
+#endif
+ if (ctx->IndirectTriangles & DD_TRI_SW_RASTERIZE) {
+ do_sw = 1;
+ break;
+ }
+
+ ppc &= ~FFB_PPC_APE_MASK;
+ if (ctx->Polygon.StippleFlag)
+ ppc |= FFB_PPC_APE_ENABLE;
+ else
+ ppc |= FFB_PPC_APE_DISABLE;
+
+ if (ctx->TriangleCaps & DD_FLATSHADE) {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
+ } else {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
+ }
+ drawop = FFB_DRAWOP_TRIANGLE;
+ break;
+
+ default:
+#ifdef STATE_TRACE
+ fprintf(stderr, "unknown %d!\n", prim);
+#endif
+ return;
+ };
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "do_sw(%d) ", do_sw);
+#endif
+ if (do_sw != 0) {
+ fbc &= ~(FFB_FBC_WB_C);
+ fbc &= ~(FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK);
+ fbc |= FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK;
+ ppc &= ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK |
+ FFB_PPC_DCE_MASK | FFB_PPC_APE_MASK);
+ ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR | FFB_PPC_XS_WID |
+ FFB_PPC_ABE_DISABLE | FFB_PPC_DCE_DISABLE |
+ FFB_PPC_APE_DISABLE);
+ } else {
+ fbc |= FFB_FBC_WB_C;
+ fbc &= ~(FFB_FBC_RGBE_MASK);
+ fbc |= FFB_FBC_RGBE_MASK;
+ ppc &= ~(FFB_PPC_ABE_MASK | FFB_PPC_XS_MASK);
+ if (ctx->Color.BlendEnabled) {
+ ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_VAR;
+ } else {
+ ppc |= FFB_PPC_ABE_DISABLE | FFB_PPC_XS_WID;
+ }
+ }
+#ifdef STATE_TRACE
+ fprintf(stderr, "fbc(%08x) ppc(%08x)\n", fbc, ppc);
+#endif
+
+ FFBFifo(fmesa, 4);
+ if (fmesa->drawop != drawop)
+ fmesa->regs->drawop = fmesa->drawop = drawop;
+ if (fmesa->fbc != fbc)
+ fmesa->regs->fbc = fmesa->fbc = fbc;
+ if (fmesa->ppc != ppc)
+ fmesa->regs->ppc = fmesa->ppc = ppc;
+ if (do_sw != 0) {
+ fmesa->regs->cmp =
+ (fmesa->cmp & ~(0xff<<16)) | (0x80 << 16);
+ } else
+ fmesa->regs->cmp = fmesa->cmp;
+
+ /* Flush the vertex cache. */
+ fmesa->vtx_cache[0] = fmesa->vtx_cache[1] =
+ fmesa->vtx_cache[2] = fmesa->vtx_cache[3] = NULL;
+}
+
+/* XXX Actually, should I be using FBC controls for this? -DaveM */
+static GLboolean ffbDDColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int new_pmask = 0x0;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDColorMask: r(%d) g(%d) b(%d) a(%d)\n",
+ r, g, b, a);
+#endif
+ if (r)
+ new_pmask |= 0x000000ff;
+ if (g)
+ new_pmask |= 0x0000ff00;
+ if (b)
+ new_pmask |= 0x00ff0000;
+
+ if (fmesa->pmask != new_pmask) {
+ fmesa->pmask = new_pmask;
+ fmesa->state_dirty |= FFB_STATE_PMASK;
+ fmesa->state_fifo_ents += 1;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean ffbDDLogicOp(GLcontext *ctx, GLenum op)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int rop;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDLogicOp: op(%s)\n",
+ gl_lookup_enum_by_nr(op));
+#endif
+ switch (op) {
+ case GL_CLEAR: rop = FFB_ROP_ZERO; break;
+ case GL_SET: rop = FFB_ROP_ONES; break;
+ case GL_COPY: rop = FFB_ROP_NEW; break;
+ case GL_AND: rop = FFB_ROP_NEW_AND_OLD; break;
+ case GL_NAND: rop = FFB_ROP_NEW_AND_NOLD; break;
+ case GL_OR: rop = FFB_ROP_NEW_OR_OLD; break;
+ case GL_NOR: rop = FFB_ROP_NEW_OR_NOLD; break;
+ case GL_XOR: rop = FFB_ROP_NEW_XOR_OLD; break;
+ case GL_NOOP: rop = FFB_ROP_OLD; break;
+ case GL_COPY_INVERTED: rop = FFB_ROP_NNEW; break;
+ case GL_INVERT: rop = FFB_ROP_NOLD; break;
+ case GL_EQUIV: rop = FFB_ROP_NNEW_XOR_NOLD; break;
+ case GL_AND_REVERSE: rop = FFB_ROP_NEW_AND_NOLD; break;
+ case GL_AND_INVERTED: rop = FFB_ROP_NNEW_AND_OLD; break;
+ case GL_OR_REVERSE: rop = FFB_ROP_NEW_OR_NOLD; break;
+ case GL_OR_INVERTED: rop = FFB_ROP_NNEW_OR_OLD; break;
+
+ default:
+ return GL_FALSE;
+ };
+
+ rop |= fmesa->rop & ~0xff;
+ if (rop != fmesa->rop) {
+ fmesa->rop = rop;
+ fmesa->state_dirty |= FFB_STATE_ROP;
+ fmesa->state_fifo_ents += 1;
+
+ if (op == GL_COPY)
+ fmesa->bad_fragment_attrs &= ~FFB_BADATTR_BLENDROP;
+ }
+
+ return GL_TRUE;
+}
+
+#if 0
+/* XXX Also need to track near/far just like 3dfx driver.
+ * XXX
+ * XXX Actually, that won't work, because the 3dfx chip works by
+ * XXX having 1/w coordinates fed to it for each primitive, and
+ * XXX it uses this to index it's 64 entry fog table.
+ */
+static void ffb_fog_linear(GLcontext *ctx, ffbContextPtr fmesa)
+{
+ GLfloat c = ctx->ProjectionMatrix.m[10];
+ GLfloat d = ctx->ProjectionMatrix.m[14];
+ GLfloat tz = ctx->Viewport.WindowMap.m[MAT_TZ];
+ GLfloat szInv = 1.0F / ctx->Viewport.WindowMap.m[MAT_SZ];
+ GLfloat fogEnd = ctx->Fog.End;
+ GLfloat fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ GLfloat ndcz;
+ GLfloat eyez;
+ GLfloat Zzero, Zone;
+ unsigned int zb, zf;
+
+ /* Compute the Z at which f reaches 0.0, this is the full
+ * saturation point.
+ *
+ * Thus compute Z (as seen by the chip during rendering),
+ * such that:
+ *
+ * 0.0 = (fogEnd - eyez) * fogScale
+ *
+ * fogScale is usually not zero, thus we are looking for:
+ *
+ * fogEnd = eyez
+ *
+ * fogEnd = -d / (c + ((Z - tz) * szInv))
+ * fogEnd * (c + ((Z - tz) * szInv)) = -d
+ * (c + ((Z - tz) * szInv)) = -d / fogEnd
+ * (Z - tz) * szInv = (-d / fogEnd) - c
+ * (Z - tz) = ((-d / fogEnd) - c) / szInv
+ * Z = (((-d / fogEnd) - c) / szInv) + tz
+ */
+ Zzero = (((-d / fogEnd) - c) / szInv) + tz;
+
+ /* Compute the Z at which f reaches 1.0, this is where
+ * the incoming frag's full intensity is shown. This
+ * equation is:
+ *
+ * 1.0 = (fogEnd - eyez)
+ *
+ * We are looking for:
+ *
+ * 1.0 + eyez = fogEnd
+ *
+ * 1.0 + (-d / (c + ((Z - tz) * szInv))) = fogEnd
+ * -d / (c + ((Z - tz) * szInv)) = fogEnd - 1.0
+ * -d / (FogEnd - 1.0) = (c + ((Z - tz) * szInv))
+ * (-d / (fogEnd - 1.0)) - c = ((Z - tz) * szInv)
+ * ((-d / (fogEnd - 1.0)) - c) / szInv = (Z - tz)
+ * (((-d / (fogEnd - 1.0)) - c) / szInv) + tz = Z
+ */
+ Zone = (((-d / (fogEnd - 1.0)) - c) / szInv) + tz;
+
+ /* FFB's Zfront must be less than Zback, thus we may have
+ * to invert Sf/Sb to satisfy this constraint.
+ */
+ if (Zzero < Zone) {
+ sf = 0.0;
+ sb = 1.0;
+ zf = Z_FROM_MESA(Zzero);
+ zb = Z_FROM_MESA(Zone);
+ } else {
+ sf = 1.0;
+ sb = 0.0;
+ zf = Z_FROM_MESA(Zone);
+ zb = Z_FROM_MESA(Zzero);
+ }
+}
+#endif
+
+static void ffbDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDFogfv: pname(%s)\n", gl_lookup_enum_by_nr(pname));
+#endif
+}
+
+static void ffbDDLineStipple(GLcontext *ctx, GLint factor, GLushort pattern)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDLineStipple: factor(%d) pattern(%04x)\n",
+ factor, pattern);
+#endif
+ if (ctx->Line.StippleFlag) {
+ factor = ctx->Line.StippleFactor;
+ pattern = ctx->Line.StipplePattern;
+ if ((GLuint) factor > 15) {
+ ctx->Driver.TriangleCaps &= ~DD_LINE_STIPPLE;
+ fmesa->lpat = FFB_LPAT_BAD;
+ } else {
+ ctx->Driver.TriangleCaps |= DD_LINE_STIPPLE;
+ fmesa->lpat = ((factor << FFB_LPAT_SCALEVAL_SHIFT) |
+ (0 << FFB_LPAT_PATLEN_SHIFT) |
+ ((pattern & 0xffff) << FFB_LPAT_PATTERN_SHIFT));
+ }
+ } else {
+ fmesa->lpat = 0;
+ }
+}
+
+void ffbXformAreaPattern(ffbContextPtr fmesa, const GLubyte *mask)
+{
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ int i, lines, xoff;
+
+ lines = 0;
+ i = (dPriv->y + dPriv->h) & (32 - 1);
+ xoff = dPriv->x & (32 - 1);
+ while (lines++ < 32) {
+ GLuint raw =
+ (((GLuint)mask[0] << 24) |
+ ((GLuint)mask[1] << 16) |
+ ((GLuint)mask[2] << 8) |
+ ((GLuint)mask[3] << 0));
+
+ fmesa->pattern[i] =
+ (raw << xoff) | (raw >> (32 - xoff));
+ i = (i - 1) & (32 - 1);
+ mask += 4;
+ }
+
+ fmesa->state_dirty |= FFB_STATE_APAT;
+ fmesa->state_fifo_ents += 32;
+}
+
+static void ffbDDPolygonStipple(GLcontext *ctx, const GLubyte *mask)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDPolygonStipple: state(%d)\n",
+ ctx->Polygon.StippleFlag);
+#endif
+ if (ctx->Polygon.StippleFlag) {
+ ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
+ } else {
+ ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
+ }
+ ffbXformAreaPattern(fmesa, mask);
+}
+
+static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int tmp;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDEnable: %s state(%d)\n",
+ gl_lookup_enum_by_nr(cap), state);
+#endif
+ switch (cap) {
+ case GL_ALPHA_TEST:
+ if (state)
+ tmp = ffbComputeAlphaFunc(ctx);
+ else
+ tmp = FFB_XCLIP_TEST_ALWAYS;
+
+ if (tmp != fmesa->xclip) {
+ fmesa->xclip = tmp;
+ fmesa->state_dirty |= FFB_STATE_XCLIP;
+ fmesa->state_fifo_ents += 1;
+ }
+ break;
+
+ case GL_BLEND:
+ tmp = (fmesa->ppc & ~FFB_PPC_ABE_MASK);
+ if (state) {
+ tmp |= FFB_PPC_ABE_ENABLE;
+ } else {
+ tmp |= FFB_PPC_ABE_DISABLE;
+ }
+ if (fmesa->ppc != tmp) {
+ fmesa->ppc = tmp;
+ fmesa->state_dirty |= FFB_STATE_PPC;
+ fmesa->state_fifo_ents += 1;
+ ffbDDBlendFunc(ctx, 0, 0);
+ }
+ break;
+
+ case GL_DEPTH_TEST:
+ if (state)
+ tmp = 0x0fffffff;
+ else
+ tmp = 0x00000000;
+ if (tmp != fmesa->magnc) {
+ unsigned int fbc = fmesa->fbc;
+ fbc &= ~FFB_FBC_ZE_MASK;
+ if (state)
+ fbc |= FFB_FBC_ZE_ON;
+ else
+ fbc |= FFB_FBC_ZE_OFF;
+ fmesa->fbc = fbc;
+ ffbDDDepthFunc(ctx, ctx->Depth.Func);
+ fmesa->magnc = tmp;
+ fmesa->state_dirty |= FFB_STATE_MAGNC | FFB_STATE_FBC;
+ fmesa->state_fifo_ents += 2;
+ }
+ break;
+
+ case GL_SCISSOR_TEST:
+ tmp = fmesa->ppc & ~FFB_PPC_VCE_MASK;
+ if (state) {
+ ffbDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+ ctx->Scissor.Width, ctx->Scissor.Height);
+ tmp |= FFB_PPC_VCE_2D;
+ } else {
+ tmp |= FFB_PPC_VCE_DISABLE;
+ }
+ break;
+
+ case GL_STENCIL_TEST:
+ if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) {
+ if (state)
+ fmesa->bad_fragment_attrs |= FFB_BADATTR_STENCIL;
+ else
+ fmesa->bad_fragment_attrs &= ~FFB_BADATTR_STENCIL;
+ break;
+ }
+
+ tmp = fmesa->fbc & ~FFB_FBC_YE_MASK;
+ if (state) {
+ ffbDDStencilFunc(ctx,
+ ctx->Stencil.Function,
+ ctx->Stencil.Ref,
+ ctx->Stencil.ValueMask);
+ ffbDDStencilMask(ctx, ctx->Stencil.WriteMask);
+ ffbDDStencilOp(ctx,
+ ctx->Stencil.FailFunc,
+ ctx->Stencil.ZFailFunc,
+ ctx->Stencil.ZPassFunc);
+ tmp |= FFB_FBC_YE_MASK;
+ } else {
+ fmesa->stencil = 0xf0000000;
+ fmesa->stencilctl = 0x33300000;
+ fmesa->state_dirty |= FFB_STATE_STENCIL;
+ fmesa->state_fifo_ents += 6;
+ tmp |= FFB_FBC_YE_OFF;
+ }
+ if (tmp != fmesa->fbc) {
+ fmesa->fbc = tmp;
+ fmesa->state_dirty |= FFB_STATE_FBC;
+ fmesa->state_fifo_ents += 1;
+ }
+ break;
+
+ case GL_FOG:
+ /* Until I implement the fog support... */
+ if (state)
+ fmesa->bad_fragment_attrs |= FFB_BADATTR_FOG;
+ else
+ fmesa->bad_fragment_attrs &= ~FFB_BADATTR_FOG;
+ break;
+
+ case GL_LINE_STIPPLE:
+ if (! state)
+ fmesa->lpat = 0;
+ else
+ ffbDDLineStipple(ctx,
+ ctx->Line.StippleFactor,
+ ctx->Line.StipplePattern);
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ /* Do nothing, we interrogate the state during
+ * reduced primitive changes. Since our caller
+ * will set NEW_POLYGON in the ctx NewState this
+ * will cause the driver rasterization functions
+ * to be reevaluated, which will cause us to force
+ * a reduced primitive change next rendering pass
+ * and it all works out.
+ */
+ break;
+
+ default:
+ break;
+ };
+}
+
+void ffbSyncHardware(ffbContextPtr fmesa)
+{
+ ffb_fbcPtr ffb = fmesa->regs;
+ unsigned int dirty;
+ int i;
+
+ FFBFifo(fmesa, fmesa->state_fifo_ents);
+
+ dirty = fmesa->state_dirty;
+ if (dirty & (FFB_STATE_FBC | FFB_STATE_PPC | FFB_STATE_DRAWOP |
+ FFB_STATE_ROP | FFB_STATE_LPAT | FFB_STATE_WID)) {
+ if (dirty & FFB_STATE_FBC)
+ ffb->fbc = fmesa->fbc;
+ if (dirty & FFB_STATE_PPC)
+ ffb->ppc = fmesa->ppc;
+ if (dirty & FFB_STATE_DRAWOP)
+ ffb->drawop = fmesa->drawop;
+ if (dirty & FFB_STATE_ROP)
+ ffb->rop = fmesa->rop;
+ if (dirty & FFB_STATE_LPAT)
+ ffb->rop = fmesa->lpat;
+ if (dirty & FFB_STATE_WID)
+ ffb->wid = fmesa->wid;
+ }
+ if (dirty & (FFB_STATE_PMASK | FFB_STATE_XPMASK | FFB_STATE_YPMASK |
+ FFB_STATE_ZPMASK | FFB_STATE_XCLIP | FFB_STATE_CMP |
+ FFB_STATE_MATCHAB | FFB_STATE_MAGNAB | FFB_STATE_MATCHC |
+ FFB_STATE_MAGNC)) {
+ if (dirty & FFB_STATE_PMASK)
+ ffb->pmask = fmesa->pmask;
+ if (dirty & FFB_STATE_XPMASK)
+ ffb->xpmask = fmesa->xpmask;
+ if (dirty & FFB_STATE_YPMASK)
+ ffb->ypmask = fmesa->ypmask;
+ if (dirty & FFB_STATE_ZPMASK)
+ ffb->zpmask = fmesa->zpmask;
+ if (dirty & FFB_STATE_XCLIP)
+ ffb->xclip = fmesa->xclip;
+ if (dirty & FFB_STATE_CMP)
+ ffb->cmp = fmesa->cmp;
+ if (dirty & FFB_STATE_MATCHAB)
+ ffb->matchab = fmesa->matchab;
+ if (dirty & FFB_STATE_MAGNAB)
+ ffb->magnab = fmesa->magnab;
+ if (dirty & FFB_STATE_MATCHC)
+ ffb->matchc = fmesa->matchc;
+ if (dirty & FFB_STATE_MAGNC)
+ ffb->magnc = fmesa->magnc;
+ }
+
+ if (dirty & FFB_STATE_DCUE) {
+ ffb->dcss = fmesa->dcss;
+ ffb->dcsf = fmesa->dcsf;
+ ffb->dcsb = fmesa->dcsb;
+ ffb->dczf = fmesa->dczf;
+ ffb->dczb = fmesa->dczb;
+ if (fmesa->ffb_sarea->flags & (FFB_DRI_FFB2 | FFB_DRI_FFB2PLUS)) {
+ ffb->dcss1 = fmesa->dcss1;
+ ffb->dcss2 = fmesa->dcss2;
+ ffb->dcss3 = fmesa->dcss3;
+ ffb->dcs2 = fmesa->dcs2;
+ ffb->dcs3 = fmesa->dcs3;
+ ffb->dcs4 = fmesa->dcs4;
+ ffb->dcd2 = fmesa->dcd2;
+ ffb->dcd3 = fmesa->dcd3;
+ ffb->dcd4 = fmesa->dcd4;
+ }
+ }
+
+ if (dirty & FFB_STATE_BLEND) {
+ ffb->blendc = fmesa->blendc;
+ ffb->blendc1 = fmesa->blendc1;
+ ffb->blendc2 = fmesa->blendc2;
+ }
+
+ if (dirty & FFB_STATE_CLIP) {
+ ffb->vclipmin = fmesa->vclipmin;
+ ffb->vclipmax = fmesa->vclipmax;
+ ffb->vclipzmin = fmesa->vclipzmin;
+ ffb->vclipzmax = fmesa->vclipzmax;
+ for (i = 0; i < 4; i++) {
+ ffb->auxclip[i].min = fmesa->aux_clips[i].min;
+ ffb->auxclip[i].max = fmesa->aux_clips[i].max;
+ }
+ }
+
+ if ((dirty & FFB_STATE_STENCIL) &&
+ (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) {
+ ffb->stencil = fmesa->stencil;
+ ffb->stencilctl = fmesa->stencilctl;
+ ffb->fbc = FFB_FBC_WB_C;
+ ffb->rawstencilctl = (fmesa->stencilctl | (1 << 19));
+ ffb->fbc = fmesa->fbc;
+ ffb->consty = fmesa->consty;
+ }
+
+ if (dirty & FFB_STATE_APAT) {
+ for (i = 0; i < 32; i++)
+ ffb->pattern[i] = fmesa->pattern[i];
+ }
+
+ fmesa->state_dirty = 0;
+ fmesa->state_fifo_ents = 0;
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void ffbDDRenderStart(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ LOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 1;
+
+ if (fmesa->state_dirty != 0)
+ ffbSyncHardware(fmesa);
+}
+
+static void ffbDDRenderFinish(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ UNLOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 0;
+}
+
+#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|\
+ NEW_TEXTURE_MATRIX|\
+ NEW_USER_CLIP|NEW_CLIENT_STATE|\
+ NEW_TEXTURE_ENABLE))
+
+static void ffbDDUpdateState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int flags;
+
+ if (ctx->NewState & INTERESTED) {
+ if (fmesa->SWrender ||
+ fmesa->bad_fragment_attrs != 0) {
+ /* Force SW rendering. */
+ fmesa->PointsFunc = NULL;
+ fmesa->LineFunc = NULL;
+ fmesa->TriangleFunc = NULL;
+ fmesa->QuadFunc = NULL;
+ } else {
+ ffbDDChooseTriRenderState(ctx);
+ ffbDDChooseLineRenderState(ctx);
+ ffbDDChoosePointRenderState(ctx);
+ }
+
+ if (0)
+ gl_print_tri_caps("tricaps", ctx->TriangleCaps);
+
+ ffbChooseRasterSetupFunc(ctx);
+
+ /* Force a reduced primitive change next rendering
+ * pass.
+ */
+ ctx->PB->primitive = GL_POLYGON + 1;
+ }
+
+#if 0
+ /* When the modelview matrix changes, this changes what
+ * the eye coordinates will be so we have to recompute
+ * the depth cueing parameters.
+ *
+ * XXX DD_HAVE_HARDWARE_FOG.
+ */
+ if (ctx->Fog.Enabled && (ctx->NewState & NEW_MODELVIEW))
+ ffb_update_fog();
+#endif
+
+ /* XXX It may be possible to eliminate all of Mesa's sw clip
+ * XXX processing using the hw clip registers we have. If
+ * XXX this is correct, it is just a matter of verifying the
+ * XXX FFB coordinate overflow rules in ffb_vb.c and if they
+ * XXX are not violated we clear CLIP_MASK_ACTIVE in
+ * XXX VB->CullMode.
+ * XXX
+ * XXX We would specify the xyz min/max values in the primary
+ * XXX viewport clip registers, and the user specified
+ * XXX scissor clip can go into one of the auxilliary viewport
+ * XXX clips.
+ */
+ flags = ctx->IndirectTriangles;
+ if (fmesa->PointsFunc != NULL) {
+ ctx->Driver.PointsFunc = fmesa->PointsFunc;
+ flags &= ~DD_POINT_SW_RASTERIZE;
+ }
+ if (fmesa->LineFunc != NULL) {
+ ctx->Driver.LineFunc = fmesa->LineFunc;
+ flags &= ~DD_LINE_SW_RASTERIZE;
+ }
+ if (fmesa->TriangleFunc != NULL) {
+ ctx->Driver.TriangleFunc = fmesa->TriangleFunc;
+ ctx->Driver.QuadFunc = fmesa->QuadFunc;
+ flags &= ~(DD_TRI_SW_RASTERIZE |
+ DD_QUAD_SW_RASTERIZE);
+ }
+ ctx->IndirectTriangles = flags;
+}
+
+void ffbDDInitStateFuncs(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ ctx->Driver.UpdateState = ffbDDUpdateState;
+ ctx->Driver.Enable = ffbDDEnable;
+ ctx->Driver.LightModelfv = NULL;
+ ctx->Driver.AlphaFunc = ffbDDAlphaFunc;
+ ctx->Driver.BlendEquation = ffbDDBlendEquation;
+ ctx->Driver.BlendFunc = ffbDDBlendFunc;
+ ctx->Driver.BlendFuncSeparate = ffbDDBlendFuncSeparate;
+ ctx->Driver.DepthFunc = ffbDDDepthFunc;
+ ctx->Driver.DepthMask = ffbDDDepthMask;
+ ctx->Driver.Fogfv = ffbDDFogfv;
+ ctx->Driver.LineStipple = ffbDDLineStipple;
+ ctx->Driver.PolygonStipple = ffbDDPolygonStipple;
+ ctx->Driver.Scissor = ffbDDScissor;
+ ctx->Driver.CullFace = NULL;
+ ctx->Driver.FrontFace = NULL;
+ ctx->Driver.ColorMask = ffbDDColorMask;
+ ctx->Driver.LogicOp = ffbDDLogicOp;
+ ctx->Driver.ReducedPrimitiveChange = ffbDDReducedPrimitiveChange;
+ ctx->Driver.RenderStart = ffbDDRenderStart;
+ ctx->Driver.RenderFinish = ffbDDRenderFinish;
+
+ if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) {
+ ctx->Driver.StencilFunc = ffbDDStencilFunc;
+ ctx->Driver.StencilMask = ffbDDStencilMask;
+ ctx->Driver.StencilOp = ffbDDStencilOp;
+ } else {
+ ctx->Driver.StencilFunc = NULL;
+ ctx->Driver.StencilMask = NULL;
+ ctx->Driver.StencilOp = NULL;
+ }
+
+ ctx->Driver.SetDrawBuffer = ffbDDSetDrawBuffer;
+ ctx->Driver.SetReadBuffer = ffbDDSetReadBuffer;
+ ctx->Driver.Color = ffbDDSetColor;
+ ctx->Driver.ClearColor = ffbDDClearColor;
+ ctx->Driver.ClearDepth = ffbDDClearDepth;
+ ctx->Driver.ClearStencil = ffbDDClearStencil;
+ ctx->Driver.Dither = NULL;
+
+ /* We will support color index modes later... -DaveM */
+ ctx->Driver.Index = 0;
+ ctx->Driver.ClearIndex = 0;
+ ctx->Driver.IndexMask = 0;
+}
+
+void ffbDDInitContextHwState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ int fifo_count = 0;
+ int i;
+
+ fmesa->hw_locked = 0;
+
+ fmesa->bad_fragment_attrs = 0;
+ fmesa->state_dirty = FFB_STATE_ALL;
+
+ fifo_count = 1;
+ fmesa->fbc = (FFB_FBC_WE_FORCEON | FFB_FBC_WM_COMBINED |
+ FFB_FBC_SB_BOTH | FFB_FBC_ZE_MASK |
+ FFB_FBC_YE_OFF | FFB_FBC_XE_OFF |
+ FFB_FBC_RGBE_MASK);
+ if (ctx->Visual->DBflag) {
+ /* Buffer B is the initial back buffer. */
+ fmesa->back_buffer = 1;
+ fmesa->fbc |= FFB_FBC_WB_BC | FFB_FBC_RB_B;
+ } else {
+ fmesa->back_buffer = 0;
+ fmesa->fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
+ }
+
+ fifo_count += 1;
+ fmesa->ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE |
+ FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_DISABLE |
+ FFB_PPC_APE_DISABLE | FFB_PPC_TBE_OPAQUE |
+ FFB_PPC_ZS_CONST | FFB_PPC_YS_CONST |
+ FFB_PPC_XS_WID | FFB_PPC_CS_VAR);
+
+ fifo_count += 3;
+ fmesa->drawop = FFB_DRAWOP_RECTANGLE;
+
+ /* GL_COPY is the default LogicOp. */
+ fmesa->rop = (FFB_ROP_NEW << 16) | (FFB_ROP_NEW << 8) | FFB_ROP_NEW;
+
+ /* No line patterning enabled. */
+ fmesa->lpat = 0x00000000;
+
+ /* We do not know the WID value until the first context switch. */
+ fifo_count += 1;
+ fmesa->wid = ~0;
+
+ fifo_count += 5;
+
+ /* ColorMask, all enabled. */
+ fmesa->pmask = 0xffffffff;
+
+ fmesa->xpmask = 0x000000ff;
+ fmesa->ypmask = 0x0000000f;
+ fmesa->zpmask = 0x0fffffff;
+
+ /* AlphaFunc GL_ALWAYS, AlphaRef 0 */
+ fmesa->xclip = FFB_XCLIP_TEST_ALWAYS | 0x00;
+
+ /* This sets us up to use WID clipping (so the DRI clipping
+ * rectangle is unneeded by us). All other match and magnitude
+ * tests are set to pass.
+ */
+ fifo_count += 5;
+ fmesa->cmp = ((FFB_CMP_MATCH_ALWAYS << 24) | /* MATCH C */
+ (FFB_CMP_MAGN_ALWAYS << 16) | /* MAGN C */
+ (FFB_CMP_MATCH_EQ << 8) | /* MATCH AB */
+ (FFB_CMP_MAGN_ALWAYS << 0)); /* MAGN AB */
+ fmesa->matchab = 0xff000000;
+ fmesa->magnab = 0x00000000;
+ fmesa->matchc = 0x00000000;
+ fmesa->magnc = 0x00000000;
+
+ /* Depth cue parameters, all zeros to start. */
+ fifo_count += 14;
+ fmesa->dcss = 0x00000000;
+ fmesa->dcsf = 0x00000000;
+ fmesa->dcsb = 0x00000000;
+ fmesa->dczf = 0x00000000;
+ fmesa->dczb = 0x00000000;
+ fmesa->dcss1 = 0x00000000;
+ fmesa->dcss2 = 0x00000000;
+ fmesa->dcss3 = 0x00000000;
+ fmesa->dcs2 = 0x00000000;
+ fmesa->dcs3 = 0x00000000;
+ fmesa->dcs4 = 0x00000000;
+ fmesa->dcd2 = 0x00000000;
+ fmesa->dcd3 = 0x00000000;
+ fmesa->dcd4 = 0x00000000;
+
+ /* Alpha blending unit state. */
+ fifo_count += 3;
+ fmesa->blendc = (1 << 0) | (0 << 2); /* src(GL_ONE) | dst(GL_ZERO) */
+ fmesa->blendc1 = 0x00000000;
+ fmesa->blendc2 = 0x00000000;
+
+ /* ViewPort clip state. */
+ fifo_count += 4 + (4 * 2);
+ fmesa->vclipmin = 0x00000000;
+ fmesa->vclipmax = 0x00000000;
+ fmesa->vclipzmin = 0x00000000;
+ fmesa->vclipzmax = 0x00000000;
+ for (i = 0; i < 4; i++) {
+ fmesa->aux_clips[0].min = 0x00000000;
+ fmesa->aux_clips[0].max = 0x00000000;
+ }
+
+ /* Stenciling state. */
+ fifo_count += 6;
+ fmesa->stencil = 0xf0000000; /* Stencil MASK, Y plane */
+ fmesa->stencilctl = 0x33300000; /* All stencil tests disabled */
+ fmesa->consty = 0x0;
+
+ /* Area pattern, used for polygon stipples. */
+ fifo_count += 32;
+ for (i = 0; i < 32; i++)
+ fmesa->pattern[i] = 0x00000000;
+
+ fmesa->state_fifo_ents = fifo_count;
+ fmesa->state_all_fifo_ents = fifo_count;
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_state.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.h
new file mode 100644
index 000000000..4221b503a
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.h
@@ -0,0 +1,13 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_state.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+
+#ifndef _FFB_STATE_H
+#define _FFB_STATE_H
+
+extern void ffbDDInitStateFuncs(GLcontext *);
+extern void ffbDDInitContextHwState(GLcontext *);
+
+extern void ffbDDScissor(GLcontext *, GLint, GLint, GLint, GLint);
+extern void ffbXformAreaPattern(ffbContextPtr, const GLubyte *);
+extern void ffbSyncHardware(ffbContextPtr fmesa);
+
+#endif /* !(_FFB_STATE_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c
new file mode 100644
index 000000000..5292973c4
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c
@@ -0,0 +1,200 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c,v 1.1 2000/06/20 05:08:39 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_context.h"
+#include "ffb_stencil.h"
+#include "ffb_lock.h"
+
+static void
+FFBWriteStencilSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLstencil stencil[], const GLubyte mask[])
+{
+ if (ctx->Depth.Mask) {
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint *zptr;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_OFF |
+ FFB_FBC_YE_ON | FFB_FBC_RGBE_OFF);
+ fmesa->regs->ppc = FFB_PPC_YS_VAR;
+ FFBWait(fmesa, fmesa->regs);
+
+ y = (dPriv->h - y);
+ zptr = (GLuint *)
+ ((char *)fmesa->sfb32 +
+ ((dPriv->x + x) << 2) +
+ ((dPriv->y + y) << 13));
+
+ for (i = 0; i < n; i++) {
+ if (mask[i])
+ *zptr = (stencil[i] & 0xf) << 28;
+ zptr++;
+ }
+
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->regs->ppc = fmesa->ppc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+ }
+}
+
+static void
+FFBWriteStencilPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
+ const GLstencil stencil[], const GLubyte mask[])
+{
+ if (ctx->Depth.Mask) {
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ char *zbase;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_OFF |
+ FFB_FBC_YE_ON | FFB_FBC_RGBE_OFF);
+ fmesa->regs->ppc = FFB_PPC_YS_VAR;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ zbase = ((char *)fmesa->sfb32 +
+ (dPriv->x << 2) + (dPriv->y << 13));
+
+ for (i = 0; i < n; i++) {
+ GLint y1 = (dPriv->h - y[i]);
+ GLint x1 = x[i];
+ GLuint *zptr;
+
+ zptr = (GLuint *)
+ (zbase + (x1 << 2) + (y1 << 13));
+ if (mask[i])
+ *zptr = (stencil[i] & 0xf) << 28;
+ }
+
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->regs->ppc = fmesa->ppc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+ }
+}
+
+static void
+FFBReadStencilSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, GLstencil stencil[])
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint *zptr;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = FFB_FBC_RB_C;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ y = (dPriv->h - y);
+ zptr = (GLuint *)
+ ((char *)fmesa->sfb32 +
+ ((dPriv->x + x) << 2) +
+ ((dPriv->y + y) << 13));
+
+ for (i = 0; i < n; i++) {
+ stencil[i] = (*zptr >> 28) & 0xf;
+ zptr++;
+ }
+
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+}
+
+static void
+FFBReadStencilPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
+ GLstencil stencil[])
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ char *zbase;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = FFB_FBC_RB_C;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ zbase = ((char *)fmesa->sfb32 +
+ (dPriv->x << 2) + (dPriv->y << 13));
+
+ for (i = 0; i < n; i++) {
+ GLint y1 = (dPriv->h - y[i]);
+ GLint x1 = x[i];
+ GLuint *zptr;
+
+ zptr = (GLuint *)
+ (zbase + (x1 << 2) + (y1 << 13));
+ stencil[i] = (*zptr >> 28) & 0xf;
+ }
+
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+}
+
+void ffbDDInitStencilFuncs(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) {
+ ctx->Driver.WriteStencilSpan = FFBWriteStencilSpan;
+ ctx->Driver.ReadStencilSpan = FFBReadStencilSpan;
+ ctx->Driver.WriteStencilPixels = FFBWriteStencilPixels;
+ ctx->Driver.ReadStencilPixels = FFBReadStencilPixels;
+ } else {
+ ctx->Driver.WriteStencilSpan = NULL;
+ ctx->Driver.ReadStencilSpan = NULL;
+ ctx->Driver.WriteStencilPixels = NULL;
+ ctx->Driver.ReadStencilPixels = NULL;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.h
new file mode 100644
index 000000000..af161e7c1
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+
+#ifndef _FFB_STENCIL_H
+#define _FFB_STENCIL_H
+
+extern void ffbDDInitStencilFuncs(GLcontext *ctx);
+
+#endif /* !(_FFB_STENCIL_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c
new file mode 100644
index 000000000..1e60b4d5d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c
@@ -0,0 +1,292 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c,v 1.1 2000/06/20 05:08:40 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "types.h"
+#include "vbrender.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+#include "vb.h"
+#include "dd.h"
+
+#undef TRI_DEBUG
+
+#ifdef TRI_DEBUG
+#define FFB_DUMP_PRIM(name) \
+ fprintf(stderr, "FFB: Begin primitive %s%s%s" #name ".\n", \
+ (IND & FFB_TRI_OFFSET_BIT) ? "OFFSET " : "", \
+ (IND & FFB_TRI_FLAT_BIT) ? "FLAT " : "", \
+ (IND & FFB_TRI_TWOSIDE_BIT) ? "TWOSIDE " : "")
+#define FFB_DUMP_VERTEX(V) \
+ fprintf(stderr, "FFB: VERTEX ARGB(%c%x.%08x:%c%x.%08x:%c%x.%08x:%c%x.%08x) " \
+ "XYZ(%04x.%04x:%04x.%04x:%c%x.%08x)\n", \
+ (((V)->color[which_color].alpha & (1 << 31)) ? '-' : ' '), \
+ (((V)->color[which_color].alpha & (1 << 30)) >> 30), \
+ (((V)->color[which_color].alpha & ((1 << 30) - 1))), \
+ (((V)->color[which_color].red & (1 << 31)) ? '-' : ' '), \
+ (((V)->color[which_color].red & (1 << 30)) >> 30), \
+ (((V)->color[which_color].red & ((1 << 30) - 1))), \
+ (((V)->color[which_color].green & (1 << 31)) ? '-' : ' '), \
+ (((V)->color[which_color].green & (1 << 30)) >> 30), \
+ (((V)->color[which_color].green & ((1 << 30) - 1))), \
+ (((V)->color[which_color].blue & (1 << 31)) ? '-' : ' '), \
+ (((V)->color[which_color].blue & (1 << 30)) >> 30), \
+ (((V)->color[which_color].blue & ((1 << 30) - 1))), \
+ (((V)->x >> 16)), (((V)->x & ((1 << 16) - 1))), \
+ (((V)->y >> 16)), (((V)->y & ((1 << 16) - 1))), \
+ (((V)->z & (1 << 31)) ? '-' : ' '), \
+ (((V)->z & (1 << 30)) >> 30), \
+ (((V)->z & ((1 << 30) - 1))))
+#else
+#define FFB_DUMP_PRIM(name) do { } while(0)
+#define FFB_DUMP_VERTEX(V) do { } while(0)
+#endif
+
+#define FFB_TRI_FLAT_BIT 0x01
+#define FFB_TRI_TWOSIDE_BIT 0x02
+#define FFB_TRI_OFFSET_BIT 0x04
+#define FFB_TRI_CULL_BIT 0x08
+#define FFB_TRI_ALPHA_BIT 0x10
+#define FFB_TRI_FALLBACK_BIT 0x20
+
+static triangle_func ffb_tri_tab[0x40];
+static quad_func ffb_quad_tab[0x40];
+
+#define IND (0)
+#define TAG(x) x
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_TWOSIDE_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT)
+#define TAG(x) x##_cull
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_cull_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT|FFB_TRI_OFFSET_BIT)
+#define TAG(x) x##_cull_offset
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_cull_offset_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT)
+#define TAG(x) x##_cull_twoside
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_cull_twoside_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT)
+#define TAG(x) x##_cull_twoside_offset
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_cull_twoside_offset_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_OFFSET_BIT)
+#define TAG(x) x##_alpha_offset
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_offset_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_TWOSIDE_BIT)
+#define TAG(x) x##_alpha_twoside
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_twoside_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT)
+#define TAG(x) x##_alpha_twoside_offset
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_twoside_offset_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT)
+#define TAG(x) x##_alpha_cull
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_cull_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_OFFSET_BIT)
+#define TAG(x) x##_alpha_cull_offset
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_cull_offset_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT)
+#define TAG(x) x##_alpha_cull_twoside
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_cull_twoside_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT)
+#define TAG(x) x##_alpha_cull_twoside_offset
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_cull_twoside_offset_flat
+#include "ffb_tritmp.h"
+
+void ffbDDTrifuncInit()
+{
+ init();
+ init_flat();
+ init_offset();
+ init_offset_flat();
+ init_twoside();
+ init_twoside_flat();
+ init_twoside_offset();
+ init_twoside_offset_flat();
+ init_cull();
+ init_cull_flat();
+ init_cull_offset();
+ init_cull_offset_flat();
+ init_cull_twoside();
+ init_cull_twoside_flat();
+ init_cull_twoside_offset();
+ init_cull_twoside_offset_flat();
+ init_alpha();
+ init_alpha_flat();
+ init_alpha_offset();
+ init_alpha_offset_flat();
+ init_alpha_twoside();
+ init_alpha_twoside_flat();
+ init_alpha_twoside_offset();
+ init_alpha_twoside_offset_flat();
+ init_alpha_cull();
+ init_alpha_cull_flat();
+ init_alpha_cull_offset();
+ init_alpha_cull_offset_flat();
+ init_alpha_cull_twoside();
+ init_alpha_cull_twoside_flat();
+ init_alpha_cull_twoside_offset();
+ init_alpha_cull_twoside_offset_flat();
+}
+
+void ffbDDChooseTriRenderState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint flags = ctx->TriangleCaps;
+ GLuint ind = 0;
+
+ if (!flags) {
+ fmesa->TriangleFunc = ffb_tri_tab[0];
+ fmesa->QuadFunc = ffb_quad_tab[0];
+ return;
+ }
+
+ if (ctx->Texture.ReallyEnabled) {
+ fmesa->TriangleFunc = NULL;
+ fmesa->QuadFunc = NULL;
+ return;
+ }
+
+ if (flags & DD_FLATSHADE)
+ ind |= FFB_TRI_FLAT_BIT;
+ if (flags & DD_TRI_CULL)
+ ind |= FFB_TRI_CULL_BIT;
+ if (ctx->Polygon.SmoothFlag)
+ ind |= FFB_TRI_FALLBACK_BIT;
+ if (flags & DD_TRI_OFFSET)
+ ind |= FFB_TRI_OFFSET_BIT;
+ if (flags & DD_TRI_LIGHT_TWOSIDE)
+ ind |= FFB_TRI_TWOSIDE_BIT;
+
+ /* If blending or the alpha test is enabled we need to
+ * provide alpha components to the chip, else we can
+ * do without it and thus feed vertex data to the chip
+ * more efficiently.
+ */
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ ind |= FFB_TRI_ALPHA_BIT;
+
+ fmesa->TriangleFunc = ffb_tri_tab[ind];
+ fmesa->QuadFunc = ffb_quad_tab[ind];
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h
new file mode 100644
index 000000000..0fffb3d79
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h
@@ -0,0 +1,9 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h,v 1.1 2000/06/20 05:08:40 dawes Exp $ */
+
+#ifndef _FFB_TRIS_H
+#define _FFB_TRIS_H
+
+extern void ffbDDTrifuncInit(void);
+extern void ffbDDChooseTriRenderState(GLcontext *);
+
+#endif /* !(_FFB_TRIS_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h
new file mode 100644
index 000000000..ba7312238
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h
@@ -0,0 +1,324 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h,v 1.1 2000/06/20 05:08:40 dawes Exp $ */
+
+static void TAG(ffb_triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2, GLuint pv)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+ struct vertex_buffer *VB = ctx->VB;
+ ffb_vertex *ffbVB = FFB_DRIVER_DATA(VB)->verts;
+ const ffb_vertex *v0 = &ffbVB[e0];
+ const ffb_vertex *v1 = &ffbVB[e1];
+ const ffb_vertex *v2 = &ffbVB[e2];
+#if (IND & FFB_TRI_OFFSET_BIT)
+ GLuint ffb_zoffset = FFB_Z_FROM_FLOAT(ctx->PolygonZoffset);
+#endif
+#if (IND & FFB_TRI_FLAT_BIT)
+ GLuint const_fg;
+#endif
+#if (IND & FFB_TRI_TWOSIDE_BIT)
+ int which_color = (VB->ColorPtr == VB->Color[0]) ? 0 : 1;
+#else
+ const int which_color = 0;
+#endif
+
+#if (IND & FFB_TRI_CULL_BIT)
+ {
+ GLfloat (*win)[4] = VB->Win.data;
+ GLfloat ex = win[e1][0] - win[e0][0];
+ GLfloat ey = win[e1][1] - win[e0][1];
+ GLfloat fx = win[e2][0] - win[e0][0];
+ GLfloat fy = win[e2][1] - win[e0][1];
+ GLfloat c = ex*fy-ey*fx;
+
+ /* Culled... */
+ if (c * ctx->backface_sign > 0)
+ return;
+ }
+#endif
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ const_fg = (((GLuint)VB->Color[which_color]->data[pv][0] << 0) |
+ ((GLuint)VB->Color[which_color]->data[pv][1] << 8) |
+ ((GLuint)VB->Color[which_color]->data[pv][2] << 16) |
+ ((GLuint)VB->Color[which_color]->data[pv][3] << 24));
+#endif
+
+ FFB_DUMP_PRIM(TRIANGLE);
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ FFBFifo(fmesa, 1);
+ ffb->fg = const_fg;
+#endif
+
+ /* First, check for a triangle strip/fan sequences.
+ * These checks rely on how MESA sends these primitives
+ * down to us in render_tmp.h
+ */
+ if (v0 == fmesa->vtx_cache[1] &&
+ v1 == fmesa->vtx_cache[2] &&
+ v2 != fmesa->vtx_cache[0]) {
+#if (IND & FFB_TRI_FLAT_BIT)
+ FFBFifo(fmesa, 3);
+#else
+#if (IND & FFB_TRI_ALPHA_BIT)
+ FFBFifo(fmesa, 7);
+#else
+ FFBFifo(fmesa, 6);
+#endif
+#endif
+ FFB_DUMP_VERTEX(v2);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v2->color[which_color].alpha;
+#endif
+ ffb->red = v2->color[which_color].red;
+ ffb->green = v2->color[which_color].green;
+ ffb->blue = v2->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v2->z + ffb_zoffset;
+#else
+ ffb->z = v2->z;
+#endif
+ ffb->y = v2->y;
+ ffb->x = v2->x;
+
+ goto update_vcache;
+ } else if (v0 == fmesa->vtx_cache[0] &&
+ v1 == fmesa->vtx_cache[2] &&
+ v2 != fmesa->vtx_cache[1]) {
+#if (IND & FFB_TRI_FLAT_BIT)
+ FFBFifo(fmesa, 3);
+#else
+#if (IND & FFB_TRI_ALPHA_BIT)
+ FFBFifo(fmesa, 7);
+#else
+ FFBFifo(fmesa, 6);
+#endif
+#endif
+ FFB_DUMP_VERTEX(v2);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v2->color[which_color].alpha;
+#endif
+ ffb->red = v2->color[which_color].red;
+ ffb->green = v2->color[which_color].green;
+ ffb->blue = v2->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v2->z + ffb_zoffset;
+#else
+ ffb->z = v2->z;
+#endif
+ ffb->dmyf = v2->y;
+ ffb->dmxf = v2->x;
+
+ goto update_vcache;
+ }
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ FFBFifo(fmesa, 9);
+#else
+#if (IND & FFB_TRI_ALPHA_BIT)
+ FFBFifo(fmesa, 21);
+#else
+ FFBFifo(fmesa, 18);
+#endif
+#endif
+
+ FFB_DUMP_VERTEX(v0);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v0->color[which_color].alpha;
+#endif
+ ffb->red = v0->color[which_color].red;
+ ffb->green = v0->color[which_color].green;
+ ffb->blue = v0->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v0->z + ffb_zoffset;
+#else
+ ffb->z = v0->z;
+#endif
+ ffb->ryf = v0->y;
+ ffb->rxf = v0->x;
+
+ FFB_DUMP_VERTEX(v1);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v1->color[which_color].alpha;
+#endif
+ ffb->red = v1->color[which_color].red;
+ ffb->green = v1->color[which_color].green;
+ ffb->blue = v1->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v1->z + ffb_zoffset;
+#else
+ ffb->z = v1->z;
+#endif
+ ffb->y = v1->y;
+ ffb->x = v1->x;
+
+ FFB_DUMP_VERTEX(v2);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v2->color[which_color].alpha;
+#endif
+ ffb->red = v2->color[which_color].red;
+ ffb->green = v2->color[which_color].green;
+ ffb->blue = v2->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v2->z + ffb_zoffset;
+#else
+ ffb->z = v2->z;
+#endif
+ ffb->y = v2->y;
+ ffb->x = v2->x;
+
+update_vcache:
+ fmesa->vtx_cache[0] = (void *)v0;
+ fmesa->vtx_cache[1] = (void *)v1;
+ fmesa->vtx_cache[2] = (void *)v2;
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+
+static void TAG(ffb_quad)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2, GLuint e3, GLuint pv)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+ struct vertex_buffer *VB = ctx->VB;
+ ffb_vertex *ffbVB = FFB_DRIVER_DATA(VB)->verts;
+ const ffb_vertex *v0 = &ffbVB[e0];
+ const ffb_vertex *v1 = &ffbVB[e1];
+ const ffb_vertex *v2 = &ffbVB[e2];
+ const ffb_vertex *v3 = &ffbVB[e3];
+#if (IND & FFB_TRI_OFFSET_BIT)
+ GLuint ffb_zoffset = FFB_Z_FROM_FLOAT(ctx->PolygonZoffset);
+#endif
+#if (IND & FFB_TRI_FLAT_BIT)
+ GLuint const_fg;
+#endif
+#if (IND & FFB_TRI_TWOSIDE_BIT)
+ int which_color = (VB->ColorPtr == VB->Color[0]) ? 0 : 1;
+#else
+ const int which_color = 0;
+#endif
+
+#if (IND & FFB_TRI_CULL_BIT)
+ {
+ GLfloat (*win)[4] = VB->Win.data;
+ GLfloat ex = win[e2][0] - win[e0][0];
+ GLfloat ey = win[e2][1] - win[e0][1];
+ GLfloat fx = win[e3][0] - win[e1][0];
+ GLfloat fy = win[e3][1] - win[e1][1];
+ GLfloat c = ex*fy-ey*fx;
+
+ /* Culled... */
+ if (c * ctx->backface_sign > 0)
+ return;
+ }
+#endif
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ const_fg = (((GLuint)VB->Color[which_color]->data[pv][0] << 0) |
+ ((GLuint)VB->Color[which_color]->data[pv][1] << 8) |
+ ((GLuint)VB->Color[which_color]->data[pv][2] << 16) |
+ ((GLuint)VB->Color[which_color]->data[pv][3] << 24));
+#endif
+
+ FFB_DUMP_PRIM(QUAD);
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ FFBFifo(fmesa, 13);
+ ffb->fg = const_fg;
+#else
+#if (IND & FFB_TRI_ALPHA_BIT)
+ FFBFifo(fmesa, 28);
+#else
+ FFBFifo(fmesa, 24);
+#endif
+#endif
+
+ FFB_DUMP_VERTEX(v0);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v0->color[which_color].alpha;
+#endif
+ ffb->red = v0->color[which_color].red;
+ ffb->green = v0->color[which_color].green;
+ ffb->blue = v0->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v0->z + ffb_zoffset;
+#else
+ ffb->z = v0->z;
+#endif
+ ffb->ryf = v0->y;
+ ffb->rxf = v0->x;
+
+ FFB_DUMP_VERTEX(v1);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v1->color[which_color].alpha;
+#endif
+ ffb->red = v1->color[which_color].red;
+ ffb->green = v1->color[which_color].green;
+ ffb->blue = v1->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v1->z + ffb_zoffset;
+#else
+ ffb->z = v1->z;
+#endif
+ ffb->y = v1->y;
+ ffb->x = v1->x;
+
+ FFB_DUMP_VERTEX(v2);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v2->color[which_color].alpha;
+#endif
+ ffb->red = v2->color[which_color].red;
+ ffb->green = v2->color[which_color].green;
+ ffb->blue = v2->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v2->z + ffb_zoffset;
+#else
+ ffb->z = v2->z;
+#endif
+ ffb->y = v2->y;
+ ffb->x = v2->x;
+
+ FFB_DUMP_VERTEX(v3);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = v3->color[which_color].alpha;
+#endif
+ ffb->red = v3->color[which_color].red;
+ ffb->green = v3->color[which_color].green;
+ ffb->blue = v3->color[which_color].blue;
+#endif
+#if (IND & FFB_TRI_OFFSET_BIT)
+ ffb->z = v3->z + ffb_zoffset;
+#else
+ ffb->z = v3->z;
+#endif
+ ffb->dmyf = v3->y;
+ ffb->dmxf = v3->x;
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(init)(void)
+{
+ ffb_tri_tab[IND] = TAG(ffb_triangle);
+ ffb_quad_tab[IND] = TAG(ffb_quad);
+}
+
+#undef IND
+#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c
new file mode 100644
index 000000000..c48b06082
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c
@@ -0,0 +1,318 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c,v 1.1 2000/06/20 05:08:40 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "ffb_xmesa.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+
+#include "stages.h"
+
+#define COL { \
+ GLubyte *col = &(VB->Color[0]->data[i][0]); \
+ v->color[0].alpha = FFB_COLOR_FROM_UBYTE(col[3]); \
+ v->color[0].red = FFB_COLOR_FROM_UBYTE(col[0]); \
+ v->color[0].green = FFB_COLOR_FROM_UBYTE(col[1]); \
+ v->color[0].blue = FFB_COLOR_FROM_UBYTE(col[2]); \
+}
+
+#define COL2 { \
+ GLubyte *col = &(VB->Color[0]->data[i][0]); \
+ v->color[0].alpha = FFB_COLOR_FROM_UBYTE(col[3]); \
+ v->color[0].red = FFB_COLOR_FROM_UBYTE(col[0]); \
+ v->color[0].green = FFB_COLOR_FROM_UBYTE(col[1]); \
+ v->color[0].blue = FFB_COLOR_FROM_UBYTE(col[2]); \
+ \
+ col = &(VB->Color[1]->data[i][0]); \
+ v->color[1].alpha = FFB_COLOR_FROM_UBYTE(col[3]); \
+ v->color[1].red = FFB_COLOR_FROM_UBYTE(col[0]); \
+ v->color[1].green = FFB_COLOR_FROM_UBYTE(col[1]); \
+ v->color[1].blue = FFB_COLOR_FROM_UBYTE(col[2]); \
+}
+
+#define COORD { \
+ GLfloat *win = VB->Win.data[i]; \
+ GLfloat tmp; \
+ tmp = win[0] + ffbxoff; \
+ v->x = FFB_COORD_FROM_FLOAT(tmp); \
+ tmp = - win[1] + ffbyoff; \
+ v->y = FFB_COORD_FROM_FLOAT(tmp); \
+ tmp = win[2] * (1.0f / 65536.0f); \
+ v->z = FFB_Z_FROM_FLOAT(tmp); \
+}
+
+#define NOP
+
+#define SETUPFUNC(name,win,col) \
+static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \
+{ \
+ ffbContextPtr fmesa = FFB_CONTEXT(VB->ctx); \
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
+ ffb_vertex *v; \
+ GLfloat ffbxoff = dPriv->x - 0.5; \
+ GLfloat ffbyoff = dPriv->h - 0.5 + dPriv->y; \
+ int i; \
+ (void) fmesa; (void) ffbxoff; (void) ffbyoff; \
+ \
+ if (0) \
+ fprintf(stderr, #name ": VB(%p) start(%d) end(%d)\n", \
+ VB, start, end); \
+ /* Flush the vertex cache. */ \
+ fmesa->vtx_cache[0] = fmesa->vtx_cache[1] = \
+ fmesa->vtx_cache[2] = fmesa->vtx_cache[3] = NULL; \
+ gl_import_client_data(VB, VB->ctx->RenderFlags, \
+ (VB->ClipOrMask \
+ ? VEC_WRITABLE | VEC_GOOD_STRIDE \
+ : VEC_GOOD_STRIDE)); \
+ \
+ v = &(FFB_DRIVER_DATA(VB)->verts[start]); \
+ \
+ if (VB->ClipOrMask == 0) { \
+ for (i = start; i < end; i++, v++) { \
+ win; \
+ col; \
+ } \
+ } else { \
+ for (i = start; i < end; i++, v++) { \
+ if (VB->ClipMask[i] == 0) { \
+ win; \
+ } \
+ col; \
+ } \
+ } \
+}
+
+SETUPFUNC(rs_w, COORD,NOP)
+SETUPFUNC(rs_g, NOP,COL)
+SETUPFUNC(rs_g2, NOP,COL2)
+SETUPFUNC(rs_wg, COORD,COL)
+SETUPFUNC(rs_wg2, COORD,COL2)
+
+static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end)
+{
+ fprintf(stderr, "ffbRasterSetup(): invalid setup function\n");
+}
+
+typedef void (*setupFunc)(struct vertex_buffer *, GLuint, GLuint);
+
+static setupFunc setup_func[8];
+
+void ffbDDSetupInit(void)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ setup_func[i] = rs_invalid;
+
+ setup_func[FFB_VB_WIN_BIT] = rs_w;
+ setup_func[FFB_VB_RGBA_BIT] = rs_g;
+ setup_func[FFB_VB_RGBA_BIT|FFB_VB_TWOSIDE_BIT] = rs_g2;
+ setup_func[FFB_VB_WIN_BIT|FFB_VB_RGBA_BIT] = rs_wg;
+ setup_func[FFB_VB_WIN_BIT|FFB_VB_RGBA_BIT|FFB_VB_TWOSIDE_BIT] = rs_wg2;
+}
+
+static void ffbPrintSetupFlags(char *msg, GLuint flags)
+{
+ fprintf(stderr, "%s: %x %s%s%s\n",
+ msg, flags,
+ (flags & FFB_VB_WIN_BIT) ? " xyz," : "",
+ (flags & FFB_VB_TWOSIDE_BIT) ? " twoside," : "",
+ (flags & FFB_VB_RGBA_BIT) ? " rgba," : "");
+}
+
+void ffbChooseRasterSetupFunc(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ int funcindex;
+
+ /* Currently just one full vertex setup type. */
+ funcindex = FFB_VB_WIN_BIT | FFB_VB_RGBA_BIT;
+
+ if (ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
+ funcindex |= FFB_VB_TWOSIDE_BIT;
+
+ if (MESA_VERBOSE)
+ ffbPrintSetupFlags("ffb: full setup function", funcindex);
+
+ fmesa->setupindex = funcindex;
+ ctx->Driver.RasterSetup = setup_func[funcindex];
+}
+
+void ffbDDCheckPartialRasterSetup(GLcontext *ctx, struct gl_pipeline_stage *d)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint tmp = fmesa->setupdone;
+
+ d->type = 0;
+ fmesa->setupdone = 0;
+
+ if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0)
+ return;
+
+ if (ctx->IndirectTriangles)
+ return;
+
+ fmesa->setupdone = tmp;
+}
+
+void ffbDDPartialRasterSetup(struct vertex_buffer *VB)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(VB->ctx);
+ GLuint new = VB->pipeline->new_outputs;
+ GLuint available = VB->pipeline->outputs;
+ GLuint ind = 0;
+
+#if 1
+ ind = FFB_VB_WIN_BIT | FFB_VB_RGBA_BIT;
+ if (VB->ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
+ ind |= FFB_VB_TWOSIDE_BIT;
+#else
+ if (new & VERT_WIN) {
+ new = available;
+ ind |= FFB_VB_WIN_BIT;
+ }
+ if (new & VERT_RGBA)
+ ind |= FFB_VB_RGBA_BIT;
+#endif
+
+#if 0
+ fmesa->setupdone &= ~ind;
+ ind &= fmesa->setupindex;
+ fmesa->setupdone |= ind;
+#endif
+
+ if (MESA_VERBOSE)
+ ffbPrintSetupFlags("ffb: partial setup function", ind);
+
+ if (ind)
+ setup_func[ind](VB, VB->Start, VB->Count);
+}
+
+void ffbDDDoRasterSetup(struct vertex_buffer *VB)
+{
+ GLcontext *ctx = VB->ctx;
+
+ if (VB->Type == VB_CVA_PRECALC)
+ ffbDDPartialRasterSetup(VB);
+ else if (ctx->Driver.RasterSetup)
+ ctx->Driver.RasterSetup(VB, VB->CopyStart, VB->Count);
+}
+
+void ffbDDResizeVB(struct vertex_buffer *VB, GLuint size)
+{
+ FFBVertexBufferPtr mvb = FFB_DRIVER_DATA(VB);
+
+ while (mvb->size < size)
+ mvb->size *= 2;
+
+ free(mvb->verts);
+ mvb->verts = (ffb_vertex *)malloc(sizeof(ffb_vertex) * mvb->size);
+ if (!mvb->verts) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+
+ gl_vector1ui_free(&mvb->clipped_elements);
+ gl_vector1ui_alloc(&mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32);
+ if (!mvb->clipped_elements.start) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+
+ free(VB->ClipMask);
+ VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
+ if (!VB->ClipMask) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+
+ 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);
+ if (!mvb->primitive || !mvb->next_primitive) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+ }
+}
+
+void ffbDDRegisterVB(struct vertex_buffer *VB)
+{
+ FFBVertexBufferPtr mvb;
+
+ mvb = (FFBVertexBufferPtr) calloc(1, sizeof(*mvb));
+ if (!mvb) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+ mvb->size = VB->Size * 2;
+ mvb->verts = (ffb_vertex *) malloc(sizeof(ffb_vertex) * mvb->size);
+ if (!mvb->verts) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+
+ gl_vector1ui_alloc(&mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32);
+ if (!mvb->clipped_elements.start) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+
+ free(VB->ClipMask);
+ VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
+ if (!VB->ClipMask) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+
+ mvb->primitive = (GLuint *)malloc(sizeof(GLuint) * mvb->size);
+ mvb->next_primitive = (GLuint *)malloc(sizeof(GLuint) * mvb->size);
+ if (!mvb->primitive || !mvb->next_primitive) {
+ fprintf(stderr, "ffb-glx: out of memory !\n");
+ exit(1);
+ }
+
+ VB->driver_data = mvb;
+}
+
+void ffbDDUnregisterVB(struct vertex_buffer *VB)
+{
+ FFBVertexBufferPtr mvb = FFB_DRIVER_DATA(VB);
+
+ if (mvb) {
+ if (mvb->verts)
+ free(mvb->verts);
+ if (mvb->primitive)
+ free(mvb->primitive);
+ if (mvb->next_primitive)
+ free(mvb->next_primitive);
+ gl_vector1ui_free(&mvb->clipped_elements);
+ free(mvb);
+ VB->driver_data = 0;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h
new file mode 100644
index 000000000..29051bdb7
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h
@@ -0,0 +1,63 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h,v 1.1 2000/06/20 05:08:40 dawes Exp $ */
+
+#ifndef _FFB_VB_H
+#define _FFB_VB_H
+
+#include "vb.h"
+#include "types.h"
+
+/* Use this to disable ffb VB processing, presumable to try
+ * and isolate bugs.
+ */
+#undef FFB_VB_DISABLE
+
+/* These are all in 2:30 signed fixed point format. */
+typedef struct {
+ GLuint alpha;
+ GLuint red;
+ GLuint green;
+ GLuint blue;
+} ffb_color;
+
+#define FFB_COLOR_FROM_UBYTE(VAL) (((((GLuint)(VAL)) + 1) & (255 << 1)) << (30 - 8))
+
+typedef struct {
+ /* As for colors, this is in 2:30 signed fixed point. */
+ GLint z;
+
+ /* These are in 16:16 fixed point. */
+ GLuint y, x;
+
+ ffb_color color[2];
+} ffb_vertex;
+
+#define FFB_Z_FROM_FLOAT(VAL) ((GLint)((VAL) * 1073741824.0f))
+#define FFB_COORD_FROM_FLOAT(VAL) ((GLuint)((VAL) * 65536.0f))
+
+struct ffb_vertex_buffer_t {
+ GLvector1ui clipped_elements;
+ ffb_vertex *verts;
+ int last_virt;
+ GLuint *primitive;
+ GLuint *next_primitive;
+ GLuint size;
+};
+
+typedef struct ffb_vertex_buffer_t *FFBVertexBufferPtr;
+
+#define FFB_DRIVER_DATA(vb) ((FFBVertexBufferPtr)((vb)->driver_data))
+
+#define FFB_VB_RGBA_BIT 0x01
+#define FFB_VB_WIN_BIT 0x02
+#define FFB_VB_TWOSIDE_BIT 0x04
+
+extern void ffbDDSetupInit(void);
+extern void ffbChooseRasterSetupFunc(GLcontext *);
+extern void ffbDDCheckPartialRasterSetup(GLcontext *, struct gl_pipeline_stage *);
+extern void ffbDDPartialRasterSetup(struct vertex_buffer *);
+extern void ffbDDDoRasterSetup(struct vertex_buffer *);
+extern void ffbDDResizeVB(struct vertex_buffer *, GLuint);
+extern void ffbDDRegisterVB(struct vertex_buffer *);
+extern void ffbDDUnregisterVB(struct vertex_buffer *);
+
+#endif /* !(_FFB_VB_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
new file mode 100644
index 000000000..021da998d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
@@ -0,0 +1,547 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c,v 1.1 2000/06/20 05:08:40 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <X11/Xlibint.h>
+#include <stdio.h>
+
+#include "ffb_xmesa.h"
+#include "context.h"
+#include "vbxform.h"
+#include "matrix.h"
+#include "simple_list.h"
+#include "mmath.h"
+
+#include "xf86dri.h"
+
+#include "ffb_context.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_stencil.h"
+#include "ffb_clear.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_lines.h"
+#include "ffb_points.h"
+#include "ffb_state.h"
+#include "ffb_pipeline.h"
+#include "ffb_lock.h"
+
+#if 0
+#include "xmesaP.h"
+#endif
+
+static ffbContextPtr ffbCtx = NULL;
+
+/* These functions are accessed by dlsym from dri_mesa_init.c:
+ *
+ * XMesaInitDriver
+ * XMesaResetDriver
+ * XMesaCreateVisual
+ * XMesaDestroyVisual
+ * XMesaCreateContext
+ * XMesaDestroyContext
+ * XMesaCreateWindowBuffer
+ * XMesaCreatePixmapBuffer
+ * XMesaDestroyBuffer
+ * XMesaSwapBuffers
+ * XMesaMakeCurrent
+ *
+ * So this is kind of the public interface to the driver. The driver
+ * uses the X11 mesa driver context as a kind of wrapper around its
+ * own driver context - but there isn't much justificiation for doing
+ * it that way - the DRI might as well use a (void *) to refer to the
+ * driver contexts. Nothing in the X context really gets used.
+ */
+
+GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
+{
+ ffbScreenPrivate *ffbScreen;
+ FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
+
+ /* Allocate the private area. */
+ ffbScreen = (ffbScreenPrivate *) Xmalloc(sizeof(ffbScreenPrivate));
+ if (!ffbScreen)
+ return GL_FALSE;
+
+ /* Map FBC registers. */
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hFbcRegs,
+ gDRIPriv->sFbcRegs,
+ &gDRIPriv->mFbcRegs)) {
+ Xfree(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->regs = (ffb_fbcPtr) gDRIPriv->mFbcRegs;
+
+ /* Map ramdac registers. */
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hDacRegs,
+ gDRIPriv->sDacRegs,
+ &gDRIPriv->mDacRegs)) {
+ drmUnmap(gDRIPriv->mFbcRegs, gDRIPriv->sFbcRegs);
+ Xfree(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->dac = (ffb_dacPtr) gDRIPriv->mDacRegs;
+
+ /* Map "Smart" framebuffer views. */
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hSfb8r,
+ gDRIPriv->sSfb8r,
+ &gDRIPriv->mSfb8r)) {
+ drmUnmap(gDRIPriv->mFbcRegs, gDRIPriv->sFbcRegs);
+ drmUnmap(gDRIPriv->mDacRegs, gDRIPriv->sDacRegs);
+ Xfree(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->sfb8r = (volatile char *) gDRIPriv->mSfb8r;
+
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hSfb32,
+ gDRIPriv->sSfb32,
+ &gDRIPriv->mSfb32)) {
+ drmUnmap(gDRIPriv->mFbcRegs, gDRIPriv->sFbcRegs);
+ drmUnmap(gDRIPriv->mDacRegs, gDRIPriv->sDacRegs);
+ drmUnmap(gDRIPriv->mSfb8r, gDRIPriv->sSfb8r);
+ Xfree(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->sfb32 = (volatile char *) gDRIPriv->mSfb32;
+
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hSfb64,
+ gDRIPriv->sSfb64,
+ &gDRIPriv->mSfb64)) {
+ drmUnmap(gDRIPriv->mFbcRegs, gDRIPriv->sFbcRegs);
+ drmUnmap(gDRIPriv->mDacRegs, gDRIPriv->sDacRegs);
+ drmUnmap(gDRIPriv->mSfb8r, gDRIPriv->sSfb8r);
+ drmUnmap(gDRIPriv->mSfb32, gDRIPriv->sSfb32);
+ Xfree(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->sfb64 = (volatile char *) gDRIPriv->mSfb64;
+
+ ffbScreen->fifo_cache = 0;
+ ffbScreen->rp_active = 0;
+
+ ffbScreen->sPriv = sPriv;
+ sPriv->private = (void *) ffbScreen;
+
+ ffbDDSetupInit();
+ ffbDDTrifuncInit();
+ ffbDDLinefuncInit();
+ ffbDDPointfuncInit();
+
+ return GL_TRUE;
+}
+
+/* Accessed by dlsym from dri_mesa_init.c */
+void XMesaResetDriver(__DRIscreenPrivate *sPriv)
+{
+ ffbScreenPrivate *ffbScreen = sPriv->private;
+ FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
+
+ drmUnmap(gDRIPriv->mFbcRegs, gDRIPriv->sFbcRegs);
+ drmUnmap(gDRIPriv->mDacRegs, gDRIPriv->sDacRegs);
+ drmUnmap(gDRIPriv->mSfb8r, gDRIPriv->sSfb8r);
+ drmUnmap(gDRIPriv->mSfb32, gDRIPriv->sSfb32);
+ drmUnmap(gDRIPriv->mSfb64, gDRIPriv->sSfb64);
+
+ Xfree(ffbScreen);
+}
+
+/* Accessed by dlsym from dri_mesa_init.c */
+GLvisual *XMesaCreateVisual(Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ const XVisualInfo *visinfo,
+ const __GLXvisualConfig *config)
+{
+ /* Only RGB visuals (for now) in this FFB driver. */
+ if (!config->rgba)
+ return NULL;
+
+ /* 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),
+ _mesa_bitcount(visinfo->green_mask),
+ _mesa_bitcount(visinfo->blue_mask),
+ config->alphaSize,
+ 0, /* index bits */
+ config->depthSize,
+ config->stencilSize,
+ config->accumRedSize,
+ config->accumGreenSize,
+ config->accumBlueSize,
+ config->accumAlphaSize,
+ 0 /* num samples */);
+}
+
+/* Create and initialize the Mesa and driver specific context data */
+GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
+ __DRIcontextPrivate *driContextPriv)
+{
+ ffbContextPtr fmesa;
+ GLcontext *glCtx;
+ __DRIscreenPrivate *sPriv;
+ ffbScreenPrivate *ffbScreen;
+
+ fmesa = (ffbContextPtr) Xmalloc(sizeof(ffbContextRec));
+ if (!fmesa)
+ return GL_FALSE;
+
+ glCtx = driContextPriv->mesaContext;
+ sPriv = driContextPriv->driScreenPriv;
+ ffbScreen = (ffbScreenPrivate *) sPriv->private;
+
+ fmesa->glCtx = glCtx;
+ glCtx->DriverCtx = (void *) fmesa;
+
+ /* Dri stuff. */
+ fmesa->display = dpy;
+ fmesa->hHWContext = driContextPriv->hHWContext;
+ fmesa->driFd = sPriv->fd;
+ fmesa->driHwLock = &sPriv->pSAREA->lock;
+
+ fmesa->ffbScreen = ffbScreen;
+ fmesa->driScreen = sPriv;
+ fmesa->ffb_sarea = FFB_DRISHARE(sPriv->pSAREA);
+
+ /* Register and framebuffer hw pointers. */
+ fmesa->regs = ffbScreen->regs;
+ fmesa->sfb32 = ffbScreen->sfb32;
+
+ fmesa->SWrender = 0;
+ if (getenv("LIBGL_SOFTWARE_RENDERING"))
+ fmesa->SWrender = 1;
+
+ ffbDDInitContextHwState(glCtx);
+
+ /* Default clear and depth colors. */
+ {
+ GLubyte r = (GLint) (glCtx->Color.ClearColor[0] * 255.0F);
+ GLubyte g = (GLint) (glCtx->Color.ClearColor[1] * 255.0F);
+ GLubyte b = (GLint) (glCtx->Color.ClearColor[2] * 255.0F);
+
+ fmesa->clear_pixel = ((r << 0) |
+ (g << 8) |
+ (b << 16));
+ }
+ fmesa->clear_depth = Z_FROM_MESA(glCtx->Depth.Clear * 4294967295.0f);
+ fmesa->clear_stencil = glCtx->Stencil.Clear & 0xf;
+
+ /* All of this need only be done once for a new context. */
+ ffbDDExtensionsInit(glCtx);
+ ffbDDInitDriverFuncs(glCtx);
+ ffbDDInitStateFuncs(glCtx);
+ ffbDDInitSpanFuncs(glCtx);
+ ffbDDInitDepthFuncs(glCtx);
+ ffbDDInitStencilFuncs(glCtx);
+
+ /* Actually we do the culling in software. The problem is
+ * that there is apparently some bug in generic MESA if you
+ * provide a driver triangle rendering function when culling
+ * is enabled.
+ *
+ * Generic MESA in such a case does the culling in it's very
+ * own software triangle rasterizers (ie. when the driver indicates
+ * it cannot do it). Perhaps this is a clue.
+ */
+ glCtx->Driver.TriangleCaps = DD_TRI_CULL;
+
+ if (glCtx->VB)
+ ffbDDRegisterVB(glCtx->VB);
+
+ if (glCtx->NrPipelineStages)
+ glCtx->NrPipelineStages =
+ ffbDDRegisterPipelineStages(glCtx->PipelineStage,
+ glCtx->PipelineStage,
+ glCtx->NrPipelineStages);
+
+ driContextPriv->driverPrivate = (void *) fmesa;
+
+ return GL_TRUE;
+}
+
+void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
+
+ if (fmesa == ffbCtx)
+ ffbCtx = NULL;
+
+ if (fmesa)
+ Xfree(fmesa);
+}
+
+/* Create and initialize the Mesa and driver specific pixmap buffer data */
+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,
+ mesaVis->AlphaBits > 0);
+}
+
+/* Create and initialize the Mesa and driver specific pixmap buffer data */
+GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ GLvisual *mesaVis)
+{
+ return NULL; /* not implemented yet */
+}
+
+#define USE_FAST_SWAP
+
+void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
+{
+ unsigned int fbc, wid, wid_reg_val, dac_db_bit;
+ unsigned int shadow_dac_addr, active_dac_addr;
+ ffb_fbcPtr ffb;
+ ffb_dacPtr dac;
+
+ if (ffbCtx == NULL ||
+ ffbCtx->glCtx->Visual->DBflag == 0)
+ return;
+
+ ffb = ffbCtx->regs;
+ dac = ffbCtx->ffbScreen->dac;
+
+ fbc = ffbCtx->fbc;
+ wid = ffbCtx->wid;
+
+ /* Swap the buffer we render into and read pixels from. */
+ ffbCtx->back_buffer ^= 1;
+
+ /* If we are writing into both buffers, don't mess with
+ * the WB setting.
+ */
+ if ((fbc & FFB_FBC_WB_AB) != FFB_FBC_WB_AB) {
+ if ((fbc & FFB_FBC_WB_A) != 0)
+ fbc = (fbc & ~FFB_FBC_WB_A) | FFB_FBC_WB_B;
+ else
+ fbc = (fbc & ~FFB_FBC_WB_B) | FFB_FBC_WB_A;
+ }
+
+ /* But either way, we must flip the read buffer setting. */
+ if ((fbc & FFB_FBC_RB_A) != 0)
+ fbc = (fbc & ~FFB_FBC_RB_A) | FFB_FBC_RB_B;
+ else
+ fbc = (fbc & ~FFB_FBC_RB_B) | FFB_FBC_RB_A;
+
+ LOCK_HARDWARE(ffbCtx);
+
+ if (ffbCtx->fbc != fbc) {
+ FFBFifo(ffbCtx, 1);
+ ffb->fbc = ffbCtx->fbc = fbc;
+ ffbCtx->ffbScreen->rp_active = 1;
+ }
+
+ /* And swap the buffer displayed in the WID. */
+ if (ffbCtx->ffb_sarea->flags & FFB_DRI_PAC1) {
+ shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid);
+ active_dac_addr = FFBDAC_PAC1_APWLUT(wid);
+ dac_db_bit = FFBDAC_PAC1_WLUT_DB;
+ } else {
+ shadow_dac_addr = FFBDAC_PAC2_SPWLUT(wid);
+ active_dac_addr = FFBDAC_PAC2_APWLUT(wid);
+ dac_db_bit = FFBDAC_PAC2_WLUT_DB;
+ }
+
+ FFBWait(ffbCtx, ffb);
+
+ wid_reg_val = DACCFG_READ(dac, active_dac_addr);
+ if (ffbCtx->back_buffer == 0)
+ wid_reg_val |= dac_db_bit;
+ else
+ wid_reg_val &= ~dac_db_bit;
+#ifdef USE_FAST_SWAP
+ DACCFG_WRITE(dac, active_dac_addr, wid_reg_val);
+#else
+ DACCFG_WRITE(dac, shadow_dac_addr, wid_reg_val);
+
+ /* Schedule the window transfer. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL,
+ (FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE));
+
+ {
+ int limit = 1000000;
+ while (limit--) {
+ unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL);
+
+ if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0)
+ break;
+ }
+ }
+#endif
+
+ UNLOCK_HARDWARE(ffbCtx);
+}
+
+static void ffb_init_wid(unsigned int wid)
+{
+ ffb_dacPtr dac = ffbCtx->ffbScreen->dac;
+ unsigned int wid_reg_val, dac_db_bit, active_dac_addr;
+ unsigned int shadow_dac_addr;
+
+ if (ffbCtx->ffb_sarea->flags & FFB_DRI_PAC1) {
+ shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid);
+ active_dac_addr = FFBDAC_PAC1_APWLUT(wid);
+ dac_db_bit = FFBDAC_PAC1_WLUT_DB;
+ } else {
+ shadow_dac_addr = FFBDAC_PAC2_SPWLUT(wid);
+ active_dac_addr = FFBDAC_PAC2_APWLUT(wid);
+ dac_db_bit = FFBDAC_PAC2_WLUT_DB;
+ }
+
+ wid_reg_val = DACCFG_READ(dac, active_dac_addr);
+ wid_reg_val &= ~dac_db_bit;
+#ifdef USE_FAST_SWAP
+ DACCFG_WRITE(dac, active_dac_addr, wid_reg_val);
+#else
+ DACCFG_WRITE(dac, shadow_dac_addr, wid_reg_val);
+
+ /* Schedule the window transfer. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL,
+ (FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE));
+
+ {
+ int limit = 1000000;
+ while (limit--) {
+ unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL);
+
+ if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0)
+ break;
+ }
+ }
+#endif
+}
+
+/* Force the context `c' to be the current context and associate with it
+ buffer `b' */
+GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
+ int first_time;
+
+ if (ffbCtx != NULL &&
+ fmesa == ffbCtx &&
+ driDrawPriv == fmesa->driDrawable)
+ return GL_TRUE;
+
+ ffbCtx = fmesa;
+ fmesa->driDrawable = driDrawPriv;
+
+ gl_make_current2(ffbCtx->glCtx,
+ driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer);
+
+ if (!ffbCtx->glCtx->Viewport.Width)
+ gl_Viewport(ffbCtx->glCtx,
+ 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
+
+ first_time = 0;
+ if (ffbCtx->wid == ~0)
+ first_time = 1;
+
+ LOCK_HARDWARE(ffbCtx);
+ if (first_time) {
+ ffbCtx->wid = ffbCtx->ffb_sarea->wid_table[driDrawPriv->index];
+ ffbCtx->state_dirty |= FFB_STATE_WID;
+ ffb_init_wid(ffbCtx->wid);
+ }
+
+ ffbCtx->state_dirty |= FFB_STATE_ALL;
+ ffbCtx->state_fifo_ents = ffbCtx->state_all_fifo_ents;
+ ffbSyncHardware(ffbCtx);
+ UNLOCK_HARDWARE(ffbCtx);
+
+ if (first_time) {
+ /* Also, at the first switch to a new context,
+ * we need to clear all the hw buffers.
+ */
+ ffbDDClear(ffbCtx->glCtx,
+ (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT |
+ DD_DEPTH_BIT | DD_STENCIL_BIT),
+ 1, 0, 0, 0, 0);
+ }
+ } else {
+ gl_make_current(0,0);
+ ffbCtx = NULL;
+ }
+
+ return GL_TRUE;
+}
+
+/* Force the context `c' to be unbound from its buffer */
+GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+void ffbXMesaUpdateState(ffbContextPtr fmesa)
+{
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ __DRIscreenPrivate *sPriv = fmesa->driScreen;
+ int stamp = dPriv->lastStamp;
+
+ XMESA_VALIDATE_DRAWABLE_INFO(fmesa->display, sPriv, dPriv);
+
+ if (dPriv->lastStamp != stamp) {
+ GLcontext *ctx = fmesa->glCtx;
+
+ if (ctx->Scissor.Enabled)
+ ffbDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+ ctx->Scissor.Width, ctx->Scissor.Height);
+ if (ctx->Polygon.StippleFlag)
+ ffbXformAreaPattern(fmesa,
+ (const GLubyte *)ctx->PolygonStipple);
+ }
+}
+
+/* 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)
+{
+}
+
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h
new file mode 100644
index 000000000..4eb8ff4f0
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h
@@ -0,0 +1,33 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h,v 1.1 2000/06/20 05:08:40 dawes Exp $ */
+
+#ifndef _FFB_XMESA_H_
+#define _FFB_XMESA_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <sys/time.h>
+#include "dri_mesaint.h"
+#include "dri_mesa.h"
+#include "types.h"
+#include "ffb_drishare.h"
+#include "ffb_regs.h"
+#include "ffb_dac.h"
+#include "ffb_fifo.h"
+
+typedef struct {
+ __DRIscreenPrivate *sPriv;
+ ffb_fbcPtr regs;
+ ffb_dacPtr dac;
+ volatile char *sfb8r;
+ volatile char *sfb32;
+ volatile char *sfb64;
+
+ int fifo_cache;
+ int rp_active;
+} ffbScreenPrivate;
+
+extern void __driRegisterExtensions(void);
+
+#endif /* GLX_DIRECT_RENDERING */
+
+#endif /* !(_FFB_XMESA_H) */
diff --git a/xc/lib/GL/mesa/src/drv/sis/Imakefile b/xc/lib/GL/mesa/src/drv/sis/Imakefile
new file mode 100644
index 000000000..ddef8bf56
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/Imakefile
@@ -0,0 +1,315 @@
+XCOMM $PI:$
+
+#include <Threads.tmpl>
+
+#define DoNormalLib NormalLibGlx
+#define DoSharedLib SharedLibGlx
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+
+XCOMM SIS_DEFINES = -DSIS_USE_HW_CULL -DSIS_USE_FASTPATH
+SIS_DEFINES = -DSIS_USE_HW_CULL
+
+XCOMM DEBUG_DEFINES = -DDEBUG_LOCKING
+XCOMM DEBUG_DEFINES = -DSIS_DEBUG
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines $(SIS_DEFINES)
+ DRI_INCLUDES = -I../../../../dri -I../../../../glx \
+ -I../../../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
+#endif
+
+MESA_INCLUDES = -I. -I.. -I../../include
+
+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)
+ 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)
+
+ DRISRCS = ../../../dri/dri_mesa.c \
+ ../../../../dri/dri_tmm.c
+
+ DRIOBJS = ../../../dri/dri_mesa.o \
+ ../../../../dri/dri_tmm.o
+
+ DRMSRCS = ../../../../dri/drm/xf86drm.c \
+ ../../../../dri/drm/xf86drmHash.c \
+ ../../../../dri/drm/xf86drmRandom.c \
+ ../../../../dri/drm/xf86drmSL.c
+
+ DRMOBJS = ../../../../dri/drm/xf86drm.o \
+ ../../../../dri/drm/xf86drmHash.o \
+ ../../../../dri/drm/xf86drmRandom.o \
+ ../../../../dri/drm/xf86drmSL.o
+
+ MESASRCS = ../../aatriangle.c \
+ ../../accum.c \
+ ../../alpha.c \
+ ../../alphabuf.c \
+ ../../attrib.c \
+ ../../bbox.c \
+ ../../bitmap.c \
+ ../../blend.c \
+ ../../buffers.c \
+ ../../clip.c \
+ ../../colortab.c \
+ ../../config.c \
+ ../../context.c \
+ ../../copypix.c \
+ ../../cva.c \
+ ../../debug_xform.c \
+ ../../depth.c \
+ ../../dlist.c \
+ ../../drawpix.c \
+ ../../enable.c \
+ ../../enums.c \
+ ../../eval.c \
+ ../../extensions.c \
+ ../../feedback.c \
+ ../../fog.c \
+ ../../get.c \
+ ../../glapi.c \
+ ../../glapinoop.c \
+ ../../glthread.c \
+ ../../hash.c \
+ ../../image.c \
+ ../../imaging.c \
+ ../../light.c \
+ ../../lines.c \
+ ../../logic.c \
+ ../../masking.c \
+ ../../matrix.c \
+ ../../mem.c \
+ ../../mmath.c \
+ ../../pb.c \
+ ../../pipeline.c \
+ ../../pixel.c \
+ ../../pixeltex.c \
+ ../../points.c \
+ ../../polygon.c \
+ ../../quads.c \
+ ../../rastpos.c \
+ ../../readpix.c \
+ ../../rect.c \
+ ../../scissor.c \
+ ../../shade.c \
+ ../../span.c \
+ ../../stages.c \
+ ../../state.c \
+ ../../stencil.c \
+ ../../teximage.c \
+ ../../texobj.c \
+ ../../texstate.c \
+ ../../texture.c \
+ ../../texutil.c \
+ ../../translate.c \
+ ../../triangle.c \
+ ../../varray.c \
+ ../../vb.c \
+ ../../vbcull.c \
+ ../../vbfill.c \
+ ../../vbindirect.c \
+ ../../vbrender.c \
+ ../../vbxform.c \
+ ../../vector.c \
+ ../../vertices.c \
+ ../../winpos.c \
+ ../../xform.c \
+ ../../zoom.c \
+ ../../X86/common_x86.c
+
+ MESAOBJS = ../../aatriangle.o \
+ ../../accum.o \
+ ../../alpha.o \
+ ../../alphabuf.o \
+ ../../attrib.o \
+ ../../bbox.o \
+ ../../bitmap.o \
+ ../../blend.o \
+ ../../buffers.o \
+ ../../clip.o \
+ ../../colortab.o \
+ ../../config.o \
+ ../../context.o \
+ ../../copypix.o \
+ ../../cva.o \
+ ../../debug_xform.o \
+ ../../depth.o \
+ ../../dlist.o \
+ ../../drawpix.o \
+ ../../enable.o \
+ ../../enums.o \
+ ../../eval.o \
+ ../../extensions.o \
+ ../../feedback.o \
+ ../../fog.o \
+ ../../get.o \
+ ../../hash.o \
+ ../../hint.o \
+ ../../image.o \
+ ../../imaging.o \
+ ../../light.o \
+ ../../lines.o \
+ ../../logic.o \
+ ../../masking.o \
+ ../../matrix.o \
+ ../../mem.o \
+ ../../mmath.o \
+ ../../pb.o \
+ ../../pipeline.o \
+ ../../pixel.o \
+ ../../pixeltex.o \
+ ../../points.o \
+ ../../polygon.o \
+ ../../quads.o \
+ ../../rastpos.o \
+ ../../readpix.o \
+ ../../rect.o \
+ ../../scissor.o \
+ ../../shade.o \
+ ../../span.o \
+ ../../stages.o \
+ ../../state.o \
+ ../../stencil.o \
+ ../../teximage.o \
+ ../../texobj.o \
+ ../../texstate.o \
+ ../../texture.o \
+ ../../texutil.o \
+ ../../translate.o \
+ ../../triangle.o \
+ ../../varray.o \
+ ../../vb.o \
+ ../../vbcull.o \
+ ../../vbfill.o \
+ ../../vbindirect.o \
+ ../../vbrender.o \
+ ../../vbxform.o \
+ ../../vector.o \
+ ../../vertices.o \
+ ../../winpos.o \
+ ../../xform.o \
+ ../../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
+
+ MMX_SRCS = ../../X86/mmx_blend.S
+
+ MMX_OBJS = ../../X86/mmx_blend.o
+
+#if MesaUse3DNow
+ 3DNOW_SRCS = ../../X86/3dnow.c \
+ ../../X86/3dnow_norm_raw.S \
+ ../../X86/3dnow_xform_masked1.S \
+ ../../X86/3dnow_xform_masked2.S \
+ ../../X86/3dnow_xform_masked3.S \
+ ../../X86/3dnow_xform_masked4.S \
+ ../../X86/3dnow_xform_raw1.S \
+ ../../X86/3dnow_xform_raw2.S \
+ ../../X86/3dnow_xform_raw3.S \
+ ../../X86/3dnow_xform_raw4.S \
+ ../../X86/vertex_3dnow.S
+
+ 3DNOW_OBJS = ../../X86/3dnow.o \
+ ../../X86/3dnow_norm_raw.o \
+ ../../X86/3dnow_xform_masked1.o \
+ ../../X86/3dnow_xform_masked2.o \
+ ../../X86/3dnow_xform_masked3.o \
+ ../../X86/3dnow_xform_masked4.o \
+ ../../X86/3dnow_xform_raw1.o \
+ ../../X86/3dnow_xform_raw2.o \
+ ../../X86/3dnow_xform_raw3.o \
+ ../../X86/3dnow_xform_raw4.o \
+ ../../X86/vertex_3dnow.o
+#endif
+
+#endif
+
+ ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
+ ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+
+ SRCS = $(DRISRCS) $(DRMSRCS) $(SISSRCS) $(MESASRCS) $(ASMSRCS)
+ OBJS = $(DRIOBJS) $(DRMOBJS) $(SISOBJS) $(MESAOBJS) $(ASMOBJS)
+
+#if !GlxUseBuiltInDRIDriver || GlxDebugSIS
+#undef DoNormalLib NormalLibGlx
+#undef DoExtraLib SharedLibGlx
+#undef DoDebugLib DebugLibGlx
+#undef DoProfileLib ProfileLibGlx
+#endif
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+#if !GlxUseBuiltInDRIDriver || GlxDebugSIS
+# if GlxDebugSIS && GlxUseBuiltInDRIDriver
+LIBNAME = libsis_dri.so
+# else
+LIBNAME = sis_dri.so
+# endif
+ALL_OBJS = $(OBJS)
+ALL_DEPS = DONE
+SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallDynamicModule($(LIBNAME),$(MODULEDIR)/dri,.)
+#endif
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c b/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c
new file mode 100644
index 000000000..6af0942c2
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c
@@ -0,0 +1,447 @@
+#include <assert.h>
+
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+#if defined(XFree86Server) && !defined(XF86DRI)
+# include "xf86fbman.h"
+#else
+# include "drm.h"
+# include "sis_drm_public.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 */
+#define DRAW_BUFFER_HW_ALIGNMENT 16
+#define DRAW_BUFFER_HW_PLUS (16 + 4)
+
+#define TEXTURE_HW_ALIGNMENT 4
+#define TEXTURE_HW_PLUS (4 + 4)
+
+#ifdef ROUNDUP
+#undef ROUNDUP
+#endif
+#define ROUNDUP(nbytes, pad) (((nbytes)+(pad-1))/(pad))
+
+#ifdef ALIGNMENT
+#undef ALIGNMENT
+#endif
+#define ALIGNMENT(value, align) (ROUNDUP((value),(align))*(align))
+
+#if defined(XFree86Server) && !defined(XF86DRI)
+
+static void *
+sis_malloc (__GLSiScontext * hwcx, GLuint size, void **free)
+{
+ GLcontext *ctx = hwcx->gc;
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+ ScreenPtr pScreen = xmesa->display;
+
+ GLuint offset;
+ BoxPtr pBox;
+
+ size = ROUNDUP (size, GET_DEPTH (hwcx));
+ *free = xf86AllocateLinearOffscreenArea (pScreen, size, 1,
+ NULL, NULL, NULL);
+
+ if (!*free)
+ return NULL;
+
+ pBox = &((FBAreaPtr) (*free))->box;
+ offset = pBox->y1 * GET_PITCH (hwcx) + pBox->x1 * GET_DEPTH (hwcx);
+
+ return GET_FbBase (hwcx) + offset;
+}
+
+static void
+sis_free (__GLSiScontext * hwcx, void *free)
+{
+ xf86FreeOffscreenArea ((FBAreaPtr) free);
+}
+
+#else
+
+/* debug */
+#if 1
+
+static int _total_video_memory_used = 0;
+static int _total_video_memory_count = 0;
+
+static void *
+sis_malloc (__GLSiScontext * hwcx, GLuint size, void **free)
+{
+ GLcontext *ctx = hwcx->gc;
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+ drm_sis_mem_t fb;
+
+ _total_video_memory_used += size;
+
+ fb.context = xmesa->driContextPriv->hHWContext;
+ fb.size = size;
+ if(ioctl(hwcx->drmSubFD, SIS_IOCTL_FB_ALLOC, &fb) || !fb.physical)
+ return NULL;
+ *free = (void *)fb.free;
+
+ /* debug */
+ /* memset(fb.physical + 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(),
+ ++_total_video_memory_count);
+ }
+
+ return (void *)(fb.physical + GET_FbBase(hwcx));
+}
+
+static void
+sis_free (__GLSiScontext * hwcx, 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",
+ (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);
+}
+
+#else
+
+static void *
+sis_malloc (__GLSiScontext * hwcx, GLuint size, void **free)
+{
+ static char *vidmem_base = 0x400000;
+ char *rval = vidmem_base;
+
+ vidmem_base += size;
+ if(vidmem_base >= 31*0x100000)
+ return NULL;
+
+ *free = rval + (DWORD)hwcx->FbBase;
+
+ return rval + (DWORD)hwcx->FbBase;
+}
+
+static void
+sis_free (__GLSiScontext * hwcx, void *free)
+{
+ return;
+}
+
+#endif
+
+#endif
+
+/* debug */
+static unsigned int Total_Real_Textures_Used = 0;
+static unsigned int Total_Textures_Used = 0;
+
+void
+sis_alloc_z_stencil_buffer (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ XMesaBuffer xm_buffer = xmesa->xm_buffer;
+ sisBufferInfo *priv = (sisBufferInfo *) xm_buffer->private;
+
+ GLuint z_depth;
+ GLuint totalBytes;
+ int width2;
+
+ GLubyte *addr;
+
+ z_depth = (xm_buffer->xm_visual->gl_visual->DepthBits +
+ xm_buffer->xm_visual->gl_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)
+ {
+ sis_free_z_stencil_buffer (xm_buffer);
+ }
+
+ addr = sis_malloc (hwcx, totalBytes, &priv->zbFree);
+ if (!addr)
+ {
+ fprintf (stderr, "SIS driver : out of video memory\n");
+ sis_fatal_error ();
+ }
+
+ if (SIS_VERBOSE&VERBOSE_SIS_BUFFER)
+ {
+ fprintf(stderr, "sis_alloc_z_stencil_buffer: addr=%lu\n", (DWORD)addr);
+ }
+
+ addr = (GLubyte *) ALIGNMENT ((GLuint) addr, Z_BUFFER_HW_ALIGNMENT);
+
+ xm_buffer->gl_buffer->DepthBuffer = (void *) addr;
+
+ /* software render */
+ hwcx->swZBase = addr;
+ hwcx->swZPitch = width2;
+
+ /* set pZClearPacket */
+ memset (priv->pZClearPacket, 0, sizeof (ENGPACKET));
+
+ priv->pZClearPacket->dwSrcPitch = (z_depth == 2) ? 0x80000000 : 0xf0000000;
+ priv->pZClearPacket->dwDestBaseAddr =
+ (DWORD) addr - (DWORD) GET_FbBase (hwcx);
+ priv->pZClearPacket->wDestPitch = width2;
+ priv->pZClearPacket->stdwDestPos.wY = 0;
+ priv->pZClearPacket->stdwDestPos.wX = 0;
+
+ priv->pZClearPacket->wDestHeight = hwcx->virtualY;
+ priv->pZClearPacket->stdwDim.wWidth = (WORD) width2 / z_depth;
+ priv->pZClearPacket->stdwDim.wHeight = (WORD) xm_buffer->height;
+ priv->pZClearPacket->stdwCmd.cRop = 0xf0;
+
+ if (hwcx->blockWrite)
+ {
+ priv->pZClearPacket->stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR);
+ priv->pZClearPacket->stdwCmd.cCmd1 =
+ (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC);
+ }
+ else
+ {
+ priv->pZClearPacket->stdwCmd.cCmd0 = 0;
+ priv->pZClearPacket->stdwCmd.cCmd1 =
+ (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC);
+ }
+}
+
+void
+sis_free_z_stencil_buffer (XMesaBuffer buf)
+{
+ sisBufferInfo *priv = (sisBufferInfo *) buf->private;
+ __GLSiScontext *hwcx = (__GLSiScontext *) buf->xm_context->private;
+
+ sis_free (hwcx, priv->zbFree);
+ priv->zbFree = NULL;
+ buf->gl_buffer->DepthBuffer = NULL;
+}
+
+void
+sis_alloc_back_image (GLcontext * ctx, XMesaImage *image, void **free,
+ ENGPACKET *packet)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ XMesaBuffer xm_buffer = xmesa->xm_buffer;
+
+ GLuint depth = GET_DEPTH (hwcx);
+ GLuint size, width2;
+
+ GLbyte *addr;
+
+ if (image->data)
+ {
+ sis_free_back_image (xm_buffer, image, *free);
+ *free = NULL;
+ }
+
+ 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);
+ if (!addr)
+ {
+ fprintf (stderr, "SIS driver : out of video memory\n");
+ sis_fatal_error ();
+ }
+
+ addr = (GLbyte *) ALIGNMENT ((GLuint) addr, DRAW_BUFFER_HW_ALIGNMENT);
+
+ image->data = addr;
+
+ image->bytes_per_line = width2 * depth;
+ image->bits_per_pixel = depth * 8;
+
+ memset (packet, 0, sizeof (ENGPACKET));
+
+ packet->dwSrcPitch = (depth == 2) ? 0x80000000 : 0xf0000000;
+ packet->dwDestBaseAddr =
+ (DWORD) addr - (DWORD) GET_FbBase (hwcx);
+ packet->wDestPitch = image->bytes_per_line;
+ packet->stdwDestPos.wY = 0;
+ packet->stdwDestPos.wX = 0;
+
+ packet->wDestHeight = hwcx->virtualY;
+ packet->stdwDim.wWidth = (WORD) width2;
+ packet->stdwDim.wHeight = (WORD) xm_buffer->height;
+ packet->stdwCmd.cRop = 0xf0;
+
+ if (hwcx->blockWrite)
+ {
+ packet->stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR);
+ packet->stdwCmd.cCmd1 =
+ (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC);
+ }
+ else
+ {
+ packet->stdwCmd.cCmd0 = 0;
+ packet->stdwCmd.cCmd1 = (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC);
+ }
+}
+
+void
+sis_free_back_image (XMesaBuffer buf, XMesaImage *image, void *free)
+{
+ __GLSiScontext *hwcx = (__GLSiScontext *) buf->xm_context->private;
+
+ sis_free (hwcx, free);
+ image->data = NULL;
+}
+
+void
+sis_alloc_texture_image (GLcontext * ctx, GLtextureImage * image)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ GLuint size;
+
+ SIStextureArea *area = image->DriverData;
+ char *addr;
+
+ GLuint texel_size;
+ GLenum driver_format;
+
+ if (area)
+ sis_free_texture_image (image);
+
+ area = calloc (1, sizeof (SIStextureArea));
+ if (!area){
+ fprintf (stderr, "SIS Driver : allocating context fails\n");
+ sis_fatal_error ();
+ return;
+ }
+
+ switch (image->IntFormat)
+ {
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ texel_size = 1;
+ driver_format = GL_ALPHA8;
+ break;
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ texel_size = 1;
+ driver_format = GL_LUMINANCE8;
+ 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:
+ texel_size = 2;
+ driver_format = GL_LUMINANCE8_ALPHA8;
+ break;
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ texel_size = 1;
+ driver_format = GL_INTENSITY8;
+ break;
+ case 3:
+ case GL_RGB:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ texel_size = 4;
+ driver_format = GL_RGB8;
+ break;
+ case 4:
+ case GL_RGBA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ texel_size = 4;
+ driver_format = GL_RGBA8;
+ break;
+ default:
+ assert(0);
+ return;
+ }
+
+ 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;
+ }
+
+ area->Data = (GLbyte *) ALIGNMENT ((GLuint) 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;
+
+ /* debug */
+ area->realSize = area->Size;
+ Total_Real_Textures_Used += area->realSize;
+ Total_Textures_Used++;
+
+ image->DriverData = area;
+}
+
+void
+sis_free_texture_image (GLtextureImage * image)
+{
+ SIStextureArea *area = (SIStextureArea *) image->DriverData;
+ __GLSiScontext *hwcx = (__GLSiScontext *) area->hwcx;
+
+ /* debug */
+ Total_Real_Textures_Used -= area->realSize;
+ Total_Textures_Used--;
+
+ if (!area)
+ return;
+
+ if (area->Data)
+ sis_free (hwcx, area->pArea);
+
+ free (area);
+ image->DriverData = NULL;
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_clear.c b/xc/lib/GL/mesa/src/drv/sis/sis_clear.c
new file mode 100644
index 000000000..5d5208628
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_clear.c
@@ -0,0 +1,570 @@
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+#include "sis_lock.h"
+
+__inline__ static GLbitfield sis_3D_Clear (GLcontext * ctx, GLbitfield mask,
+ GLint x, GLint y, GLint width,
+ GLint height);
+__inline__ static void sis_clear_color_buffer (GLcontext * ctx, GLint x,
+ GLint y, GLint width,
+ GLint height);
+__inline__ static void sis_clear_z_stencil_buffer (GLcontext * ctx,
+ GLbitfield mask, GLint x,
+ GLint y, GLint width,
+ GLint height);
+
+GLbitfield
+sis_Clear (GLcontext * ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ XMesaBuffer xm_buffer = xmesa->xm_buffer;
+ GLint x1, y1, width1, height1;
+
+ if (all)
+ {
+ GLframebuffer *buffer = ctx->DrawBuffer;
+
+ x1 = 0;
+ y1 = 0;
+ width1 = buffer->Width;
+ height1 = buffer->Height;
+ }
+ else
+ {
+ x1 = x;
+ y1 = Y_FLIP(y+height-1);
+ width1 = width;
+ height1 = height;
+ }
+
+ LOCK_HARDWARE ();
+
+ /*
+ * TODO: no considering multiple-buffer and clear buffer
+ * differs from current draw buffer
+ */
+
+ if ((xm_buffer->xm_visual->gl_visual->StencilBits &&
+ ((mask | GL_DEPTH_BUFFER_BIT) ^ (mask | GL_STENCIL_BUFFER_BIT)))
+ || (*(DWORD *) (ctx->Color.ColorMask) != 0xffffffff)
+ )
+ {
+ /* only Clear either depth or stencil buffer */
+ mask = sis_3D_Clear (ctx, mask, x1, y1, width1, height1);
+ }
+
+ if (mask & ctx->Color.DrawDestMask)
+ {
+ sis_clear_color_buffer (ctx, x1, y1, width1, height1);
+ mask &= ~ctx->Color.DrawDestMask;
+ }
+ if (mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT))
+ {
+ if (xm_buffer->gl_buffer->DepthBuffer)
+ sis_clear_z_stencil_buffer (ctx, mask, x1, y1, width1, height1);
+ mask &= ~(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ }
+ if (mask & GL_ACCUM_BUFFER_BIT)
+ {
+ }
+
+ UNLOCK_HARDWARE ();
+
+ return mask;
+}
+
+void
+sis_ClearDepth (GLcontext * ctx, GLclampd d)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ set_z_stencil_pattern (hwcx, d, ctx->Stencil.Clear);
+}
+
+void
+sis_ClearStencil (GLcontext * ctx, GLint s)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ set_z_stencil_pattern (hwcx, ctx->Depth.Clear, s);
+
+}
+
+#define MAKE_CLEAR_COLOR_8888(cc) \
+ ( (((DWORD)(((GLubyte *)(cc))[3] * 255.0 + 0.5))<<24) | \
+ (((DWORD)(((GLubyte *)(cc))[0] * 255.0 + 0.5))<<16) | \
+ (((DWORD)(((GLubyte *)(cc))[1] * 255.0 + 0.5))<<8) | \
+ ((DWORD)(((GLubyte *)(cc))[2] * 255.0 + 0.5)) )
+
+__inline__ static GLbitfield
+sis_3D_Clear (GLcontext * ctx, GLbitfield mask,
+ GLint x, GLint y, GLint width, GLint height)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *current = &hwcx->current;
+
+#define RESETSTATE (GFLAG_ENABLESETTING | GFLAG_ENABLESETTING2 | \
+ GFLAG_ZSETTING | GFLAG_DESTSETTING | \
+ GFLAG_STENCILSETTING | GFLAG_CLIPPING)
+#define STEN_OP (SiS_SFAIL_REPLACE | SiS_SPASS_ZFAIL_REPLACE | \
+ SiS_SPASS_ZPASS_REPLACE)
+
+ float left, top, right, bottom, zClearVal;
+ DWORD dwColor=0;
+ DWORD bClrColor, bClrDepth, bClrStencil;
+ DWORD dwPrimitiveSet;
+ DWORD dwEnable1, dwEnable2, dwDepthMask=0, dwSten1=0, dwSten2=0;
+
+ int count;
+ BoxPtr pExtents;
+
+ bClrColor = 0;
+ bClrDepth = (mask & GL_DEPTH_BUFFER_BIT) &&
+ (xmesa->xm_visual->gl_visual->DepthBits);
+ bClrStencil = (mask & GL_STENCIL_BUFFER_BIT) &&
+ (xmesa->xm_visual->gl_visual->StencilBits);
+
+ /* update HW state */
+ /* TODO: if enclosing sis_Clear by sis_RenderStart and sis_RenderEnd is
+ * uniform, but it seems needless to do so
+ */
+ if (hwcx->GlobalFlag)
+ {
+ sis_update_render_state (hwcx, 0);
+ }
+
+ dwEnable2 = 0;
+ if (bClrColor)
+ {
+ dwColor = MAKE_CLEAR_COLOR_8888 (ctx->Color.ClearColor);
+ }
+ else
+ {
+ dwEnable2 |= 0x8000;
+ }
+
+ if (bClrDepth && bClrStencil)
+ {
+ DWORD wmask, smask;
+ GLstencil sten;
+
+ zClearVal = ctx->Depth.Clear;
+ sten = ctx->Stencil.Clear;
+ wmask = (DWORD) ctx->Stencil.WriteMask;
+ smask = 0xff;
+
+ dwEnable1 = MASK_ZWriteEnable | MASK_StencilTestEnable;
+ dwEnable2 |= MASK_ZMaskWriteEnable;
+ dwDepthMask = ((wmask << 24) | 0x00ffffff);
+ dwSten1 = S_8 | (((DWORD) sten << 8) | smask) | SiS_STENCIL_ALWAYS;
+ dwSten2 = STEN_OP;
+ }
+ else if (bClrDepth)
+ {
+ zClearVal = ctx->Depth.Clear;
+ dwEnable1 = MASK_ZWriteEnable;
+ dwEnable2 |= MASK_ZMaskWriteEnable;
+ dwDepthMask = 0xffffff;
+ }
+ else if (bClrStencil)
+ {
+ DWORD wmask, smask;
+ GLstencil sten;
+
+ sten = (GLstencil) ctx->Stencil.Clear;
+ wmask = (DWORD) ctx->Stencil.WriteMask;
+ smask = 0xff;
+
+ zClearVal = 0;
+ dwEnable1 = MASK_ZWriteEnable | MASK_StencilTestEnable;
+ dwEnable2 |= MASK_ZMaskWriteEnable;
+ dwDepthMask = (wmask << 24) & 0xff000000;
+ dwSten1 = S_8 | (((DWORD) sten << 8) | smask) | SiS_STENCIL_ALWAYS;
+ dwSten2 = STEN_OP;
+ }
+ else
+ {
+ dwEnable2 &= ~MASK_ZMaskWriteEnable;
+ dwEnable1 = 0L;
+ zClearVal = 1;
+ }
+
+ mWait3DCmdQueue (35);
+ MMIO (REG_3D_TEnable, dwEnable1);
+ MMIO (REG_3D_TEnable2, dwEnable2);
+ if (bClrDepth | bClrStencil)
+ {
+ MMIO (REG_3D_ZSet, current->hwZ);
+ MMIO (REG_3D_ZStWriteMask, dwDepthMask);
+ MMIO (REG_3D_ZAddress, current->hwOffsetZ);
+ }
+ if (bClrColor)
+ {
+ MMIO (REG_3D_DstSet, (current->hwDstSet & 0x00ffffff) | 0xc000000);
+ MMIO (REG_3D_DstAddress, current->hwOffsetDest);
+ }
+ else
+ {
+ MMIO (REG_3D_DstAlphaWriteMask, 0L);
+ }
+ if (bClrStencil)
+ {
+ MMIO (REG_3D_StencilSet, dwSten1);
+ MMIO (REG_3D_StencilSet2, dwSten2);
+ }
+
+ if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT)
+ {
+ sis_get_clip_rects (xmesa, &pExtents, &count);
+ }
+ else
+ {
+ pExtents = NULL;
+ count = 1;
+ }
+
+ while(count--)
+ {
+ left = x;
+ right = x + width - 1;
+ top = y;
+ bottom = y + height - 1;
+
+ if (pExtents)
+ {
+ GLuint origin_x, origin_y;
+ GLuint x1, y1, x2, y2;
+
+ sis_get_drawable_origin (xmesa, &origin_x, &origin_y);
+
+ x1 = pExtents->x1 - origin_x;
+ y1 = pExtents->y1 - origin_y;
+ x2 = pExtents->x2 - origin_x - 1;
+ y2 = pExtents->y2 - origin_y - 1;
+
+ left = (left > x1) ? left : x1;
+ right = (right > x2) ? x2 : right;
+ top = (top > y1) ? top : y1;
+ bottom = (bottom > y2) ? y2 : bottom;
+ if (left > right || top > bottom)
+ continue;
+ pExtents++;
+ }
+
+ MMIO (REG_3D_ClipTopBottom, ((DWORD) top << 13) | (DWORD) bottom);
+ MMIO (REG_3D_ClipLeftRight, ((DWORD) left << 13) | (DWORD) right);
+
+ /* the first triangle */
+ dwPrimitiveSet = (OP_3D_TRIANGLE_DRAW | OP_3D_FIRE_TSARGBc |
+ SHADE_FLAT_VertexC);
+ MMIO (REG_3D_PrimitiveSet, dwPrimitiveSet);
+
+ MMIO (REG_3D_TSZa, *(DWORD *) & zClearVal);
+ MMIO (REG_3D_TSXa, *(DWORD *) & right);
+ MMIO (REG_3D_TSYa, *(DWORD *) & top);
+ MMIO (REG_3D_TSARGBa, dwColor);
+
+ MMIO (REG_3D_TSZb, *(DWORD *) & zClearVal);
+ MMIO (REG_3D_TSXb, *(DWORD *) & left);
+ MMIO (REG_3D_TSYb, *(DWORD *) & top);
+ MMIO (REG_3D_TSARGBb, dwColor);
+
+ MMIO (REG_3D_TSZc, *(DWORD *) & zClearVal);
+ MMIO (REG_3D_TSXc, *(DWORD *) & left);
+ MMIO (REG_3D_TSYc, *(DWORD *) & bottom);
+ MMIO (REG_3D_TSARGBc, dwColor);
+
+ /* second triangle */
+ dwPrimitiveSet = (OP_3D_TRIANGLE_DRAW | OP_3D_FIRE_TSARGBb |
+ SHADE_FLAT_VertexB);
+ MMIO (REG_3D_PrimitiveSet, dwPrimitiveSet);
+
+ MMIO (REG_3D_TSZb, *(DWORD *) & zClearVal);
+ MMIO (REG_3D_TSXb, *(DWORD *) & right);
+ MMIO (REG_3D_TSYb, *(DWORD *) & bottom);
+ MMIO (REG_3D_TSARGBb, dwColor);
+ }
+
+ mEndPrimitive ();
+
+ hwcx->GlobalFlag |= RESETSTATE;
+
+#undef RESETSTATE
+#undef STEN_OP
+
+ /*
+ * TODO: will mesa call several times if multiple draw buffer
+ */
+ return (mask & ~(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
+}
+
+__inline__ static void
+sis_bitblt_clear_cmd (__GLSiScontext * hwcx, ENGPACKET * pkt)
+{
+ LPDWORD lpdwDest, lpdwSrc;
+ int i;
+
+ lpdwSrc = (DWORD *) pkt + 1;
+ lpdwDest = (DWORD *) (GET_IOBase (hwcx) + REG_SRC_ADDR) + 1;
+
+ mWait3DCmdQueue (10);
+
+ *lpdwDest++ = *lpdwSrc++;
+ lpdwSrc++;
+ lpdwDest++;
+ for (i = 3; i < 8; i++)
+ {
+ *lpdwDest++ = *lpdwSrc++;
+ }
+
+ MMIO (REG_CMD0, *(DWORD *) & pkt->stdwCmd);
+ MMIO (0x8240, -1);
+
+}
+
+__inline__ static void
+sis_clear_color_buffer (GLcontext * ctx,
+ GLint x, GLint y, GLint width, GLint height)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ XMesaBuffer xm_buffer = xmesa->xm_buffer;
+ sisBufferInfo *priv = (sisBufferInfo *) xm_buffer->private;
+
+ int count;
+ GLuint origin_x, origin_y;
+ GLuint depth = GET_DEPTH (hwcx);
+ BoxPtr pExtents = NULL;
+ GLint xx, yy;
+ GLint x0, y0, width0, height0;
+
+ ENGPACKET stEngPacket;
+
+ GLuint pitch;
+
+ switch (ctx->Color.DriverDrawBuffer)
+ {
+ case GL_BACK_LEFT:
+ priv->pCbClearPacket->stdwDestPos.wY = y;
+ priv->pCbClearPacket->stdwDestPos.wX = x;
+ priv->pCbClearPacket->stdwDim.wWidth = (WORD) width;
+ priv->pCbClearPacket->stdwDim.wHeight = (WORD) height;
+ priv->pCbClearPacket->dwFgRopColor = hwcx->clearColorPattern;
+
+ sis_bitblt_clear_cmd (hwcx, priv->pCbClearPacket);
+ return;
+ case GL_FRONT_LEFT:
+ x0 = x;
+ y0 = y;
+ width0 = width;
+ height0 = height;
+
+ pitch = GET_PITCH (hwcx);
+ sis_get_drawable_origin (xmesa, &origin_x, &origin_y);
+ sis_get_clip_rects (xmesa, &pExtents, &count);
+ break;
+ case GL_BACK_RIGHT:
+ case GL_FRONT_RIGHT:
+ default:
+ assert (0);
+ return;
+ }
+
+ memset (&stEngPacket, 0, sizeof (ENGPACKET));
+
+ while (count--)
+ {
+ GLint x2 = pExtents->x1 - origin_x;
+ GLint y2 = pExtents->y1 - origin_y;
+ GLint xx2 = pExtents->x2 - origin_x;
+ GLint yy2 = pExtents->y2 - origin_y;
+
+ x = (x0 > x2) ? x0 : x2;
+ y = (y0 > y2) ? y0 : y2;
+ xx = ((x0 + width0) > (xx2)) ? xx2 : x0 + width0;
+ yy = ((y0 + height0) > (yy2)) ? yy2 : y0 + height0;
+ width = xx - x;
+ height = yy - y;
+ pExtents++;
+
+ if (width <= 0 || height <= 0)
+ continue;
+
+ stEngPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xc0000000;
+ stEngPacket.stdwDestPos.wY = y + origin_y;
+ stEngPacket.stdwDestPos.wX = x + origin_x;
+ stEngPacket.dwDestBaseAddr = (DWORD) 0;
+ stEngPacket.wDestPitch = pitch;
+ /* TODO: set maximum value? */
+ stEngPacket.wDestHeight = hwcx->virtualY;
+ stEngPacket.stdwDim.wWidth = (WORD) width;
+ stEngPacket.stdwDim.wHeight = (WORD) height;
+ stEngPacket.stdwCmd.cRop = 0xf0;
+ stEngPacket.dwFgRopColor = hwcx->clearColorPattern;
+
+ /* for SGRAM Block Write Enable */
+ if (hwcx->blockWrite)
+ {
+ stEngPacket.stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR);
+ stEngPacket.stdwCmd.cCmd1 =
+ (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC);
+ }
+ else
+ {
+ stEngPacket.stdwCmd.cCmd0 = 0;
+ stEngPacket.stdwCmd.cCmd1 =
+ (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC);
+ }
+
+ sis_bitblt_clear_cmd (hwcx, &stEngPacket);
+ }
+}
+
+__inline__ static void
+sis_clear_z_stencil_buffer (GLcontext * ctx, GLbitfield mask,
+ GLint x, GLint y, GLint width, GLint height)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ GLframebuffer *buffer = ctx->DrawBuffer;
+ sisBufferInfo *priv = (sisBufferInfo *) xmesa->xm_buffer->private;
+
+ /* TODO: check write mask */
+
+ if (!buffer->DepthBuffer)
+ return;
+
+ /* TODO: consider alignment of width, height? */
+ priv->pZClearPacket->stdwDestPos.wY = y;
+ priv->pZClearPacket->stdwDestPos.wX = x;
+ priv->pZClearPacket->stdwDim.wWidth = (WORD) width;
+ priv->pZClearPacket->stdwDim.wHeight = (WORD) height;
+ priv->pZClearPacket->dwFgRopColor = hwcx->clearZStencilPattern;
+
+ sis_bitblt_clear_cmd (hwcx, priv->pZClearPacket);
+}
+
+__inline__ static void
+sis_bitblt_copy_cmd (__GLSiScontext * hwcx, ENGPACKET * pkt)
+{
+ LPDWORD lpdwDest, lpdwSrc;
+ int i;
+
+ lpdwSrc = (DWORD *) pkt;
+ lpdwDest = (DWORD *) (GET_IOBase (hwcx) + REG_SRC_ADDR);
+
+ mWait3DCmdQueue (10);
+
+ for (i = 0; i < 7; i++)
+ {
+ *lpdwDest++ = *lpdwSrc++;
+ }
+
+ MMIO (REG_CMD0, *(DWORD *) & pkt->stdwCmd);
+ MMIO (0x8240, -1);
+}
+
+__inline__ static void
+sis_swap_image (XMesaBuffer b, XMesaDrawable d, XMesaImage * image)
+{
+ XMesaContext xmesa = b->xm_context;
+ __GLSiScontext *hwcx = (__GLSiScontext *) b->xm_context->private;
+
+ GLuint depth = GET_DEPTH (hwcx);
+ ENGPACKET stEngPacket;
+ DWORD src;
+ GLuint srcPitch, dstPitch;
+
+ BoxPtr pExtents;
+ BoxRec box;
+ int count;
+ GLuint origin_x, origin_y;
+
+ memset (&stEngPacket, 0, sizeof (ENGPACKET));
+
+ if (!sis_get_clip_rects (xmesa, &pExtents, &count))
+ {
+ sis_get_drawable_box (xmesa, &box);
+ pExtents = &box;
+ count = 1;
+ }
+
+ src = (DWORD) image->data - (DWORD) GET_FbBase (hwcx);
+ srcPitch = image->bytes_per_line;
+ dstPitch = GET_PITCH (hwcx);
+ sis_get_drawable_origin (xmesa, &origin_x, &origin_y);
+
+ while(count --)
+ {
+ stEngPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xc0000000;
+
+ stEngPacket.dwSrcBaseAddr = src;
+ stEngPacket.dwSrcPitch |= srcPitch;
+
+ stEngPacket.stdwSrcPos.wY = pExtents->y1 - origin_y;
+ stEngPacket.stdwSrcPos.wX = pExtents->x1 - origin_x;
+ stEngPacket.stdwDestPos.wY = pExtents->y1;
+ stEngPacket.stdwDestPos.wX = pExtents->x1;
+ stEngPacket.dwDestBaseAddr = (DWORD) 0;
+ stEngPacket.wDestPitch = dstPitch;
+
+ /* TODO: set maximum value? */
+ stEngPacket.wDestHeight = hwcx->virtualY;
+ stEngPacket.stdwDim.wWidth = (WORD) pExtents->x2 - pExtents->x1;
+ stEngPacket.stdwDim.wHeight = (WORD) pExtents->y2 - pExtents->y1;
+ stEngPacket.stdwCmd.cRop = 0xcc;
+
+ if (hwcx->blockWrite)
+ {
+ stEngPacket.stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR);
+ stEngPacket.stdwCmd.cCmd1 =
+ (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC);
+ }
+ else
+ {
+ stEngPacket.stdwCmd.cCmd0 = 0;
+ stEngPacket.stdwCmd.cCmd1 =
+ (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC);
+ }
+
+ sis_bitblt_copy_cmd (hwcx, &stEngPacket);
+
+ pExtents++;
+ }
+}
+
+void
+sis_swap_buffers (XMesaBuffer b)
+{
+ XMesaContext xmesa = b->xm_context;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ GLcontext *ctx = hwcx->gc;
+
+ /* debug */
+ /* return; */
+
+ /* frame control */
+ /* TODO: need lock? */
+ while((*hwcx->FrameCountPtr) - *(DWORD *)(hwcx->IOBase+0x8a2c)
+ > SIS_MAX_FRAME_LENGTH)
+ {
+ DWORD temp = *(DWORD *)(hwcx->IOBase+0x8a2c);
+ }
+
+ LOCK_HARDWARE ();
+
+ *(DWORD *)(hwcx->IOBase+0x8a2c) = *hwcx->FrameCountPtr;
+ (*hwcx->FrameCountPtr)++;
+ sis_swap_image (b, b->frontbuffer, b->backimage);
+
+ UNLOCK_HARDWARE ();
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_common.h b/xc/lib/GL/mesa/src/drv/sis/sis_common.h
new file mode 100644
index 000000000..45002d14f
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_common.h
@@ -0,0 +1,190 @@
+#ifndef _sis_common_h_
+#define _sis_common_h_
+
+#include "types.h"
+#include "sis_xmesaP.h"
+
+#if defined(SIS_DUMP)
+#include "sis_debug.h"
+#endif
+
+#if SIS_STEREO
+# include "sis_stereo.h"
+#else
+# define STEREO_OFFSET(v) 0
+# define STEREO_SAMPLE(v) do{}while(0)
+#endif
+
+#ifdef XFree86Server
+# include "resource.h"
+# include "windowstr.h"
+# include "gcstruct.h"
+# include "GL/xf86glx.h"
+# include "xf86glx_util.h"
+# include "xf86_ansic.h"
+# include "xf86_libc.h"
+#else
+# ifdef GLX_DIRECT_RENDERING
+# include <stdio.h>
+# include <unistd.h>
+# include <stdlib.h>
+# include <string.h>
+# include "dri_mesaint.h"
+typedef struct _Box
+{
+ short x1, y1, x2, y2;
+}
+BoxRec;
+#define NullBox ((BoxPtr)0)
+typedef struct _Box *BoxPtr;
+# endif
+#endif
+
+typedef unsigned short WORD;
+typedef unsigned long DWORD;
+typedef unsigned int UINT;
+typedef int INT;
+typedef long LONG;
+typedef DWORD *LPDWORD;
+
+/*
+ * BitBlt Commands
+ */
+#define Index_SR_Misc_Ctrl11 0x3e
+#define CMD0_DD_ENABLE 0x06
+#define CMD0_SRC_VIDEO 0x00
+#define CMD0_SRC_CPU 0x10
+#define CMD0_PAT_FG_COLOR 0x00
+#define CMD1_DIR_X_DEC 0x00
+#define CMD1_DIR_X_INC 0x01
+#define CMD1_DIR_Y_DEC 0x00
+#define CMD1_DIR_Y_INC 0x02
+#define REG_SRC_ADDR 0x8200
+#define REG_CMD0 0x823c
+
+typedef struct
+{
+ WORD wSrcPitch;
+ WORD wDestPitch;
+}
+_PITCH;
+typedef struct
+{
+ WORD wWidth;
+ WORD wHeight;
+}
+_DIM;
+typedef struct
+{
+ WORD wY;
+ WORD wX;
+}
+_POS;
+
+typedef struct
+{
+ BYTE cCmd0;
+ BYTE cRop;
+ BYTE cCmd1;
+ BYTE cReserved;
+}
+_CMD;
+
+typedef struct
+{
+ WORD wStatus0;
+ BYTE cStatus0_BYTE3;
+ BYTE cStatus0_BYTE4;
+}
+_CMDQUESTATUS;
+
+typedef struct
+{
+ DWORD dwSrcBaseAddr;
+ DWORD dwSrcPitch;
+ _POS stdwSrcPos;
+ _POS stdwDestPos;
+ DWORD dwDestBaseAddr;
+ WORD wDestPitch;
+ WORD wDestHeight;
+ _DIM stdwDim;
+ DWORD dwFgRopColor;
+ DWORD dwBgRopColor;
+ DWORD dwSrcHiCKey;
+ DWORD dwSrcLoCKey;
+ DWORD dwMaskA;
+ DWORD dwMaskB;
+ DWORD dwClipA;
+ DWORD dwClipB;
+ _CMD stdwCmd;
+ _CMDQUESTATUS stdwCmdQueStatus;
+}
+ENGPACKET, *LPENGPACKET;
+
+/*
+ * Hardware Info
+ */
+#include "sis_reg.h"
+#include "sis_init.h"
+
+typedef struct gl_texture_object GLtextureObject;
+typedef struct gl_texture_image GLtextureImage;
+
+typedef struct sis_texure_area
+{
+ GLbyte *Data;
+ GLenum Format;
+ void *pArea;
+ GLuint Pitch;
+ GLuint Size;
+ GLuint texelSize;
+ void *hwcx;
+
+ /* Debug */
+ GLuint realSize;
+}
+SIStextureArea;
+
+/* dirtyFlag */
+#define SIS_TEX_ENV 0x1
+#define SIS_TEX_IMAGE 0x2 /* image in video memory is stale */
+#define SIS_TEX_PARAMETER 0x4
+#define SIS_TEX_ALL (SIS_TEX_IMAGE | SIS_TEX_PARAMETER)
+
+typedef struct sis_texobj_area
+{
+ DWORD dirtyFlag;
+ GLboolean valid;
+ struct sis_texobj_area *prev, *next;
+}
+sisTexobjInfo;
+
+typedef struct sis_buffer_private
+{
+ void *zbFree, *bbFree;
+
+ ENGPACKET *pZClearPacket, *pCbClearPacket;
+
+ ENGPACKET zClearPacket, cbClearPacket;
+
+#if SIS_STEREO
+ XMesaImage *pStereoImages[3];
+ ENGPACKET *pStereoPackets[3];
+ void *stereoFrees[3]; /* stereoFrees[0] is useless */
+
+ ENGPACKET stereoPackets[2];
+#endif
+}
+sisBufferInfo;
+
+/* HW capability */
+#define SIS_MAX_MIPMAP_LEVEL 11
+#define SIS_MAX_TEXTURE_SIZE 2048
+#define SIS_MAX_TEXTURES 2
+
+#define SIS_MAX_FRAME_LENGTH 3
+
+DWORD doFPtoFixedNoRound (DWORD dwInValue, int nFraction);
+
+#define Y_FLIP(Y) (xmesa->xm_buffer->bottom-(Y))
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_ctx.c b/xc/lib/GL/mesa/src/drv/sis/sis_ctx.c
new file mode 100644
index 000000000..820e7d733
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_ctx.c
@@ -0,0 +1,840 @@
+#ifdef XFree86Server
+# define PSZ 8
+# include "cfb.h"
+# undef PSZ
+# include "cfb16.h"
+# include "cfb24.h"
+# include "cfb32.h"
+# include "cfb24_32.h"
+/* for SISPtr */
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86Resources.h"
+# include "xf86Version.h"
+# include "xf86PciInfo.h"
+# include "xf86Pci.h"
+# include "xf86cmap.h"
+# include "vgaHW.h"
+# include "xf86RAC.h"
+# include "sis_regs.h"
+# include "sis.h"
+# include "dristruct.h"
+# include "dri.h"
+#else
+#include "sis_dri.h"
+#endif
+
+#include "extensions.h"
+
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+int GlobalCurrentHwcx = -1;
+int GlobalHwcxCountBase = 1;
+int GlobalCmdQueueLen = 0;
+
+void
+WaitEngIdle (__GLSiScontext * hwcx)
+{
+ BYTE *IOBase = GET_IOBase (hwcx);
+ BYTE cEngineState;
+
+ cEngineState = *((BYTE volatile *) (IOBase + 0x8243));
+ while (((cEngineState & 0x80) == 0) ||
+ ((cEngineState & 0x40) == 0) || ((cEngineState & 0x20) == 0))
+ {
+ cEngineState = *((BYTE volatile *) (IOBase + 0x8243));
+ }
+}
+
+void
+Wait2DEngIdle (__GLSiScontext * hwcx)
+{
+ BYTE *IOBase = GET_IOBase (hwcx);
+ BYTE cEngineState;
+
+ cEngineState = *((BYTE volatile *) (IOBase + 0x8243));
+ while (!(cEngineState & 0x80))
+ {
+ cEngineState = *((BYTE volatile *) (IOBase + 0x8243));
+ }
+}
+
+static void
+sis_init_opengl_state (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *current = &hwcx->current;
+ __GLSiSHardware *prev = &(hwcx->prev);
+
+ /*
+ prev->hwCapEnable = INIT_6327_CapsEnable ;
+ prev->hwCapEnable = 0x000000a0;
+ */
+ /* add Texture Perspective Enable */
+ prev->hwCapEnable = 0x000002a0;
+
+ /*
+ prev->hwCapEnable2 = INIT_6327_CapsEnable2;
+ prev->hwCapEnable2 = 0x00aa0080;
+ */
+ /* if multi-texture enabled, disable Z pre-test */
+ prev->hwCapEnable2 = 0x00000000;
+
+ /* Z test mode is LE */
+ prev->hwZ = INIT_6327_ZSet;
+
+ /* TODO : maybe call sis_DepthFunc to update is a better way */
+ ctx->Driver.DepthFunc (ctx, ctx->Depth.Func);
+
+ /* Depth mask */
+ prev->hwZMask = INIT_6327_ZMask;
+
+ /* Alpha test mode is ALWAYS, Alpha ref value is 0 */
+ prev->hwAlpha = INIT_6327_AlphaSet;
+
+ /* ROP2 is COPYPEN */
+ prev->hwDstSet = INIT_6327_DstSet;
+
+ /* color mask */
+ prev->hwDstMask = INIT_6327_DstMask;
+
+ /* LinePattern is 0, Repeat Factor is 0 */
+ prev->hwLinePattern = 0x00008000;
+
+ /* Fog mode is Linear Fog, Fog color is (0, 0, 0) */
+ prev->hwFog = INIT_6327_FogSet;
+
+ /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
+ prev->hwDstSrcBlend = INIT_6327_BlendMode;
+
+ /* Texture mapping mode is Tile */
+#if 0
+ prev->texture[0].hwTextqureSet = INIT_6327_TextureSet;
+#endif
+ /* Magnified & minified texture filter is NEAREST */
+#if 0
+ prev->texture[0].hwTextureMip = INIT_6327_TextureMip;
+#endif
+
+ /* Texture Blending seeting */
+ prev->hwTexBlendClr0 = INIT_6327_TextureColorBlend0;
+
+ prev->hwTexBlendClr1 = INIT_6327_TextureColorBlend1;
+
+ prev->hwTexBlendAlpha0 = INIT_6327_TextureAlphaBlend0;
+
+ prev->hwTexBlendAlpha1 = INIT_6327_TextureAlphaBlend1;
+
+ memcpy (current, prev, sizeof (__GLSiSHardware));
+
+ /* Init the texture transparency color high range value */
+#if 0
+ lpdwRegIO = ((LPDWORD)hwcx->lpEngIO + REG_3D_TransparencyColorHigh);
+ prev->hwTextureClrHigh = INIT_6326_TextureClrHigh;
+ *(lpdwRegIO) = INIT_6327_TextureClrHigh;
+#endif
+}
+
+static void
+sis_init_user_setting (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ /* disable all unsupported per-pixel extensions */
+ 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_subtract");
+ gl_extensions_disable (ctx, "GL_EXT_paletted_texture");
+ gl_extensions_disable (ctx, "GL_EXT_point_parameters");
+ gl_extensions_disable (ctx, "GL_EXT_texture3D");
+ gl_extensions_disable (ctx, "GL_INGR_blend_func_separate");
+ gl_extensions_disable (ctx, "GL_PGI_misc_hints");
+ gl_extensions_disable (ctx, "GL_EXT_clip_volume_hint");
+ gl_extensions_disable (ctx, "GL_EXT_texture_env_add");
+
+ /* TODO: driver doesn't handle this */
+ if (getenv ("SIS_SINGLE_TEXTURE"))
+ gl_extensions_disable (ctx, "GL_ARB_multitexture");
+
+ /* turning off the extension has more speed */
+ /* if mesa supports indirect VB rendering, remove it */
+
+ /* if disable it, quake3 will have broken triangle */
+ /* gl_extensions_disable (ctx, "GL_EXT_compiled_vertex_array"); */
+
+ /* debug */
+ if(getenv ("SIS_NO_AGP_CMDS"))
+ hwcx->AGPCmdModeEnabled = GL_FALSE;
+
+#if SIS_STEREO
+ if(getenv ("SIS_STEREO") && hwcx->irqEnabled)
+ hwcx->useStereo = GL_TRUE;
+ else
+ hwcx->useStereo = GL_FALSE;
+
+ {
+ float val;
+ char *str;
+
+ /* TODO: error check */
+ if((str=getenv("SIS_STEREO_OFFSET"))){
+ val= atof(str);
+ if(val>0 && val<1){
+ StereoInitOffset = val;
+ }
+ }
+
+ if((str=getenv("SIS_STEREO_SCALE"))){
+ val= atof(str);
+ if(val>0){
+ StereoInitScale = val;
+ }
+ }
+ }
+
+ if(getenv("SIS_STEREO_DYNAMIC_Z"))
+ StereoDynamicZ = GL_TRUE;
+#endif
+}
+
+void
+SiSCreateContext (XMesaContext xmesa)
+{
+ GLcontext *ctx = xmesa->gl_ctx;
+ __GLSiScontext *hwcx;
+
+ int i;
+
+ hwcx = (__GLSiScontext *) calloc (1, sizeof (__GLSiScontext));
+ if (!hwcx)
+ {
+ fprintf (stderr, "SIS Driver : allocating context fails\n");
+ sis_fatal_error ();
+ return;
+ }
+
+ /* set gc */
+ hwcx->gc = ctx;
+ xmesa->private = hwcx;
+
+ /* set static part in ctx->Driver */
+ sis_init_driver (ctx);
+
+ /* Set 2D data (from X-Server) */
+ /* i assume the data will not change during X-server's lifetime */
+#ifdef XFree86Server
+ {
+ ScrnInfoPtr pScrn = xf86Screens[xmesa->display->myNum];
+ SISPtr pSiS = SISPTR (pScrn);
+
+ hwcx->virtualX = pSiS->pScrn->virtualX;
+ hwcx->virtualY = pSiS->pScrn->virtualY;
+ hwcx->bytesPerPixel = (pSiS->pScrn->bitsPerPixel + 7) / 8;
+ hwcx->IOBase = pSiS->IOBase;
+ hwcx->FbBase = pSiS->FbBase;
+ hwcx->displayWidth = pSiS->pScrn->displayWidth * hwcx->bytesPerPixel;
+ hwcx->pitch = pSiS->scrnOffset;
+ hwcx->Chipset = pSiS->Chipset;
+ hwcx->drmSubFD = pSiS->drmSubFD;
+#if SIS_STEREO
+ hwcx->irqEnabled = pSiS->irqEnabled;
+#endif
+ }
+#else
+ {
+ __DRIscreenPrivate *psp = xmesa->driContextPriv->driScreenPriv;
+ SISDRIPtr priv = (SISDRIPtr) psp->pDevPriv;
+
+ hwcx->virtualX = priv->width;
+ hwcx->virtualY = priv->height;
+ hwcx->bytesPerPixel = priv->bytesPerPixel;
+ hwcx->IOBase = priv->regs.map;
+ hwcx->FbBase = psp->pFB;
+ hwcx->displayWidth = psp->fbWidth;
+ hwcx->pitch = psp->fbStride;
+ hwcx->Chipset = priv->deviceID;
+ /* TODO: make sure psp->fd is sub-driver's fd */
+ hwcx->drmSubFD = psp->fd;
+#if SIS_STEREO
+ hwcx->irqEnabled = priv->irqEnabled;
+#endif
+ }
+#endif
+
+#if defined(SIS_DUMP)
+ IOBase4Debug = GET_IOBase (hwcx);
+#endif
+
+ /* support ARGB8888 and RGB565 */
+ switch (hwcx->bytesPerPixel)
+ {
+ case 4:
+ hwcx->redMask = 0x00ff0000;
+ hwcx->greenMask = 0x0000ff00;
+ hwcx->blueMask = 0x000000ff;
+ hwcx->alphaMask = 0xff000000;
+ hwcx->colorFormat = DST_FORMAT_ARGB_8888;
+ break;
+ case 2:
+ hwcx->redMask = 0xf800;
+ hwcx->greenMask = 0x07e0;
+ hwcx->blueMask = 0x001f;
+ hwcx->alphaMask = 0;
+ hwcx->colorFormat = DST_FORMAT_RGB_565;
+ break;
+ default:
+ assert (0);
+ }
+
+ sis_sw_init_driver (ctx);
+
+ /* TODO: index mode */
+
+#if defined(XFree86Server)
+ {
+#if defined(XF86DRI)
+ ScreenPtr pScreen = xmesa->display;
+ ScrnInfoPtr pScrn = xf86Screens[xmesa->display->myNum];
+ SISPtr pSiS = SISPTR (pScrn);
+
+ if (pSiS->directRenderingEnabled)
+ {
+ SISSAREAPriv *saPriv = (SISSAREAPriv *) DRIGetSAREAPrivate (pScreen);
+
+ drmContextPtr contextPtr;
+
+ /* in DR, the action is done by DRI */
+ hwcx->pDRIContextPriv = DRICreateContextPriv (pScreen, contextPtr, 0);
+ if (!contextPtr)
+ {
+ /* TODO */
+ assert(0);
+ }
+
+ hwcx->serialNumber = (int) *contextPtr;
+ hwcx->CurrentHwcxPtr = &(saPriv->CtxOwner);
+ hwcx->CurrentQueueLenPtr = pSiS->cmdQueueLenPtr;
+ /* hwcx->FrameCountPtr = */
+
+ /* what does this do? */
+ /*
+ drmFreeReservedContextList (contextPtr);
+ */
+
+ /* TODO, set AGP command buffer */
+ hwcx->AGPCmdModeEnabled = GL_FALSE;
+ }
+ else
+#endif
+ {
+ hwcx->serialNumber = GlobalHwcxCountBase++;
+ hwcx->CurrentHwcxPtr = &GlobalCurrentHwcx;
+ hwcx->CurrentQueueLenPtr = pSiS->cmdQueueLenPtr;
+ /* hwcx->FrameCountPtr = */
+
+ /* TODO, set AGP command buffer */
+ hwcx->AGPCmdModeEnabled = GL_FALSE;
+ }
+ }
+#else
+ {
+ __DRIscreenPrivate *psp = xmesa->driContextPriv->driScreenPriv;
+ SISDRIPtr priv = (SISDRIPtr) psp->pDevPriv;
+ SISSAREAPriv *saPriv = (SISSAREAPriv *) (((char *) psp->pSAREA) +
+ sizeof (XF86DRISAREARec));
+
+ /* or use xmesa->driContextPriv->contextID
+ * use hHWContext is better, but limit ID to [0..2^31-1] (modify driver)
+ * hHWContext is CARD32
+ */
+ hwcx->serialNumber = xmesa->driContextPriv->hHWContext;
+ hwcx->CurrentHwcxPtr = &(saPriv->CtxOwner);
+ hwcx->CurrentQueueLenPtr = &(saPriv->QueueLength);
+ hwcx->FrameCountPtr = &(saPriv->FrameCount);
+
+ /* set AGP */
+ hwcx->AGPSize = priv->agp.size;
+ hwcx->AGPBase = priv->agp.map;
+ hwcx->AGPAddr = priv->agp.handle;
+
+ /* set AGP command buffer */
+ hwcx->AGPCmdModeEnabled = GL_FALSE;
+ if (hwcx->AGPSize){
+ if(priv->AGPCmdBufSize){
+ hwcx->AGPCmdBufBase = hwcx->AGPBase + priv->AGPCmdBufOffset;
+ hwcx->AGPCmdBufAddr = hwcx->AGPAddr + priv->AGPCmdBufOffset;
+ hwcx->AGPCmdBufSize = priv->AGPCmdBufSize;
+
+ hwcx->pAGPCmdBufNext = (DWORD *)&(saPriv->AGPCmdBufNext);
+ hwcx->AGPCmdModeEnabled = GL_TRUE;
+ }
+ }
+ }
+#endif
+
+ hwcx->GlobalFlag = 0L;
+
+ hwcx->swRenderFlag = 0;
+ hwcx->swForceRender = GL_FALSE;
+ hwcx->Primitive = 0;
+ hwcx->useFastPath = GL_FALSE;
+
+ /* TODO */
+ /* hwcx->blockWrite = SGRAMbw = IsBlockWrite (); */
+ hwcx->blockWrite = GL_FALSE;
+
+ /* this function will over-write AGPCmdModeEnabled */
+ /* TODO: pay attention to side-effect */
+ sis_init_user_setting (ctx);
+
+ sis_init_opengl_state (ctx);
+ sis_set_buffer_static (ctx);
+ set_color_pattern (hwcx, 0, 0, 0, 0);
+ set_z_stencil_pattern (hwcx, 1.0, 0);
+
+ /* TODO: need to clear cache? */
+ hwcx->clearTexCache = GL_TRUE;
+
+ hwcx->AGPParseSet = 0x00000040;
+ hwcx->dwPrimitiveSet = 0x00060000;
+
+ for (i = 0; i < SIS_MAX_TEXTURES; i++)
+ {
+ hwcx->TexStates[i] = 0;
+ hwcx->PrevTexFormat[i] = 0;
+ }
+
+#if SIS_STEREO
+ hwcx->isFullScreen = GL_FALSE;
+ hwcx->stereoEnabled = GL_FALSE;
+#endif
+}
+
+void
+SiSDestroyContext (XMesaContext xmesa)
+{
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+#if defined(XFree86Server) && defined(XF86DRI)
+ DRIDestroyContextPriv ((DRIContextPrivPtr)hwcx->pDRIContextPriv);
+#endif
+
+ /*
+ * TODO: if the context ID given by kernel will be recycled,
+ * then, the current ID will set to -1 if the current ID
+ * is equal to my id
+ */
+ free (hwcx);
+}
+
+void
+sis_update_render_state (__GLSiScontext * hwcx, GLuint stateType)
+{
+ __GLSiSHardware *prev = &hwcx->prev;
+
+ mWait3DCmdQueue (45);
+
+ if (hwcx->GlobalFlag & GFLAG_ENABLESETTING)
+ {
+ if (!hwcx->clearTexCache)
+ {
+ MMIO (REG_3D_TEnable, prev->hwCapEnable);
+ }
+ else
+ {
+ MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear);
+ MMIO (REG_3D_TEnable, prev->hwCapEnable);
+ hwcx->clearTexCache = GL_FALSE;
+ }
+ }
+
+ if (hwcx->GlobalFlag & GFLAG_ENABLESETTING2)
+ {
+ MMIO (REG_3D_TEnable2, prev->hwCapEnable2);
+ }
+
+ /* Z Setting */
+ if (hwcx->GlobalFlag & GFLAG_ZSETTING)
+ {
+ MMIO (REG_3D_ZSet, prev->hwZ);
+ MMIO (REG_3D_ZStWriteMask, prev->hwZMask);
+ MMIO (REG_3D_ZAddress, prev->hwOffsetZ);
+ }
+
+ /* Alpha Setting */
+ if (hwcx->GlobalFlag & GFLAG_ALPHASETTING)
+ {
+ MMIO (REG_3D_AlphaSet, prev->hwAlpha);
+ }
+
+ if (hwcx->GlobalFlag & GFLAG_DESTSETTING)
+ {
+ MMIO (REG_3D_DstSet, prev->hwDstSet);
+ MMIO (REG_3D_DstAlphaWriteMask, prev->hwDstMask);
+ MMIO (REG_3D_DstAddress, prev->hwOffsetDest);
+ }
+
+ /* Line Setting */
+#if 0
+ if (hwcx->GlobalFlag & GFLAG_LINESETTING)
+ {
+ MMIO(REG_3D_LinePattern, prev->hwLinePattern);
+ }
+#endif
+
+ /* Fog Setting */
+ if (hwcx->GlobalFlag & GFLAG_FOGSETTING)
+ {
+ MMIO (REG_3D_FogSet, prev->hwFog);
+ MMIO (REG_3D_FogInverseDistance, prev->hwFogInverse);
+ MMIO (REG_3D_FogFarDistance, prev->hwFogFar);
+ MMIO (REG_3D_FogFactorDensity, prev->hwFogDensity);
+ }
+
+ /* Stencil Setting */
+ if (hwcx->GlobalFlag & GFLAG_STENCILSETTING)
+ {
+ MMIO (REG_3D_StencilSet, prev->hwStSetting);
+ MMIO (REG_3D_StencilSet2, prev->hwStSetting2);
+ }
+
+ /* Miscellaneous Setting */
+ if (hwcx->GlobalFlag & GFLAG_DSTBLEND)
+ {
+ MMIO (REG_3D_DstBlendMode, prev->hwDstSrcBlend);
+ }
+ if (hwcx->GlobalFlag & GFLAG_CLIPPING)
+ {
+ MMIO (REG_3D_ClipTopBottom, prev->clipTopBottom);
+ MMIO (REG_3D_ClipLeftRight, prev->clipLeftRight);
+ }
+
+ hwcx->GlobalFlag &= ~GFLAG_RENDER_STATES;
+}
+
+void
+sis_update_texture_state (__GLSiScontext * hwcx)
+{
+ __GLSiSHardware *prev = &hwcx->prev;
+
+ mWait3DCmdQueue (55);
+
+ if (hwcx->clearTexCache)
+ {
+ MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear);
+ MMIO (REG_3D_TEnable, prev->hwCapEnable);
+ hwcx->clearTexCache = GL_FALSE;
+ }
+
+ /* Texture Setting */
+ if (hwcx->GlobalFlag & CFLAG_TEXTURERESET)
+ {
+ MMIO (REG_3D_TextureSet, prev->texture[0].hwTextureSet);
+ }
+ if (hwcx->GlobalFlag & GFLAG_TEXTUREMIPMAP)
+ {
+ MMIO (REG_3D_TextureMip, prev->texture[0].hwTextureMip);
+ }
+
+ /*
+ MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh);
+ MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow);
+ */
+
+ if (hwcx->GlobalFlag & GFLAG_TEXBORDERCOLOR)
+ {
+ MMIO (REG_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor);
+ }
+ if (hwcx->GlobalFlag & GFLAG_TEXTUREADDRESS)
+ {
+ MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear);
+ MMIO (REG_3D_TEnable, prev->hwCapEnable);
+
+ switch ((prev->texture[0].hwTextureSet & MASK_TextureLevel) >> 8)
+ {
+ case 11:
+ MMIO (REG_3D_TextureAddress11, prev->texture[0].texOffset11);
+ case 10:
+ MMIO (REG_3D_TextureAddress10, prev->texture[0].texOffset10);
+ MMIO (REG_3D_TexturePitch10, prev->texture[0].texPitch10);
+ case 9:
+ MMIO (REG_3D_TextureAddress9, prev->texture[0].texOffset9);
+ case 8:
+ MMIO (REG_3D_TextureAddress8, prev->texture[0].texOffset8);
+ MMIO (REG_3D_TexturePitch8, prev->texture[0].texPitch89);
+ case 7:
+ MMIO (REG_3D_TextureAddress7, prev->texture[0].texOffset7);
+ case 6:
+ MMIO (REG_3D_TextureAddress6, prev->texture[0].texOffset6);
+ MMIO (REG_3D_TexturePitch6, prev->texture[0].texPitch67);
+ case 5:
+ MMIO (REG_3D_TextureAddress5, prev->texture[0].texOffset5);
+ case 4:
+ MMIO (REG_3D_TextureAddress4, prev->texture[0].texOffset4);
+ MMIO (REG_3D_TexturePitch4, prev->texture[0].texPitch45);
+ case 3:
+ MMIO (REG_3D_TextureAddress3, prev->texture[0].texOffset3);
+ case 2:
+ MMIO (REG_3D_TextureAddress2, prev->texture[0].texOffset2);
+ MMIO (REG_3D_TexturePitch2, prev->texture[0].texPitch23);
+ case 1:
+ MMIO (REG_3D_TextureAddress1, prev->texture[0].texOffset1);
+ case 0:
+ MMIO (REG_3D_TextureAddress0, prev->texture[0].texOffset0);
+ MMIO (REG_3D_TexturePitch0, prev->texture[0].texPitch01);
+ }
+ }
+ if (hwcx->GlobalFlag & CFLAG_TEXTURERESET_1)
+ {
+ MMIO (REG_3D_Texture1Set, prev->texture[1].hwTextureSet);
+ }
+ if (hwcx->GlobalFlag & GFLAG_TEXTUREMIPMAP_1)
+ {
+ MMIO (REG_3D_Texture1Mip, prev->texture[1].hwTextureMip);
+ }
+
+ if (hwcx->GlobalFlag & GFLAG_TEXBORDERCOLOR_1)
+ {
+ MMIO (REG_3D_Texture1BorderColor,
+ prev->texture[1].hwTextureBorderColor);
+ }
+ if (hwcx->GlobalFlag & GFLAG_TEXTUREADDRESS_1)
+ {
+ switch ((prev->texture[1].hwTextureSet & MASK_TextureLevel) >> 8)
+ {
+ case 11:
+ MMIO (REG_3D_Texture1Address11, prev->texture[1].texOffset11);
+ case 10:
+ MMIO (REG_3D_Texture1Address10, prev->texture[1].texOffset10);
+ MMIO (REG_3D_Texture1Pitch10, prev->texture[1].texPitch10);
+ case 9:
+ MMIO (REG_3D_Texture1Address9, prev->texture[1].texOffset9);
+ case 8:
+ MMIO (REG_3D_Texture1Address8, prev->texture[1].texOffset8);
+ MMIO (REG_3D_Texture1Pitch8, prev->texture[1].texPitch89);
+ case 7:
+ MMIO (REG_3D_Texture1Address7, prev->texture[1].texOffset7);
+ case 6:
+ MMIO (REG_3D_Texture1Address6, prev->texture[1].texOffset6);
+ MMIO (REG_3D_Texture1Pitch6, prev->texture[1].texPitch67);
+ case 5:
+ MMIO (REG_3D_Texture1Address5, prev->texture[1].texOffset5);
+ case 4:
+ MMIO (REG_3D_Texture1Address4, prev->texture[1].texOffset4);
+ MMIO (REG_3D_Texture1Pitch4, prev->texture[1].texPitch45);
+ case 3:
+ MMIO (REG_3D_Texture1Address3, prev->texture[1].texOffset3);
+ case 2:
+ MMIO (REG_3D_Texture1Address2, prev->texture[1].texOffset2);
+ MMIO (REG_3D_Texture1Pitch2, prev->texture[1].texPitch23);
+ case 1:
+ MMIO (REG_3D_Texture1Address1, prev->texture[1].texOffset1);
+ case 0:
+ MMIO (REG_3D_Texture1Address0, prev->texture[1].texOffset0);
+ MMIO (REG_3D_Texture1Pitch0, prev->texture[1].texPitch01);
+ }
+ }
+
+ /* texture environment */
+ if (hwcx->GlobalFlag & GFLAG_TEXTUREENV)
+ {
+ MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor);
+ MMIO (REG_3D_TextureColorBlendSet0, prev->hwTexBlendClr0);
+ MMIO (REG_3D_TextureAlphaBlendSet0, prev->hwTexBlendAlpha0);
+ }
+ if (hwcx->GlobalFlag & GFLAG_TEXTUREENV_1)
+ {
+ MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor);
+ MMIO (REG_3D_TextureColorBlendSet1, prev->hwTexBlendClr1);
+ MMIO (REG_3D_TextureAlphaBlendSet1, prev->hwTexBlendAlpha1);
+ }
+
+ hwcx->GlobalFlag &= ~GFLAG_TEXTURE_STATES;
+}
+
+void
+sis_validate_all_state (__GLSiScontext * hwcx)
+{
+ __GLSiSHardware *prev = &hwcx->prev;
+
+ mEndPrimitive ();
+ mWait3DCmdQueue (40);
+
+ /* Enable Setting */
+ MMIO (REG_3D_TEnable, prev->hwCapEnable);
+ MMIO (REG_3D_TEnable2, prev->hwCapEnable2);
+
+ /* Z Setting */
+ /* if (prev->hwCapEnable & MASK_ZTestEnable) { */
+ MMIO (REG_3D_ZSet, prev->hwZ);
+ MMIO (REG_3D_ZStWriteMask, prev->hwZMask);
+ MMIO (REG_3D_ZAddress, prev->hwOffsetZ);
+ /* } */
+
+ /* Alpha Setting */
+ if (prev->hwCapEnable & MASK_AlphaTestEnable)
+ {
+ MMIO (REG_3D_AlphaSet, prev->hwAlpha);
+ }
+
+ /* Destination Setting */
+ MMIO (REG_3D_DstSet, prev->hwDstSet);
+ MMIO (REG_3D_DstAlphaWriteMask, prev->hwDstMask);
+ MMIO (REG_3D_DstAddress, prev->hwOffsetDest);
+
+ /* Line Setting */
+#if 0
+ if (prev->hwCapEnable2 & MASK_LinePatternEnable) {
+ MMIO(REG_3D_LinePattern, prev->hwLinePattern);
+ }
+#endif
+
+ /* Fog Setting */
+ if (prev->hwCapEnable & MASK_FogEnable)
+ {
+ MMIO (REG_3D_FogSet, prev->hwFog);
+ MMIO (REG_3D_FogInverseDistance, prev->hwFogInverse);
+ MMIO (REG_3D_FogFarDistance, prev->hwFogFar);
+ MMIO (REG_3D_FogFactorDensity, prev->hwFogDensity);
+ }
+
+ /* Stencil Setting */
+ if (prev->hwCapEnable & MASK_StencilTestEnable)
+ {
+ MMIO (REG_3D_StencilSet, prev->hwStSetting);
+ MMIO (REG_3D_StencilSet2, prev->hwStSetting2);
+ }
+
+ /* Miscellaneous Setting */
+ if (prev->hwCapEnable & MASK_BlendEnable)
+ {
+ MMIO (REG_3D_DstBlendMode, prev->hwDstSrcBlend);
+ }
+
+ MMIO (REG_3D_ClipTopBottom, prev->clipTopBottom);
+ MMIO (REG_3D_ClipLeftRight, prev->clipLeftRight);
+
+ /* TODO */
+ /* Texture Setting */
+ /* if (prev->hwCapEnable & MASK_TextureEnable) */
+ {
+ MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear);
+
+ MMIO (REG_3D_TEnable, prev->hwCapEnable);
+
+ MMIO (REG_3D_TextureSet, prev->texture[0].hwTextureSet);
+ MMIO (REG_3D_TextureMip, prev->texture[0].hwTextureMip);
+ /*
+ MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh);
+ MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow);
+ */
+ MMIO (REG_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor);
+
+ switch ((prev->texture[0].hwTextureSet & MASK_TextureLevel) >> 8)
+ {
+ case 11:
+ MMIO (REG_3D_TextureAddress11, prev->texture[0].texOffset11);
+ case 10:
+ MMIO (REG_3D_TextureAddress10, prev->texture[0].texOffset10);
+ MMIO (REG_3D_TexturePitch10, prev->texture[0].texPitch10);
+ case 9:
+ MMIO (REG_3D_TextureAddress9, prev->texture[0].texOffset9);
+ case 8:
+ MMIO (REG_3D_TextureAddress8, prev->texture[0].texOffset8);
+ MMIO (REG_3D_TexturePitch8, prev->texture[0].texPitch89);
+ case 7:
+ MMIO (REG_3D_TextureAddress7, prev->texture[0].texOffset7);
+ case 6:
+ MMIO (REG_3D_TextureAddress6, prev->texture[0].texOffset6);
+ MMIO (REG_3D_TexturePitch6, prev->texture[0].texPitch67);
+ case 5:
+ MMIO (REG_3D_TextureAddress5, prev->texture[0].texOffset5);
+ case 4:
+ MMIO (REG_3D_TextureAddress4, prev->texture[0].texOffset4);
+ MMIO (REG_3D_TexturePitch4, prev->texture[0].texPitch45);
+ case 3:
+ MMIO (REG_3D_TextureAddress3, prev->texture[0].texOffset3);
+ case 2:
+ MMIO (REG_3D_TextureAddress2, prev->texture[0].texOffset2);
+ MMIO (REG_3D_TexturePitch2, prev->texture[0].texPitch23);
+ case 1:
+ MMIO (REG_3D_TextureAddress1, prev->texture[0].texOffset1);
+ case 0:
+ MMIO (REG_3D_TextureAddress0, prev->texture[0].texOffset0);
+ MMIO (REG_3D_TexturePitch0, prev->texture[0].texPitch01);
+ }
+
+ /* TODO */
+ /* if (hwcx->ctx->Texture.Unit[1].ReallyEnabled) */
+ {
+ MMIO (REG_3D_Texture1Set, prev->texture[1].hwTextureSet);
+ MMIO (REG_3D_Texture1Mip, prev->texture[1].hwTextureMip);
+ /*
+ MMIO(REG_3D_Texture1TransparencyColorHigh, prev->texture[1].hwTextureClrHigh);
+ MMIO(REG_3D_Texture1TransparencyColorLow, prev->texture[1].hwTextureClrLow);
+ */
+ MMIO (REG_3D_Texture1BorderColor, prev->texture[1].hwTextureBorderColor);
+
+ switch ((prev->texture[1].hwTextureSet & MASK_TextureLevel) >> 8)
+ {
+ case 11:
+ MMIO (REG_3D_Texture1Address11, prev->texture[1].texOffset11);
+ case 10:
+ MMIO (REG_3D_Texture1Address10, prev->texture[1].texOffset10);
+ MMIO (REG_3D_Texture1Pitch10, prev->texture[1].texPitch10);
+ case 9:
+ MMIO (REG_3D_Texture1Address9, prev->texture[1].texOffset9);
+ case 8:
+ MMIO (REG_3D_Texture1Address8, prev->texture[1].texOffset8);
+ MMIO (REG_3D_Texture1Pitch8, prev->texture[1].texPitch89);
+ case 7:
+ MMIO (REG_3D_Texture1Address7, prev->texture[1].texOffset7);
+ case 6:
+ MMIO (REG_3D_Texture1Address6, prev->texture[1].texOffset6);
+ MMIO (REG_3D_Texture1Pitch6, prev->texture[1].texPitch67);
+ case 5:
+ MMIO (REG_3D_Texture1Address5, prev->texture[1].texOffset5);
+ case 4:
+ MMIO (REG_3D_Texture1Address4, prev->texture[1].texOffset4);
+ MMIO (REG_3D_Texture1Pitch4, prev->texture[1].texPitch45);
+ case 3:
+ MMIO (REG_3D_Texture1Address3, prev->texture[1].texOffset3);
+ case 2:
+ MMIO (REG_3D_Texture1Address2, prev->texture[1].texOffset2);
+ MMIO (REG_3D_Texture1Pitch2, prev->texture[1].texPitch23);
+ case 1:
+ MMIO (REG_3D_Texture1Address1, prev->texture[1].texOffset1);
+ case 0:
+ MMIO (REG_3D_Texture1Address0, prev->texture[1].texOffset0);
+ MMIO (REG_3D_Texture1Pitch0, prev->texture[1].texPitch01);
+ }
+ }
+
+ /* texture environment */
+ MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor);
+ MMIO (REG_3D_TextureColorBlendSet0, prev->hwTexBlendClr0);
+ MMIO (REG_3D_TextureColorBlendSet1, prev->hwTexBlendClr1);
+ MMIO (REG_3D_TextureAlphaBlendSet0, prev->hwTexBlendAlpha0);
+ MMIO (REG_3D_TextureAlphaBlendSet1, prev->hwTexBlendAlpha1);
+ }
+
+ hwcx->GlobalFlag = 0;
+}
+
+void
+sis_fatal_error (void)
+{
+ /* free video memory, or the framebuffer device will do it automatically */
+
+#ifdef XFree86Server
+ FatalError ("Fatal errors in libGLcore.a\n");
+#else
+ fprintf(stderr, "Fatal errors in sis_dri.so\n");
+ exit (-1);
+#endif
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_ctx.h b/xc/lib/GL/mesa/src/drv/sis/sis_ctx.h
new file mode 100644
index 000000000..d8d49abe0
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_ctx.h
@@ -0,0 +1,255 @@
+#ifndef _sis_ctx_h_
+#define _sis_ctx_h_
+
+#include "sis_common.h"
+
+/* for GLboolean */
+#include <GL/gl.h>
+
+#define PCI_CHIP_SIS300 0x0300
+#define PCI_CHIP_SIS630 0x6300
+#define PCI_CHIP_SIS540 0x5300
+
+#define SIS_STATE_TRIANGLE 1
+#define SIS_STATE_LINE 2
+#define SIS_STATE_POINT 3
+
+/* for swRenderFlag */
+#define SIS_SW_TRIANGLE 0x1
+#define SIS_SW_LINE 0x2
+#define SIS_SW_POINT 0x4
+#define SIS_SW_TEXTURE_DIM 0x8
+#define SIS_SW_TEXTURE_OBJ 0x10
+#define SIS_SW_TEXTURE_OBJ1 0x20
+#define SIS_SW_TEXTURE_ENV 0x100
+#define SIS_SW_TEXTURE_ENV1 0x200
+
+#define SIS_SW_TEXTURE (SIS_SW_TEXTURE_DIM | \
+ SIS_SW_TEXTURE_OBJ | SIS_SW_TEXTURE_OBJ1 | \
+ SIS_SW_TEXTURE_ENV | SIS_SW_TEXTURE_ENV1)
+#define SIS_SW_ALL (SIS_SW_POINT | SIS_SW_LINE | SIS_SW_TRIANGLE | \
+ SIS_SW_TEXTURE)
+
+/*
+ ** Device dependent context state
+ */
+typedef struct __GLSiSTextureRec
+{
+ DWORD hwTextureSet;
+ DWORD hwTextureMip;
+ DWORD hwTextureClrHigh;
+ DWORD hwTextureClrLow;
+ DWORD hwTextureBorderColor;
+
+ DWORD texOffset0;
+ DWORD texOffset1;
+ DWORD texOffset2;
+ DWORD texOffset3;
+ DWORD texOffset4;
+ DWORD texOffset5;
+ DWORD texOffset6;
+ DWORD texOffset7;
+ DWORD texOffset8;
+ DWORD texOffset9;
+ DWORD texOffset10;
+ DWORD texOffset11;
+
+ DWORD texPitch01;
+ DWORD texPitch23;
+ DWORD texPitch45;
+ DWORD texPitch67;
+ DWORD texPitch89;
+ DWORD texPitch10;
+}
+__GLSiSTexture;
+
+typedef struct __GLSiSHardwareRec
+{
+ DWORD hwCapEnable, hwCapEnable2; /* Enable Setting */
+
+ DWORD hwOffsetZ, hwZ; /* Z Setting */
+
+ DWORD hwZBias, hwZMask; /* Z Setting */
+
+ DWORD hwAlpha; /* Alpha Setting */
+
+ DWORD hwDstSet, hwDstMask; /* Destination Setting */
+
+ DWORD hwOffsetDest; /* Destination Setting */
+
+ DWORD hwLinePattern; /* Line Setting */
+
+ DWORD hwFog; /* Fog Setting */
+
+ DWORD hwFogFar, hwFogInverse; /* Fog Distance setting */
+
+ DWORD hwFogDensity; /* Fog factor & density */
+
+ DWORD hwStSetting, hwStSetting2; /* Stencil Setting */
+
+ DWORD hwStOffset; /* Stencil Setting */
+
+ DWORD hwDstSrcBlend; /* Blending mode Setting */
+
+ DWORD clipTopBottom; /* Clip for Top & Bottom */
+
+ DWORD clipLeftRight; /* Clip for Left & Right */
+
+ struct __GLSiSTextureRec texture[2];
+
+ DWORD hwTexEnvColor; /* Texture Blending Setting */
+
+ DWORD hwTexBlendClr0;
+ DWORD hwTexBlendClr1;
+ DWORD hwTexBlendAlpha0;
+ DWORD hwTexBlendAlpha1;
+
+}
+__GLSiSHardware;
+
+/*
+ ** Device dependent context state
+ */
+typedef struct __GLSiScontextRec
+{
+ /* This must be first in this structure */
+ GLcontext *gc;
+
+ unsigned int virtualX, virtualY;
+ unsigned int bytesPerPixel;
+ unsigned char *IOBase;
+ unsigned char *FbBase;
+ unsigned int displayWidth; /* per byte */
+ unsigned int pitch;
+
+ /* for sw-render */
+ GLubyte *swRenderBase;
+ GLuint swRenderPitch;
+ GLubyte *swZBase;
+ GLuint swZPitch;
+ GLuint pixelValue;
+ GLboolean swForceRender;
+
+ /* HW RGBA layout */
+ unsigned int redMask, greenMask, blueMask, alphaMask;
+ unsigned int colorFormat;
+
+ /* Z format */
+ unsigned int zFormat;
+
+ /* Clear patterns, 4 bytes */
+ unsigned int clearColorPattern;
+ unsigned int clearZStencilPattern;
+
+ /* render function */
+ points_func PointsFunc;
+ line_func LineFunc;
+ triangle_func TriangleFunc;
+ quad_func QuadFunc;
+ rect_func RectFunc;
+
+ /* DRM fd */
+ int drmSubFD;
+
+ /* AGP Memory */
+ unsigned int AGPSize;
+ unsigned char *AGPBase;
+ unsigned int AGPAddr;
+
+ /* AGP Command Buffer */
+ /* TODO: use Global variables */
+ unsigned char *AGPCmdBufBase;
+ DWORD AGPCmdBufAddr;
+ unsigned int AGPCmdBufSize;
+ DWORD *pAGPCmdBufNext;
+ GLboolean AGPCmdModeEnabled;
+ GLboolean UseAGPCmdMode;
+
+ /* register 0x89F4 */
+ DWORD AGPParseSet;
+
+ /* register 0x89F8 */
+ DWORD dwPrimitiveSet;
+
+ __GLSiSHardware prev, current;
+
+ DWORD chipVer;
+ int Chipset;
+
+ DWORD drawableID;
+
+ /* SGRAM block write */
+ GLboolean blockWrite;
+
+ GLuint swRenderFlag;
+ GLenum Primitive;
+
+ /* Fast Path */
+ GLboolean useFastPath;
+
+ DWORD GlobalFlag;
+
+ DWORD rawLockMask;
+ DWORD lockMask;
+
+ void (*SwapBuffers)(XMesaBuffer b);
+
+ /* stereo */
+ GLboolean isFullScreen;
+ GLboolean useStereo;
+ GLboolean stereoEnabled;
+ int stereo_drawIndex;
+ int stereo_drawSide;
+ GLboolean irqEnabled;
+
+ int serialNumber;
+
+#if defined(XFree86Server) && defined(XF86DRI)
+ void *pDRIContextPriv;
+#endif
+
+ GLboolean clearTexCache;
+
+ GLuint TexStates[SIS_MAX_TEXTURES];
+ GLuint PrevTexFormat[SIS_MAX_TEXTURES];
+
+ int *CurrentHwcxPtr;
+ int *CurrentQueueLenPtr;
+ unsigned int *FrameCountPtr;
+}
+__GLSiScontext;
+
+/* Macros to access hwcx */
+#define GET_IOBase(x) ((x)->IOBase)
+#define GET_FbBase(x) ((x)->FbBase)
+#define GET_DEPTH(x) ((x)->bytesPerPixel)
+#define GET_WIDTH(x) ((x)->displayWidth)
+#define GET_PITCH(x) ((x)->pitch)
+#define GET_FbPos(hwcx,x,y) (GET_FbBase(hwcx)+(x)*GET_DEPTH(hwcx)\
+ +(y)*GET_PITCH(hwcx))
+
+#define GET_ColorFormat(x) ((x)->colorFormat)
+
+#define GET_RMASK(x) ((x)->redMask)
+#define GET_GMASK(x) ((x)->greenMask)
+#define GET_BMASK(x) ((x)->blueMask)
+#define GET_AMASK(x) ((x)->alphaMask)
+
+/* update to hwcx->prev */
+extern void sis_update_drawable_state (GLcontext * ctx);
+
+/* update to hw */
+extern void sis_update_texture_state (__GLSiScontext * hwcx);
+extern void sis_update_render_state (__GLSiScontext * hwcx, GLuint stateType);
+extern void sis_validate_all_state (__GLSiScontext * hwcx);
+
+extern void sis_set_scissor (GLcontext * gc);
+
+/* AGP */
+void sis_StartAGP (GLcontext * ctx);
+void sis_FlushAGP (GLcontext * ctx);
+extern float *AGP_CurrentPtr;
+
+void sis_fatal_error (void);
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_debug.c b/xc/lib/GL/mesa/src/drv/sis/sis_debug.c
new file mode 100644
index 000000000..e472f38ee
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_debug.c
@@ -0,0 +1,138 @@
+/*
+ * dump HW states, set environment variable SIS_DE1BUG
+ * to enable these functions
+ */
+
+#include <fcntl.h>
+#include <assert.h>
+
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+/* for SiS 300 */
+#define MMIOLength (0x8FFF-0x8800+1)
+#define MMIO3DOffset (0x8800)
+#define FILE_NAME "300.dump"
+
+char *IOBase4Debug = 0;
+
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+
+DWORD _empty[0x10000];
+
+//#if defined(DEBUG)
+
+void
+dump_agp (void *addr, int dword_count)
+{
+ if (!getenv ("SIS_DEBUG"))
+ return;
+
+ {
+ int i;
+ FILE *file = fopen ("300agp.dump", "w");
+
+ if (file)
+ {
+ for (i = 0; i < dword_count; i++)
+ {
+ fprintf (file, "%f\n", *(float *) addr);
+ ((unsigned char *) addr) += 4;
+ }
+ fclose (file);
+ }
+ }
+}
+
+void
+d2f_once (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ static int serialNumber = -1;
+
+ if (serialNumber == hwcx->serialNumber)
+ return;
+ else
+ serialNumber = hwcx->serialNumber;
+
+ d2f();
+}
+
+void
+d2f (void)
+{
+ if (!getenv ("SIS_DEBUG"))
+ return;
+
+ /* dump 0x8800 - 0x8AFF */
+ {
+ int fh;
+ int rval;
+ void *addr = IOBase4Debug + MMIO3DOffset;
+
+ assert (IOBase4Debug);
+
+ if ((fh = open (FILE_NAME, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) != -1)
+ {
+ rval = write (fh, addr, MMIOLength);
+ assert (rval != -1);
+ close (fh);
+ }
+ }
+}
+
+/* dump to HW */
+void
+d2h (char *file_name)
+{
+ int fh;
+ int rval;
+ void *addr[MMIOLength];
+
+ if (!getenv ("SIS_DEBUG"))
+ return;
+
+ if ((fh = open (file_name, O_CREAT, S_IREAD | S_IWRITE)) != -1)
+ {
+ rval = read (fh, addr, MMIOLength);
+ assert (rval != -1);
+ close (fh);
+ }
+ memcpy (IOBase4Debug + MMIO3DOffset, addr, MMIOLength);
+
+}
+
+/* dump video memory to file */
+void
+dvidmem (unsigned char *addr, int size)
+{
+ int fh;
+ int rval;
+ static char *file_name = "vidmem.dump";
+
+ if (!getenv ("SIS_DEBUG"))
+ return;
+
+ if ((fh = open (file_name, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) != -1)
+ {
+ rval = write (fh, addr, size);
+ assert (rval != -1);
+ 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
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_debug.h b/xc/lib/GL/mesa/src/drv/sis/sis_debug.h
new file mode 100644
index 000000000..ea4c16204
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_debug.h
@@ -0,0 +1,11 @@
+#ifndef _sis_debug_h_
+#define _sis_debug_h_
+
+void dump_agp (void *addr, int dword_count);
+void d2f (void);
+void d2f_once (GLcontext * ctx);
+void d2h (char *file_name);
+void dvidmem (unsigned char *addr, int size);
+extern char *IOBase4Debug;
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c b/xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c
new file mode 100644
index 000000000..725c9e10a
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c
@@ -0,0 +1,193 @@
+/*
+ * FOR
+ * 1. triangle/strip with 2-texture with no other capability
+ * (depth-offset, edge-flag...)
+ * 2. smooth shading
+ * 3. render to backbuffer
+ * 4. use AGP command mode
+ */
+
+#ifdef PC_HEADER
+#include "all.h"
+#else
+#include "glheader.h"
+#include "clip.h"
+#include "context.h"
+#include "light.h"
+#include "lines.h"
+#include "macros.h"
+#include "matrix.h"
+#include "pb.h"
+#include "points.h"
+#include "pipeline.h"
+#include "stages.h"
+#include "types.h"
+#include "vb.h"
+#include "vbcull.h"
+#include "vbrender.h"
+#include "vbindirect.h"
+#include "xform.h"
+#endif
+
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+#define WRITE_SMOOTH_W_T2(v) \
+do{ \
+ DWORD dcSARGB; \
+ \
+ AGP_CurrentPtr[0] = VB->Win.data[v][0] - 0.5; \
+ AGP_CurrentPtr[1] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \
+ AGP_CurrentPtr[2] = VB->Win.data[v][2] / 65535.0; \
+ AGP_CurrentPtr[3] = VB->Win.data[v][3]; \
+ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[v]); \
+ ((DWORD *)AGP_CurrentPtr)[4] = dcSARGB; \
+ AGP_CurrentPtr[5] = VB->TexCoordPtr[0]->data[v][0]; \
+ AGP_CurrentPtr[6] = VB->TexCoordPtr[0]->data[v][1]; \
+ AGP_CurrentPtr[7] = VB->TexCoordPtr[1]->data[v][0]; \
+ AGP_CurrentPtr[8] = VB->TexCoordPtr[1]->data[v][1]; \
+ AGP_CurrentPtr+=9; \
+}while(0)
+
+ /* TODO or use for loop and let compiler unroll it */
+#define COPY_SMOOTH_W_T2(i) \
+do{ \
+ AGP_CurrentPtr[0] = (AGP_CurrentPtr+(i)*9)[0]; \
+ AGP_CurrentPtr[1] = (AGP_CurrentPtr+(i)*9)[1]; \
+ AGP_CurrentPtr[2] = (AGP_CurrentPtr+(i)*9)[2]; \
+ AGP_CurrentPtr[3] = (AGP_CurrentPtr+(i)*9)[3]; \
+ AGP_CurrentPtr[4] = (AGP_CurrentPtr+(i)*9)[4]; \
+ AGP_CurrentPtr[5] = (AGP_CurrentPtr+(i)*9)[5]; \
+ AGP_CurrentPtr[6] = (AGP_CurrentPtr+(i)*9)[6]; \
+ AGP_CurrentPtr[7] = (AGP_CurrentPtr+(i)*9)[7]; \
+ AGP_CurrentPtr[8] = (AGP_CurrentPtr+(i)*9)[8]; \
+ AGP_CurrentPtr+=9; \
+}while(0)
+
+#if defined(SIS_USE_FASTPATH)
+static void sis_render_vb( struct vertex_buffer *VB )
+{
+ GLcontext *ctx = VB->ctx;
+ GLuint i, next, prim;
+ GLuint parity = VB->Parity;
+ render_func *tab;
+ GLuint count = VB->Count;
+
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ if(!hwcx->useFastPath){
+ gl_render_vb(VB);
+ return;
+ }
+
+ if (VB->Indirect) {
+ return;
+#ifndef SIS_USE_HW_CULL
+ } else if (VB->CullMode & CULL_MASK_ACTIVE) {
+ tab = ctx->Driver.RenderVBCulledTab;
+
+ /* TODO: check */
+ if (!VB->CullDone)
+ gl_fast_copy_vb( VB );
+#endif
+ } else if (VB->CullMode & CLIP_MASK_ACTIVE) {
+ tab = ctx->Driver.RenderVBClippedTab;
+ } else {
+ tab = ctx->Driver.RenderVBRawTab;
+ }
+
+ /* TODO: know what does it do */
+ gl_import_client_data( VB, ctx->RenderFlags,
+ (VB->ClipOrMask
+ ? VEC_WRITABLE|VEC_GOOD_STRIDE
+ : VEC_GOOD_STRIDE));
+
+ ctx->Driver.RenderStart( ctx );
+
+ if(tab != ctx->Driver.RenderVBRawTab){
+ for ( i= VB->CopyStart ; i < count ; parity = 0, i = next )
+ {
+ prim = VB->Primitive[i];
+ next = VB->NextPrimitive[i];
+
+ tab[prim]( VB, i, next, parity );
+ }
+ }
+ else{
+ for ( i= VB->CopyStart ; i < count ; parity = 0, i = next )
+ {
+ prim = VB->Primitive[i];
+ next = VB->NextPrimitive[i];
+
+ if(prim == GL_TRIANGLE_STRIP)
+ {
+ int j;
+
+ /* assume size >= 3 */
+ /* assert(next-i+1 >= 3); */
+
+ if(i+2 >=next)
+ break;
+
+ if(parity){
+ WRITE_SMOOTH_W_T2(i+1);
+ WRITE_SMOOTH_W_T2(i);
+ WRITE_SMOOTH_W_T2(i+2);
+ }
+ else{
+ WRITE_SMOOTH_W_T2(i);
+ WRITE_SMOOTH_W_T2(i+1);
+ WRITE_SMOOTH_W_T2(i+2);
+ }
+
+ for(j=i+3; j<next; j++){
+ if(parity){
+ COPY_SMOOTH_W_T2(-3);
+ COPY_SMOOTH_W_T2(-2);
+ WRITE_SMOOTH_W_T2(j);
+ }
+ else{
+ COPY_SMOOTH_W_T2(-1);
+ COPY_SMOOTH_W_T2(-3);
+ WRITE_SMOOTH_W_T2(j);
+ }
+ parity ^= 1;
+ }
+ }
+ else
+ {
+ tab[prim]( VB, i, next, parity );
+ }
+ }
+ }
+
+ ctx->Driver.RenderFinish( ctx );
+}
+#endif
+
+GLuint sis_RegisterPipelineStages (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_RENDER:
+ out[o] = in[i];
+#if defined(SIS_USE_FASTPATH)
+ if (in[i].run == gl_render_vb) {
+ out[o].run = sis_render_vb;
+ }
+#endif
+ o++;
+ break;
+ default:
+ out[o++] = in[i];
+ break;
+ }
+ }
+
+ return o;
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_fog.c b/xc/lib/GL/mesa/src/drv/sis/sis_fog.c
new file mode 100644
index 000000000..61bab48d8
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_fog.c
@@ -0,0 +1,141 @@
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+static DWORD convertFtToFogFt (DWORD dwInValue);
+
+void
+sis_Fogfv (GLcontext * ctx, GLenum pname, const GLfloat * params)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ __GLSiSHardware *current = &hwcx->current;
+
+ GLubyte dwFogColor[4];
+ DWORD dwArg;
+ float fArg;
+
+ switch (pname)
+ {
+ case GL_FOG_MODE:
+ current->hwFog &= ~(FOGMODE_LINEAR | FOGMODE_EXP | FOGMODE_EXP2);
+ switch (ctx->Fog.Mode)
+ {
+ case GL_LINEAR:
+ current->hwFog |= FOGMODE_LINEAR;
+ break;
+ case GL_EXP:
+ current->hwFog |= FOGMODE_EXP;
+ break;
+ case GL_EXP2:
+ current->hwFog |= FOGMODE_EXP2;
+ break;
+ }
+ break;
+ case GL_FOG_DENSITY:
+ dwArg = *(DWORD *) (&(ctx->Fog.Density));
+ current->hwFogDensity = 0;
+ current->hwFogDensity |= convertFtToFogFt (dwArg);
+ break;
+ case GL_FOG_START:
+ case GL_FOG_END:
+ fArg = 1.0 / (ctx->Fog.End - ctx->Fog.Start);
+ current->hwFogInverse = doFPtoFixedNoRound (*(DWORD *) (&fArg), 10);
+ if (pname == GL_FOG_END)
+ {
+ dwArg = *(DWORD *) (&(ctx->Fog.End));
+ if (hwcx->Chipset == PCI_CHIP_SIS300)
+ {
+ current->hwFogFar = doFPtoFixedNoRound (dwArg, 10);
+ }
+ else
+ {
+ current->hwFogFar = doFPtoFixedNoRound (dwArg, 6);
+ }
+ }
+ break;
+ case GL_FOG_INDEX:
+ /* TODO */
+ break;
+ case GL_FOG_COLOR:
+ *((DWORD *) dwFogColor) = 0;
+ dwFogColor[2] = (GLubyte)((ctx->Fog.Color[0]) * 255.0);
+ dwFogColor[1] = (GLubyte)((ctx->Fog.Color[1]) * 255.0);
+ dwFogColor[0] = (GLubyte)((ctx->Fog.Color[2]) * 255.0);
+ current->hwFog &= 0xff000000;
+ current->hwFog |= *((DWORD *) dwFogColor);
+ break;
+ }
+}
+
+DWORD
+doFPtoFixedNoRound (DWORD dwInValue, int nFraction)
+{
+ DWORD dwMantissa;
+ int nTemp;
+
+ if (dwInValue == 0)
+ return 0;
+ nTemp = (int) (dwInValue & 0x7F800000) >> 23;
+ nTemp = nTemp - 127 + nFraction - 23;
+ dwMantissa = (dwInValue & 0x007FFFFF) | 0x00800000;
+
+ if (nTemp < -25)
+ return 0;
+ if (nTemp > 0)
+ {
+ dwMantissa <<= nTemp;
+ }
+ else
+ {
+ nTemp = -nTemp;
+ dwMantissa >>= nTemp;
+ }
+ if (dwInValue & 0x80000000)
+ {
+ dwMantissa = ~dwMantissa + 1;
+ }
+ return (dwMantissa);
+}
+
+/* s[8].23->s[7].10 */
+static DWORD
+convertFtToFogFt (DWORD dwInValue)
+{
+ DWORD dwMantissa, dwExp;
+ DWORD dwRet;
+
+ if (dwInValue == 0)
+ return 0;
+
+ /* ----- Standard float Format: s[8].23 -----
+ * ----- = (-1)^S * 2^(E - 127) * (1 + M / 2^23) -----
+ * ----- = (-1)^S * 2^((E-63) - 64) * (1 + (M/2^13) / 2^10) -----
+ * ----- Density float Format: s[7].10 -----
+ * ----- New Exponential = E - 63 -----
+ * ----- New Mantissa = M / 2^13 -----
+ * ----- -----
+ */
+
+ dwExp = (dwInValue & 0x7F800000) >> 23;
+ dwExp -= 63;
+
+ if ((LONG) dwExp < 0)
+ return 0;
+
+ if (dwExp <= 0x7F)
+ {
+ dwMantissa = (dwInValue & 0x007FFFFF) >> (23 - 10);
+ }
+ else
+ {
+ /* ----- To Return +Max(or -Max) ----- */
+ dwExp = 0x7F;
+ dwMantissa = 0x3FF;
+ }
+
+ dwRet = (dwInValue & 0x80000000) >> (31 - 17); /* Shift Sign Bit */
+
+ dwRet |= (dwExp << 10) | dwMantissa;
+
+ return (dwRet);
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_init.h b/xc/lib/GL/mesa/src/drv/sis/sis_init.h
new file mode 100644
index 000000000..12fd6164a
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_init.h
@@ -0,0 +1,260 @@
+#ifndef _sis_init_h_
+#define _sis_init_h_
+
+typedef LONG fixed;
+
+typedef struct _FIXEDCOLOR
+{
+ fixed r, g, b, a;
+}
+FIXEDCOLOR;
+
+#define COMMANDMODE_MMIO 1
+#define COMMANDMODE_WC 2
+#define COMMANDMODE_AGP 0
+#define _HAS_AGPBUF 1
+
+#define floatConvertToFixedRGB(fixedColor, floatColor)\
+{\
+ fixedColor.r = (fixed) (floatColor.r * gc->constants.oneOverRedScale * ((float) 0xffffff));\
+ fixedColor.g = (fixed) (floatColor.g * gc->constants.oneOverGreenScale * ((float) 0xffffff));\
+ fixedColor.b = (fixed) (floatColor.b * gc->constants.oneOverBlueScale * ((float) 0xffffff));\
+ fixedColor.a = (fixed) (floatColor.a * gc->constants.oneOverAlphaScale * ((float) 0xffffff));\
+}
+
+/* Optimize */
+#define RGBA8ConvertToBGRA8(fixedColor, color)\
+{\
+ ((GLubyte *)fixedColor)[0] = ((GLubyte *)color)[2] ; \
+ ((GLubyte *)fixedColor)[1] = ((GLubyte *)color)[1] ; \
+ ((GLubyte *)fixedColor)[2] = ((GLubyte *)color)[0] ; \
+ ((GLubyte *)fixedColor)[3] = ((GLubyte *)color)[3] ; \
+}
+
+/* Put ARGB into DWORD */
+#define setTSARGB(dcSARGB, fixedColor)\
+{\
+ dcSARGB = ((fixedColor.a & 0x00ff0000) << 8 | \
+ (fixedColor.r & 0x00ff0000) | \
+ (fixedColor.g & 0x00ff0000) >> 8 | \
+ (fixedColor.b & 0x00ff0000) >> 16 ); \
+}
+
+#define setTSFS(dwFactor, fFactor) \
+{\
+ (dwFactor) = ((fixed)((fFactor) * 0xff)) << 24;\
+}
+
+#define MMIO(reg, value) \
+{\
+ *(LPDWORD)(GET_IOBase(hwcx) + (reg)) = value; \
+}
+
+#define mEndPrimitive() \
+{ \
+ *(GET_IOBase(hwcx) + REG_3D_EndPrimitiveList) = 0xFF; \
+ *(DWORD *)(GET_IOBase(hwcx) + 0x8b60) = (DWORD)(-1); \
+}
+
+#define INIT_6327_CapsEnable 0x00000080
+#define INIT_6327_CapsEnable2 0x00000000
+
+#define INIT_6327_ZSet 0x00030000
+#define INIT_6327_ZMask 0xffffffff
+#define INIT_6327_AlphaSet 0x07000000
+#define INIT_6327_DstSet 0x0C000000
+#define INIT_6327_DstMask 0xffffffff
+#define INIT_6327_FogSet 0x04000000
+#define INIT_6327_BlendMode 0x00000001
+#define INIT_6327_TextureSet 0x00030000
+#define INIT_6327_TextureMip 0x00000000
+/* #define INIT_6327_Texture0BlendSet 0x33031941 */
+#define INIT_6327_TextureColorBlend0 0xC1485000
+#define INIT_6327_TextureAlphaBlend0 0x333A0000
+#define INIT_6327_Texture1Set 0x00030000
+#define INIT_6327_Texture1Set2 0x00000000
+/* #define INIT_6327_Texture1BlendSet 0x00000000 */
+#define INIT_6327_TextureColorBlend1 0x294B4000
+#define INIT_6327_TextureAlphaBlend1 0x333A0000
+/* #define INIT_6327_TexAddrType 0x00001000 */
+/* #define INIT_6326_InputColorFormat 0xA0000000 */
+#define INIT_6327_ParsingSet 0x00000060
+
+#define SiS_Z_COMP_NEVER 0x00000000
+#define SiS_Z_COMP_S_LT_B 0x00010000
+#define SiS_Z_COMP_S_EQ_B 0x00020000
+#define SiS_Z_COMP_S_LE_B 0x00030000
+#define SiS_Z_COMP_S_GT_B 0x00040000
+#define SiS_Z_COMP_S_NE_B 0x00050000
+#define SiS_Z_COMP_S_GE_B 0x00060000
+#define SiS_Z_COMP_ALWAYS 0x00070000
+
+#define SiS_ALPHA_NEVER 0x00000000
+#define SiS_ALPHA_LESS 0x01000000
+#define SiS_ALPHA_EQUAL 0x02000000
+#define SiS_ALPHA_LEQUAL 0x03000000
+#define SiS_ALPHA_GREATER 0x04000000
+#define SiS_ALPHA_NOTEQUAL 0x05000000
+#define SiS_ALPHA_GEQUAL 0x06000000
+#define SiS_ALPHA_ALWAYS 0x07000000
+
+#define SiS_STENCIL_NEVER 0x00000000
+#define SiS_STENCIL_LESS 0x01000000
+#define SiS_STENCIL_EQUAL 0x02000000
+#define SiS_STENCIL_LEQUAL 0x03000000
+#define SiS_STENCIL_GREATER 0x04000000
+#define SiS_STENCIL_NOTEQUAL 0x05000000
+#define SiS_STENCIL_GEQUAL 0x06000000
+#define SiS_STENCIL_ALWAYS 0x07000000
+
+#define SiS_SFAIL_KEEP 0x00000000
+#define SiS_SFAIL_ZERO 0x00100000
+#define SiS_SFAIL_REPLACE 0x00200000
+#define SiS_SFAIL_INVERT 0x00500000
+#define SiS_SFAIL_INCR 0x00600000
+#define SiS_SFAIL_DECR 0x00700000
+
+#define SiS_SPASS_ZFAIL_KEEP 0x00000000
+#define SiS_SPASS_ZFAIL_ZERO 0x00010000
+#define SiS_SPASS_ZFAIL_REPLACE 0x00020000
+#define SiS_SPASS_ZFAIL_INVERT 0x00050000
+#define SiS_SPASS_ZFAIL_INCR 0x00060000
+#define SiS_SPASS_ZFAIL_DECR 0x00070000
+
+#define SiS_SPASS_ZPASS_KEEP 0x00000000
+#define SiS_SPASS_ZPASS_ZERO 0x00001000
+#define SiS_SPASS_ZPASS_REPLACE 0x00002000
+#define SiS_SPASS_ZPASS_INVERT 0x00005000
+#define SiS_SPASS_ZPASS_INCR 0x00006000
+#define SiS_SPASS_ZPASS_DECR 0x00007000
+
+#define SiS_D_ZERO 0x00000000
+#define SiS_D_ONE 0x00000010
+#define SiS_D_SRC_COLOR 0x00000020
+#define SiS_D_ONE_MINUS_SRC_COLOR 0x00000030
+#define SiS_D_SRC_ALPHA 0x00000040
+#define SiS_D_ONE_MINUS_SRC_ALPHA 0x00000050
+#define SiS_D_DST_ALPHA 0x00000060
+#define SiS_D_ONE_MINUS_DST_ALPHA 0x00000070
+
+#define SiS_S_ZERO 0x00000000
+#define SiS_S_ONE 0x00000001
+#define SiS_S_SRC_ALPHA 0x00000004
+#define SiS_S_ONE_MINUS_SRC_ALPHA 0x00000005
+#define SiS_S_DST_ALPHA 0x00000006
+#define SiS_S_ONE_MINUS_DST_ALPHA 0x00000007
+#define SiS_S_DST_COLOR 0x00000008
+#define SiS_S_ONE_MINUS_DST_COLOR 0x00000009
+#define SiS_S_SRC_ALPHA_SATURATE 0x0000000a
+
+/* Logic Op */
+#define LOP_CLEAR 0x00000000
+#define LOP_NOR 0x01000000
+#define LOP_AND_INVERTED 0x02000000
+#define LOP_COPY_INVERTED 0x03000000
+#define LOP_AND_REVERSE 0x04000000
+#define LOP_INVERT 0x05000000
+#define LOP_XOR 0x06000000
+#define LOP_NAND 0x07000000
+#define LOP_AND 0x08000000
+#define LOP_EQUIV 0x09000000
+#define LOP_NOOP 0x0a000000
+#define LOP_OR_INVERTED 0x0b000000
+#define LOP_COPY 0x0c000000
+#define LOP_OR_REVERSE 0x0d000000
+#define LOP_OR 0x0e000000
+#define LOP_SET 0x0f000000
+
+/* Get lock before calling this */
+#define mWait3DCmdQueue(wLen)\
+do{\
+ while ( *(hwcx->CurrentQueueLenPtr) < (int)(wLen))\
+ {\
+ *(hwcx->CurrentQueueLenPtr) = \
+ (int)(*(DWORD *)(GET_IOBase(hwcx) + REG_QUELEN) & MASK_QUELEN) \
+ - (int)20; \
+ }\
+ *(hwcx->CurrentQueueLenPtr) -= (int)(wLen);\
+}while(0)
+
+#if 0
+#define mWait3DCmdQueue(wLen) do{}while(0);
+#endif
+
+#define GFLAG_ENABLESETTING 0x00000001
+#define GFLAG_ENABLESETTING2 0x00000002
+#define GFLAG_ZSETTING 0x00000004
+#define GFLAG_ALPHASETTING 0x00000008
+#define GFLAG_DESTSETTING 0x00000010
+#define GFLAG_LINESETTING 0x00000020
+#define GFLAG_STENCILSETTING 0x00000040
+#define GFLAG_FOGSETTING 0x00000080
+#define GFLAG_DSTBLEND 0x00000100
+#define GFLAG_CLIPPING 0x00000200
+#define CFLAG_TEXTURERESET 0x00000400
+#define GFLAG_TEXTUREMIPMAP 0x00000800
+#define GFLAG_TEXBORDERCOLOR 0x00001000
+#define GFLAG_TEXTUREADDRESS 0x00002000
+#define GFLAG_TEXTUREENV 0x00004000
+#define CFLAG_TEXTURERESET_1 0x00008000
+#define GFLAG_TEXTUREMIPMAP_1 0x00010000
+#define GFLAG_TEXBORDERCOLOR_1 0x00020000
+#define GFLAG_TEXTUREADDRESS_1 0x00040000
+#define GFLAG_TEXTUREENV_1 0x00080000
+
+#define GFLAG_TEXTURE_STATES (CFLAG_TEXTURERESET | GFLAG_TEXTUREMIPMAP | \
+ GFLAG_TEXBORDERCOLOR | GFLAG_TEXTUREADDRESS | \
+ CFLAG_TEXTURERESET_1 | GFLAG_TEXTUREMIPMAP_1 | \
+ GFLAG_TEXBORDERCOLOR_1 | \
+ GFLAG_TEXTUREADDRESS_1 | \
+ GFLAG_TEXTUREENV | GFLAG_TEXTUREENV_1)
+
+
+#define GFLAG_RENDER_STATES (GFLAG_ENABLESETTING | GFLAG_ENABLESETTING2 | \
+ GFLAG_ZSETTING | GFLAG_ALPHASETTING | \
+ GFLAG_DESTSETTING | GFLAG_FOGSETTING | \
+ GFLAG_STENCILSETTING | GFLAG_DSTBLEND | \
+ GFLAG_CLIPPING)
+
+
+
+#define Index_SR_Ext_BIOS 0x10
+#define REVISION_6205BASE 3
+#define SiS6326 (REVISION_6205BASE+20) /* 6326 A/B/C0 */
+#define SiS6326C (REVISION_6205BASE+21) /* 6326 C1 */
+#define SiS6326C5 (REVISION_6205BASE+22) /* 6326 C5 */
+#define SiS6326G (REVISION_6205BASE+25) /* 6326 C1 */
+#define SiS6326D0 (REVISION_6205BASE+30) /* 6326 D0 */
+#define SiS6326D1 (REVISION_6205BASE+31) /* 6326 D1 */
+#define SiS6326D2 (REVISION_6205BASE+32) /* 6326 D2 */
+#define SiS6326H0 (REVISION_6205BASE+35) /* 6326 H0 */
+#define SiS6215A (REVISION_6205BASE+1) /* 6205 B2, Video only version */
+#define SiS6215B (REVISION_6205BASE+2) /* 6205 D3, Video only version */
+#define SiS6215C (REVISION_6205BASE+3) /* 6205 B2, Video XOR version */
+#define SiS6205B (REVISION_6205BASE+4) /* 6205 B2 */
+#define SiS6205D (REVISION_6205BASE+5) /* 6205 D3 */
+#define SiS5597 (REVISION_6205BASE+7) /* Jedi, 5597, 5598 */
+
+#define REVISION_6205 {{0x6326, 0xAF, 0, SiS6326 },\
+ {0x6326, 0xC1, 0, SiS6326C },\
+ {0x6326, 0x92, 0, SiS6326D2},\
+ {0x6326, 0x92, 1, SiS6326D2},\
+ {0x6326, 0x0A, 0, SiS6326G },\
+ {0x6326, 0xD0, 0, SiS6326D0},\
+ {0x6326, 0xD1, 0, SiS6326D1},\
+ {0x6326, 0xD2, 0, SiS6326D2},\
+ {0x6326, 0xD2, 1, SiS6326D2},\
+ {0x6326, 0x0B, 0, SiS6326H0},\
+ {0x6326, 0x0B, 1, SiS6326H0},\
+ {0x0200, 0x6F, 0, SiS5597 },\
+ {0x0205, 0x6F, 0, SiS5597 },\
+ {0x0205, 0x44, 1, SiS6215A },\
+ {0x0205, 0xD3, 1, SiS6215B },\
+ {0x0204, 0x2F, 1, SiS6215C },\
+ {0x0205, 0x44, 0, SiS6205B },\
+ {0x0205, 0xD3, 0, SiS6205D }}
+
+#define REG_QUELEN 0x8240 /* Byte for 201C */
+#define MASK_QUELEN 0xffff
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h b/xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h
new file mode 100644
index 000000000..d85be4176
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h
@@ -0,0 +1,243 @@
+#define SIS_TRI_FUNC 0
+
+#define SIS_MMIO_WRITE_VERTEX(v, i) \
+ if(SIS_STEREO && hwcx->stereoEnabled) \
+ { \
+ MMIOBase[(REG_3D_TSXa+(i)*0x30)/4] = VB->Win.data[v][0] - 0.5 + STEREO_OFFSET(v); \
+ MMIOBase[(REG_3D_TSYa+(i)*0x30)/4] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \
+ } \
+ else \
+ { \
+ MMIOBase[(REG_3D_TSXa+(i)*0x30)/4] = VB->Win.data[v][0] - 0.5 ; \
+ MMIOBase[(REG_3D_TSYa+(i)*0x30)/4] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \
+ } \
+\
+ if (ctx->TriangleCaps & DD_TRI_OFFSET) \
+ { \
+ if(SIS_TRI_FUNC){ \
+ MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = \
+ (VB->Win.data[v][2] + ctx->PolygonZoffset) / 65535.0; \
+ } \
+ else{ \
+ MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = \
+ (VB->Win.data[v][2] + ctx->LineZoffset) / 65535.0; \
+ } \
+ } \
+ else \
+ { \
+ MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = VB->Win.data[v][2] / 65535.0; \
+ } \
+\
+ if (SIS_STATES & SIS_TEXTURE0) \
+ { \
+ if(VB->TexCoordPtr[0]->size == 4){ \
+ MMIOBase[(REG_3D_TSUAa+(i)*0x30)/4] = VB->TexCoordPtr[0]->data[v][0] / \
+ VB->TexCoordPtr[0]->data[v][3]; \
+ MMIOBase[(REG_3D_TSVAa+(i)*0x30)/4] = VB->TexCoordPtr[0]->data[v][1] / \
+ VB->TexCoordPtr[0]->data[v][3]; \
+ } \
+ else{ \
+ MMIOBase[(REG_3D_TSUAa+(i)*0x30)/4] = VB->TexCoordPtr[0]->data[v][0]; \
+ MMIOBase[(REG_3D_TSVAa+(i)*0x30)/4] = VB->TexCoordPtr[0]->data[v][1]; \
+ } \
+ } \
+\
+ if (SIS_STATES & SIS_TEXTURE1) \
+ { \
+ if(VB->TexCoordPtr[1]->size == 4){ \
+ MMIOBase[(REG_3D_TSUBa+(i)*0x30)/4] = VB->TexCoordPtr[1]->data[v][0] / \
+ VB->TexCoordPtr[1]->data[v][3]; \
+ MMIOBase[(REG_3D_TSVBa+(i)*0x30)/4] = VB->TexCoordPtr[1]->data[v][1] / \
+ VB->TexCoordPtr[1]->data[v][3]; \
+ } \
+ else{ \
+ MMIOBase[(REG_3D_TSUBa+(i)*0x30)/4] = VB->TexCoordPtr[1]->data[v][0]; \
+ MMIOBase[(REG_3D_TSVBa+(i)*0x30)/4] = VB->TexCoordPtr[1]->data[v][1]; \
+ } \
+ } \
+\
+ if (SIS_STATES & (SIS_USE_W)) \
+ { \
+ if(VB->TexCoordPtr[0]->size == 4){ \
+ MMIOBase[(REG_3D_TSWGa+(i)*0x30)/4] = VB->Win.data[v][3] * \
+ VB->TexCoordPtr[0]->data[v][3]; \
+ } \
+ else{ \
+ MMIOBase[(REG_3D_TSWGa+(i)*0x30)/4] = VB->Win.data[v][3]; \
+ } \
+ } \
+\
+ if (SIS_STATES & (SIS_SMOOTH)) \
+ { \
+ DWORD dcSARGB; \
+\
+ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[v]); \
+\
+ ((DWORD *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = dcSARGB; \
+ } \
+ else if(LAST_VERTEX) \
+ { \
+ DWORD dcSARGB; \
+\
+ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[pv]); \
+\
+ ((DWORD *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = dcSARGB; \
+ } \
+
+static void
+SIS_TAG (sis_line) (GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pv)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ struct vertex_buffer *VB = ctx->VB;
+ float *MMIOBase = (float *) GET_IOBase (hwcx);
+
+ STEREO_SAMPLE(vert0);
+
+ mWait3DCmdQueue (10 * 2 + 1);
+
+ if (SIS_STATES & (SIS_SMOOTH))
+ {
+ hwcx->dwPrimitiveSet &= ~0x07001f07;
+ hwcx->dwPrimitiveSet |=
+ (OP_3D_FIRE_TSARGBb | SHADE_GOURAUD | OP_3D_LINE_DRAW);
+
+ ((DWORD *) MMIOBase)[REG_3D_PrimitiveSet / 4] = hwcx->dwPrimitiveSet;
+ }
+ else
+ {
+ hwcx->dwPrimitiveSet &= ~0x07001f07;
+ hwcx->dwPrimitiveSet |=
+ (OP_3D_FIRE_TSARGBb | SHADE_FLAT_VertexB | OP_3D_LINE_DRAW);
+
+ ((DWORD *) MMIOBase)[REG_3D_PrimitiveSet / 4] = hwcx->dwPrimitiveSet;
+ }
+
+#define LAST_VERTEX 0
+ SIS_MMIO_WRITE_VERTEX (vert0, 0);
+#undef LAST_VERTEX
+#define LAST_VERTEX 1
+ SIS_MMIO_WRITE_VERTEX (vert1, 1);
+#undef LAST_VERTEX
+
+ /* debug
+ mEndPrimitive ();
+ WaitEngIdle(hwcx);
+ d2f_once (ctx);
+ */
+}
+
+#define SIS_AGP_WRITE_VERTEX(v) \
+do{ \
+if(SIS_STEREO && hwcx->stereoEnabled) \
+{ \
+ AGP_CurrentPtr[0] = VB->Win.data[v][0] - 0.5 + STEREO_OFFSET(v); \
+} \
+else \
+{ \
+ AGP_CurrentPtr[0] = VB->Win.data[v][0] - 0.5; \
+} \
+AGP_CurrentPtr[1] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \
+\
+if (ctx->TriangleCaps & DD_TRI_OFFSET){ \
+ if(SIS_TRI_FUNC){ \
+ AGP_CurrentPtr[2] = (VB->Win.data[v][2] + ctx->PolygonZoffset) / 65535.0; \
+ } \
+ else{ \
+ AGP_CurrentPtr[2] = (VB->Win.data[v][2] + ctx->LineZoffset) / 65535.0; \
+ } \
+} \
+else{ \
+ AGP_CurrentPtr[2] = VB->Win.data[v][2] / 65535.0; \
+}\
+AGP_CurrentPtr+=3; \
+if (SIS_STATES & (SIS_USE_W)) \
+{ \
+ if(VB->TexCoordPtr[1]->size == 4){ \
+ AGP_CurrentPtr[0] = VB->Win.data[v][3] * \
+ VB->TexCoordPtr[0]->data[v][3]; \
+ } \
+ else{ \
+ AGP_CurrentPtr[0] = VB->Win.data[v][3]; \
+ } \
+ AGP_CurrentPtr+=1; \
+} \
+\
+if (SIS_STATES & (SIS_SMOOTH)) \
+{ \
+ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[v]); \
+ ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \
+} \
+else if(FIRST_VERTEX) \
+{ \
+ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[pv]); \
+ ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \
+} \
+else \
+{ \
+ ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \
+} \
+AGP_CurrentPtr+=1; \
+\
+if (SIS_STATES & SIS_TEXTURE0) \
+{ \
+ if(VB->TexCoordPtr[0]->size == 4){ \
+ AGP_CurrentPtr[0] = VB->TexCoordPtr[0]->data[v][0] / \
+ VB->TexCoordPtr[0]->data[v][3]; \
+ AGP_CurrentPtr[1] = VB->TexCoordPtr[0]->data[v][1] / \
+ VB->TexCoordPtr[0]->data[v][3]; \
+ } \
+ else{ \
+ AGP_CurrentPtr[0] = VB->TexCoordPtr[0]->data[v][0]; \
+ AGP_CurrentPtr[1] = VB->TexCoordPtr[0]->data[v][1]; \
+ } \
+ AGP_CurrentPtr+=2; \
+} \
+\
+if (SIS_STATES & SIS_TEXTURE1) \
+{ \
+ if(VB->TexCoordPtr[1]->size == 4){ \
+ AGP_CurrentPtr[0] = VB->TexCoordPtr[1]->data[v][0] / \
+ VB->TexCoordPtr[1]->data[v][3]; \
+ AGP_CurrentPtr[1] = VB->TexCoordPtr[1]->data[v][1] / \
+ VB->TexCoordPtr[1]->data[v][3]; \
+ } \
+ else{ \
+ AGP_CurrentPtr[0] = VB->TexCoordPtr[1]->data[v][0]; \
+ AGP_CurrentPtr[1] = VB->TexCoordPtr[1]->data[v][1]; \
+ } \
+ AGP_CurrentPtr+=2; \
+} \
+}while(0)
+
+static void
+SIS_TAG (sis_agp_line) (GLcontext * ctx, GLuint vert0, GLuint vert1,
+ GLuint pv)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ struct vertex_buffer *VB = ctx->VB;
+
+ DWORD dcSARGB;
+
+ STEREO_SAMPLE(vert0);
+
+#if 0
+ if ((DWORD) AGP_CurrentPtr - (DWORD) AGP_StartPtr >= (AGP_ALLOC_SIZE - 0x10))
+ {
+ sis_FlushAGP (ctx);
+ sis_StartAGP (ctx);
+ }
+#endif
+
+#define FIRST_VERTEX 1
+ SIS_AGP_WRITE_VERTEX (vert0);
+#undef FIRST_VERTEX
+#define FIRST_VERTEX 0
+ SIS_AGP_WRITE_VERTEX (vert1);
+#undef FIRST_VERTEX
+}
+
+#undef SIS_TRI_FUNC
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_lock.h b/xc/lib/GL/mesa/src/drv/sis/sis_lock.h
new file mode 100644
index 000000000..7e6dadb20
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_lock.h
@@ -0,0 +1,102 @@
+#ifndef _sis_dri_h_
+#define _sis_dri_h_
+
+/* from tdfx */
+#define SIS_VALIDATE_DRAWABLE_INFO(dpy, psp, pdp) \
+do { \
+ while (*(pdp->pStamp) != pdp->lastStamp) { \
+ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
+ DRI_MESA_VALIDATE_DRAWABLE_INFO(dpy, psp->myNum, pdp); \
+ DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
+ sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); \
+ } \
+} while (0)
+
+#ifdef DEBUG_LOCKING
+extern char *prevLockFile;
+extern int prevLockLine;
+#define DEBUG_LOCK() \
+ do { \
+ prevLockFile=(__FILE__); \
+ prevLockLine=(__LINE__); \
+ } while (0)
+#define DEBUG_RESET() \
+ do { \
+ prevLockFile=NULL; \
+ prevLockLine=0; \
+ } while (0)
+#define DEBUG_CHECK_LOCK() \
+ do { \
+ if(prevLockFile){ \
+ fprintf(stderr, "LOCK SET : %s:%d\n", __FILE__, __LINE__); \
+ } \
+ } while (0)
+#else
+#define DEBUG_LOCK()
+#define DEBUG_RESET()
+#define DEBUG_CHECK_LOCK()
+#endif
+
+#ifdef XFree86Server
+
+/* TODO, X-server will inform us if drawable state changed? */
+#define LOCK_HARDWARE() \
+ do { \
+ mEndPrimitive(); \
+ sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); \
+ if(*(hwcx->CurrentHwcxPtr) != hwcx->serialNumber) \
+ sis_validate_all_state(hwcx); \
+ } while (0)
+
+#define UNLOCK_HARDWARE() \
+ do { \
+ mEndPrimitive(); \
+ } while (0)
+
+#else
+
+#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 { \
+ int stamp; \
+ char __ret=0; \
+ __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; \
+ __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \
+ mEndPrimitive(); \
+ DEBUG_CHECK_LOCK(); \
+ DEBUG_LOCK(); \
+ DRM_LIGHT_LOCK_RETURN(sPriv->fd, &sPriv->pSAREA->lock, \
+ dPriv->driContextPriv->hHWContext, __ret); \
+ stamp=dPriv->lastStamp; \
+ XMESA_VALIDATE_DRAWABLE_INFO(xmesa->display, sPriv, dPriv); \
+ if (*(dPriv->pStamp)!=stamp) \
+ { \
+ sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); \
+ } \
+ if(__ret && (*(hwcx->CurrentHwcxPtr) != hwcx->serialNumber)) \
+ { \
+ sis_validate_all_state(hwcx); \
+ } \
+ } while (0)
+
+/* Unlock the hardware using the global current context */
+#define UNLOCK_HARDWARE() \
+ do { \
+ __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; \
+ __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \
+ mEndPrimitive(); \
+ DEBUG_RESET(); \
+ *(hwcx->CurrentHwcxPtr) = hwcx->serialNumber; \
+ DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, \
+ dPriv->driContextPriv->hHWContext); \
+ } while (0)
+
+#endif
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_mesa.c b/xc/lib/GL/mesa/src/drv/sis/sis_mesa.c
new file mode 100644
index 000000000..7e91e5fd2
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_mesa.c
@@ -0,0 +1,1542 @@
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+#include "sis_lock.h"
+
+#include "state.h"
+
+void
+sis_RenderStart (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ LOCK_HARDWARE ();
+
+ if (hwcx->Primitive & hwcx->swRenderFlag)
+ {
+ WaitEngIdle (hwcx);
+ }
+
+ if (ctx->Texture.ReallyEnabled)
+ {
+ sis_validate_texture (ctx);
+ if (hwcx->swRenderFlag & SIS_SW_TEXTURE)
+ {
+ hwcx->swForceRender = GL_TRUE;
+ gl_update_state(ctx);
+ hwcx->swForceRender = GL_FALSE;
+ }
+ else
+ {
+ if (hwcx->GlobalFlag & GFLAG_TEXTURE_STATES)
+ sis_update_texture_state (hwcx);
+ }
+ }
+
+ if (hwcx->GlobalFlag & GFLAG_RENDER_STATES)
+ {
+ sis_update_render_state (hwcx, 0);
+ }
+
+ if (hwcx->UseAGPCmdMode)
+ {
+ sis_StartAGP (ctx);
+ }
+
+ /* d2f_once (ctx); */
+}
+
+void
+sis_RenderFinish (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ if (hwcx->UseAGPCmdMode)
+ {
+ sis_FlushAGP (ctx);
+ }
+
+ UNLOCK_HARDWARE ();
+}
+
+void
+sis_ReducedPrimitiveChange (GLcontext * ctx, GLenum primitive)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ /* it is possible several primitive types per VB */
+ if (hwcx->UseAGPCmdMode)
+ {
+ sis_FlushAGP (ctx);
+ sis_StartAGP (ctx);
+ }
+ else
+ {
+ mEndPrimitive();
+
+ /*
+ * do nothing now because each hw's primitive-type will be set
+ * per primitive
+ */
+
+ /* TODO: if above rule changes, remember to modify */
+ }
+
+ hwcx->AGPParseSet &= ~0xf;
+ switch (primitive)
+ {
+ case GL_POINT:
+ case GL_POINTS:
+ hwcx->Primitive = SIS_SW_POINT;
+ hwcx->AGPParseSet |= 0x0;
+ break;
+ case GL_LINE:
+ case GL_LINES:
+ hwcx->Primitive = SIS_SW_LINE;
+ hwcx->AGPParseSet |= 0x4;
+ break;
+ case GL_POLYGON:
+ hwcx->Primitive = SIS_SW_TRIANGLE;
+ hwcx->AGPParseSet |= 0x8;
+ break;
+ }
+}
+
+void
+sis_init_driver (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ ctx->Driver.UpdateState = sis_UpdateState;
+
+ ctx->Driver.RenderStart = sis_RenderStart;
+ ctx->Driver.RenderFinish = sis_RenderFinish;
+ ctx->Driver.ReducedPrimitiveChange = sis_ReducedPrimitiveChange;
+ ctx->Driver.Finish = sis_Finish;
+ ctx->Driver.Flush = sis_Flush;
+
+ ctx->Driver.AlphaFunc = sis_AlphaFunc;
+ ctx->Driver.BlendEquation = sis_BlendEquation;
+ ctx->Driver.BlendFunc = sis_BlendFunc;
+ ctx->Driver.BlendFuncSeparate = sis_BlendFuncSeparate;
+ ctx->Driver.ClearDepth = sis_ClearDepth;
+ ctx->Driver.CullFace = sis_CullFace;
+ ctx->Driver.FrontFace = sis_FrontFace;
+ ctx->Driver.DepthFunc = sis_DepthFunc;
+ ctx->Driver.DepthMask = sis_DepthMask;
+ ctx->Driver.DepthRange = sis_DepthRange;
+ ctx->Driver.Enable = sis_Enable;
+ ctx->Driver.Fogfv = sis_Fogfv;
+ ctx->Driver.Hint = sis_Hint;
+ ctx->Driver.Lightfv = sis_Lightfv;
+ ctx->Driver.LightModelfv = sis_LightModelfv;
+ ctx->Driver.PolygonMode = sis_PolygonMode;
+ ctx->Driver.Scissor = sis_Scissor;
+ ctx->Driver.ShadeModel = sis_ShadeModel;
+ ctx->Driver.ClearStencil = sis_ClearStencil;
+ ctx->Driver.StencilFunc = sis_StencilFunc;
+ ctx->Driver.StencilMask = sis_StencilMask;
+ ctx->Driver.StencilOp = sis_StencilOp;
+ ctx->Driver.Viewport = sis_Viewport;
+
+ ctx->Driver.Clear = sis_Clear;
+
+ ctx->Driver.TexEnv = sis_TexEnv;
+ ctx->Driver.TexImage = sis_TexImage;
+ ctx->Driver.TexSubImage = sis_TexSubImage;
+ ctx->Driver.TexParameter = sis_TexParameter;
+ ctx->Driver.BindTexture = sis_BindTexture;
+ ctx->Driver.DeleteTexture = sis_DeleteTexture;
+ ctx->Driver.UpdateTexturePalette = sis_UpdateTexturePalette;
+ ctx->Driver.ActiveTexture = sis_ActiveTexture;
+ ctx->Driver.IsTextureResident = sis_IsTextureResident;
+ ctx->Driver.PrioritizeTexture = sis_PrioritizeTexture;
+
+ ctx->Driver.ClearColor = sis_ClearColor;
+ ctx->Driver.SetDrawBuffer = sis_SetDrawBuffer;
+ ctx->Driver.SetReadBuffer = sis_SetReadBuffer;
+ ctx->Driver.GetBufferSize = sis_GetBufferSize;
+ ctx->Driver.GetString = sis_GetString;
+ ctx->Driver.ColorMask = sis_ColorMask;
+ ctx->Driver.LogicOp = sis_LogicOp;
+ ctx->Driver.Dither = sis_Dither;
+ ctx->Driver.GetParameteri = sis_GetParameteri;
+ ctx->Driver.DrawPixels = sis_DrawPixels;
+ ctx->Driver.Bitmap = sis_Bitmap;
+
+ /* Optimization */
+#if NOT_DONE
+ ctx->Driver.RasterSetup = sis_ChooseRasterSetupFunc(ctx);
+ ctx->Driver.RegisterVB = sis_RegisterVB;
+ ctx->Driver.UnregisterVB = sis_UnregisterVB;
+ ctx->Driver.ResetVB = sis_ResetVB;
+ ctx->Driver.ResetCvaVB = sis_ResetCvaVB;
+#endif
+
+ /* Fast Path */
+ ctx->Driver.RegisterPipelineStages = sis_RegisterPipelineStages;
+
+ /* driver-specific */
+ hwcx->SwapBuffers = sis_swap_buffers;
+
+#ifdef SIS_USE_HW_CULL
+ /* set capability flag */
+ ctx->Driver.TriangleCaps = DD_TRI_CULL;
+#endif
+}
+
+void
+sis_UpdateState (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ sis_set_render_func (ctx);
+
+ /* ?? duplicate in sis_Enable */
+ if (ctx->NewState & NEW_FOG)
+ {
+ if (ctx->RasterMask & FOG_BIT)
+ current->hwCapEnable |= MASK_FogEnable;
+ else
+ current->hwCapEnable &= ~MASK_FogEnable;
+ }
+
+ /* TODO: mesa->NewState. In sis_Enable? */
+ if (ctx->RasterMask & STENCIL_BIT)
+ {
+ current->hwCapEnable |=
+ (MASK_StencilTestEnable | MASK_StencilWriteEnable);
+ }
+ else
+ {
+ current->hwCapEnable &=
+ ~(MASK_StencilTestEnable | MASK_StencilWriteEnable);
+ }
+
+ /* NEW_TEXTURE_ENABLE depends on glEnable() instead of ReallyEnabled */
+ /* if (ctx->NewState & NEW_TEXTURE_ENABLE) */
+ if(1)
+ {
+ if (ctx->Texture.ReallyEnabled &
+ (TEXTURE0_1D | TEXTURE0_2D | TEXTURE1_1D | TEXTURE1_2D))
+ {
+ current->hwCapEnable |= MASK_TextureEnable;
+
+ current->hwCapEnable &= ~MASK_TextureNumUsed;
+ if (ctx->Texture.ReallyEnabled & TEXTURE1_ANY)
+ current->hwCapEnable |= 0x00002000;
+ else
+ current->hwCapEnable |= 0x00001000;
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_TextureEnable;
+ }
+
+#if 1
+ /* TODO : if unmark these, error in multitexture */
+ if(ctx->NewState & NEW_TEXTURE_ENABLE)
+ {
+ int i;
+ for (i = 0; i < SIS_MAX_TEXTURES; i++)
+ {
+ hwcx->TexStates[i] |= (NEW_TEXTURING | NEW_TEXTURE_ENV);
+ }
+ }
+#endif
+ }
+
+ /* enable setting 1 */
+ if (current->hwCapEnable ^ prev->hwCapEnable)
+ {
+ prev->hwCapEnable = current->hwCapEnable;
+ hwcx->GlobalFlag |= GFLAG_ENABLESETTING;
+ }
+
+ /* enable setting 2 */
+ if (current->hwCapEnable2 ^ prev->hwCapEnable2)
+ {
+ prev->hwCapEnable2 = current->hwCapEnable2;
+ hwcx->GlobalFlag |= GFLAG_ENABLESETTING2;
+ }
+
+ /* TODO: if fog disable, don't check */
+ if (current->hwCapEnable & MASK_FogEnable)
+ {
+ /* fog setting */
+ if (current->hwFog ^ prev->hwFog)
+ {
+ prev->hwFog = current->hwFog;
+ hwcx->GlobalFlag |= GFLAG_FOGSETTING;
+ }
+ if (current->hwFogFar ^ prev->hwFogFar)
+ {
+ prev->hwFogFar = current->hwFogFar;
+ hwcx->GlobalFlag |= GFLAG_FOGSETTING;
+ }
+ if (current->hwFogInverse ^ prev->hwFogInverse)
+ {
+ prev->hwFogInverse = current->hwFogInverse;
+ hwcx->GlobalFlag |= GFLAG_FOGSETTING;
+ }
+ if (current->hwFogDensity ^ prev->hwFogDensity)
+ {
+ prev->hwFogDensity = current->hwFogDensity;
+ hwcx->GlobalFlag |= GFLAG_FOGSETTING;
+ }
+ }
+
+#if NOT_DONE
+ sis_set_render_vb_tabs(ctx);
+#endif
+
+ /* TODO: assume when isFullScreen/DrawBuffer changed, UpdateState
+ * will be called
+ */
+#if SIS_STEREO
+ if(hwcx->isFullScreen &&
+ (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT) &&
+ hwcx->useStereo)
+ {
+ if(!hwcx->stereoEnabled){
+ sis_init_stereo(ctx);
+ }
+ }
+ else{
+ if(hwcx->stereoEnabled){
+ sis_final_stereo(ctx);
+ }
+ }
+#endif
+
+ /* TODO : 1. where to handle SIS_SW_TEXTURE?
+ * 2. sw<->hw
+ * 3. sw-render only if next primitve need to do
+ */
+}
+
+void
+sis_set_buffer_static (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ GLvisual *visual = ctx->Visual;
+
+ switch (hwcx->bytesPerPixel)
+ {
+ case 2:
+ /* TODO: don't check
+ if (hwcx->redMask == 0xf800 && hwcx->greenMask == 0x07e0 &&
+ hwcx->blueMask == 0x001f)
+ */
+ {
+ current->hwDstSet |= DST_FORMAT_RGB_565;
+ }
+ break;
+ case 4:
+ /*
+ if (hwcx->redMask == 0xff0000 && hwcx->greenMask == 0xff00 &&
+ hwcx->blueMask == 0xff)
+ */
+ {
+ switch (visual->AlphaBits)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ /* TODO */
+ current->hwDstSet |= DST_FORMAT_ARGB_8888;
+ break;
+ }
+ }
+ break;
+ default:
+ assert (0);
+ }
+
+ switch (visual->DepthBits)
+ {
+ case 0:
+ current->hwCapEnable &= ~MASK_ZWriteEnable;
+ case 16:
+ hwcx->zFormat = Z_16;
+ current->hwCapEnable |= MASK_ZWriteEnable;
+ break;
+ case 32:
+ hwcx->zFormat = Z_32;
+ current->hwCapEnable |= MASK_ZWriteEnable;
+ break;
+ case 24:
+ assert (visual->StencilBits);
+ hwcx->zFormat = S_8_Z_24;
+ current->hwCapEnable |= MASK_StencilBufferEnable;
+ current->hwCapEnable |= MASK_ZWriteEnable;
+ break;
+ }
+
+ current->hwZ &= ~MASK_ZBufferFormat;
+ current->hwZ |= hwcx->zFormat;
+
+ /* Destination Color Format */
+ if (current->hwDstSet ^ prev->hwDstSet)
+ {
+ prev->hwDstSet = current->hwDstSet;
+ hwcx->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+
+ /* Z Buffer Data Format */
+ if (current->hwZ ^ prev->hwZ)
+ {
+ prev->hwZ = current->hwZ;
+ hwcx->GlobalFlag |= GFLAG_ZSETTING;
+ }
+
+ sis_sw_set_zfuncs_static (ctx);
+}
+
+void
+sis_Finish (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ sis_Flush (ctx);
+
+ WaitEngIdle (hwcx);
+}
+
+void
+sis_Flush (GLcontext * ctx)
+{
+ /* do nothing now */
+}
+
+void
+sis_AlphaFunc (GLcontext * ctx, GLenum func, GLclampf ref)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ /* TODO: ref is type GLclampf, but mesa has scaled it to 0 - 255.0 */
+ current->hwAlpha = ((unsigned char) ref) << 16;
+
+ /* Alpha Test function */
+ current->hwAlpha &= ~0x07000000;
+ switch (func)
+ {
+ case GL_NEVER:
+ current->hwAlpha |= SiS_ALPHA_NEVER;
+ break;
+ case GL_LESS:
+ current->hwAlpha |= SiS_ALPHA_LESS;
+ break;
+ case GL_EQUAL:
+ current->hwAlpha |= SiS_ALPHA_EQUAL;
+ break;
+ case GL_LEQUAL:
+ current->hwAlpha |= SiS_ALPHA_LEQUAL;
+ break;
+ case GL_GREATER:
+ current->hwAlpha |= SiS_ALPHA_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ current->hwAlpha |= SiS_ALPHA_NOTEQUAL;
+ break;
+ case GL_GEQUAL:
+ current->hwAlpha |= SiS_ALPHA_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ current->hwAlpha |= SiS_ALPHA_ALWAYS;
+ break;
+ }
+
+ prev->hwAlpha = current->hwAlpha;
+ hwcx->GlobalFlag |= GFLAG_ALPHASETTING;
+}
+
+void
+sis_BlendEquation (GLcontext * ctx, GLenum mode)
+{
+ /* version 1.2 specific */
+ /* TODO: 300 don't support, fall back? */
+}
+
+void
+sis_BlendFunc (GLcontext * ctx, GLenum sfactor, GLenum dfactor)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ /* TODO: in ICD, if no blend, it will reset these value */
+ /* blending enable */
+ current->hwDstSrcBlend = 0x10000; /* Default destination alpha */
+
+ switch (dfactor)
+ {
+ case GL_ZERO:
+ current->hwDstSrcBlend |= SiS_D_ZERO;
+ break;
+ case GL_ONE:
+ current->hwDstSrcBlend |= SiS_D_ONE;
+ break;
+ case GL_SRC_COLOR:
+ current->hwDstSrcBlend |= SiS_D_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ current->hwDstSrcBlend |= SiS_D_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ current->hwDstSrcBlend |= SiS_D_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_ALPHA;
+ break;
+ }
+
+ switch (sfactor)
+ {
+ case GL_ZERO:
+ current->hwDstSrcBlend |= SiS_S_ZERO;
+ break;
+ case GL_ONE:
+ current->hwDstSrcBlend |= SiS_S_ONE;
+ break;
+ case GL_SRC_ALPHA:
+ current->hwDstSrcBlend |= SiS_S_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ current->hwDstSrcBlend |= SiS_S_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_ALPHA;
+ break;
+ case GL_DST_COLOR:
+ current->hwDstSrcBlend |= SiS_S_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ current->hwDstSrcBlend |= SiS_S_SRC_ALPHA_SATURATE;
+ break;
+ }
+
+ if (current->hwDstSrcBlend ^ prev->hwDstSrcBlend)
+ {
+ prev->hwDstSrcBlend = current->hwDstSrcBlend;
+ hwcx->GlobalFlag |= GFLAG_DSTBLEND;
+ }
+}
+
+void
+sis_BlendFuncSeparate (GLcontext * ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA)
+{
+}
+
+void
+sis_CullFace (GLcontext * ctx, GLenum mode)
+{
+#ifdef SIS_USE_HW_CULL
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ hwcx->AGPParseSet &= ~0x00008000;
+ hwcx->dwPrimitiveSet &= ~0x08000000;
+
+ /* TODO : GL_FRONT_AND_BACK must be handled elsewhere */
+ if((mode == GL_FRONT && ctx->Polygon.FrontFace == GL_CCW) ||
+ (mode == GL_BACK && ctx->Polygon.FrontFace == GL_CW))
+ {
+ hwcx->AGPParseSet |= 0x00008000;
+ hwcx->dwPrimitiveSet |= 0x08000000;
+ }
+#endif
+}
+
+void
+sis_FrontFace (GLcontext * ctx, GLenum mode)
+{
+#ifdef SIS_USE_HW_CULL
+ sis_CullFace (ctx, ctx->Polygon.CullFaceMode);
+#endif
+}
+
+void
+sis_DepthFunc (GLcontext * ctx, GLenum func)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ GLuint hwZFunc = 0;
+
+ switch (func)
+ {
+ case GL_LESS:
+ hwZFunc = SiS_Z_COMP_S_LT_B;
+ break;
+ case GL_GEQUAL:
+ hwZFunc = SiS_Z_COMP_S_GE_B;
+ break;
+ case GL_LEQUAL:
+ hwZFunc = SiS_Z_COMP_S_LE_B;
+ break;
+ case GL_GREATER:
+ hwZFunc = SiS_Z_COMP_S_GT_B;
+ break;
+ case GL_NOTEQUAL:
+ hwZFunc = SiS_Z_COMP_S_NE_B;
+ break;
+ case GL_EQUAL:
+ hwZFunc = SiS_Z_COMP_S_EQ_B;
+ break;
+ case GL_ALWAYS:
+ hwZFunc = SiS_Z_COMP_ALWAYS;
+ break;
+ case GL_NEVER:
+ hwZFunc = SiS_Z_COMP_NEVER;
+ break;
+ }
+ current->hwZ &= ~MASK_ZTestMode;
+ current->hwZ |= hwZFunc;
+
+ if (current->hwZ ^ prev->hwZ)
+ {
+ prev->hwZ = current->hwZ;
+
+ hwcx->GlobalFlag |= GFLAG_ZSETTING;
+ }
+}
+
+void
+sis_DepthMask (GLcontext * ctx, GLboolean flag)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ __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)
+ {
+ current->hwCapEnable |= MASK_ZWriteEnable;
+ if (flag && ctx->Stencil.WriteMask == 0xff)
+ {
+ current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable;
+ }
+ else
+ {
+ current->hwCapEnable2 |= MASK_ZMaskWriteEnable;
+ current->hwZMask = ((DWORD) ctx->Stencil.WriteMask << 24) |
+ ((flag) ? 0x00ffffff : 0);
+
+ if (current->hwZMask ^ prev->hwZMask)
+ {
+ prev->hwZMask = current->hwZMask;
+ hwcx->GlobalFlag |= GFLAG_ZSETTING;
+ }
+ }
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_ZWriteEnable;
+ }
+ }
+ else
+ {
+ if (flag)
+ {
+ current->hwCapEnable |= MASK_ZWriteEnable;
+ current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable;
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_ZWriteEnable;
+ }
+ }
+}
+
+void
+sis_DepthRange (GLcontext * ctx, GLclampd nearval, GLclampd farval)
+{
+ /* mesa handles it? */
+}
+
+void
+sis_Enable (GLcontext * ctx, GLenum cap, GLboolean state)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *current = &hwcx->current;
+
+ switch (cap)
+ {
+ case GL_ALPHA_TEST:
+ if (state)
+ {
+ current->hwCapEnable |= MASK_AlphaTestEnable;
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_AlphaTestEnable;
+ }
+ break;
+/*
+ case GL_AUTO_NORMAL:
+ break;
+*/
+ case GL_BLEND:
+ /* TODO: */
+ if(state)
+ /* if (state & !ctx->Color.ColorLogicOpEnabled) */
+ {
+ current->hwCapEnable |= MASK_BlendEnable;
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_BlendEnable;
+ }
+ 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:
+ break;
+ case GL_COLOR_MATERIAL:
+ break;
+*/
+ case GL_CULL_FACE:
+#ifdef SIS_USE_HW_CULL
+ if (state)
+ {
+ current->hwCapEnable |= MASK_CullEnable;
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_CullEnable;
+ }
+#endif
+ break;
+ case GL_DEPTH_TEST:
+ if (state && xmesa->xm_buffer->gl_buffer->DepthBuffer)
+ {
+ current->hwCapEnable |= MASK_ZTestEnable;
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_ZTestEnable;
+ }
+ break;
+ case GL_DITHER:
+ if (state)
+ {
+ current->hwCapEnable |= MASK_DitherEnable;
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_DitherEnable;
+ }
+ break;
+/*
+ case GL_FOG:
+ 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:
+ break;
+ case GL_LIGHTING:
+ break;
+ case GL_LINE_SMOOTH:
+ break;
+ case GL_LINE_STIPPLE:
+ break;
+ case GL_INDEX_LOGIC_OP:
+ break;
+*/
+ case GL_COLOR_LOGIC_OP:
+ if (state)
+ {
+ sis_LogicOp (ctx, ctx->Color.LogicOp);
+ }
+ else
+ {
+ sis_LogicOp (ctx, GL_COPY);
+ }
+ break;
+/*
+ case GL_MAP1_COLOR_4:
+ break;
+ case GL_MAP1_INDEX:
+ break;
+ case GL_MAP1_NORMAL:
+ break;
+ case GL_MAP1_TEXTURE_COORD_1:
+ break;
+ case GL_MAP1_TEXTURE_COORD_2:
+ break;
+ case GL_MAP1_TEXTURE_COORD_3:
+ break;
+ case GL_MAP1_TEXTURE_COORD_4:
+ break;
+ case GL_MAP1_VERTEX_3:
+ break;
+ case GL_MAP1_VERTEX_4:
+ break;
+ case GL_MAP2_COLOR_4:
+ break;
+ case GL_MAP2_INDEX:
+ break;
+ case GL_MAP2_NORMAL:
+ break;
+ case GL_MAP2_TEXTURE_COORD_1:
+ break;
+ case GL_MAP2_TEXTURE_COORD_2:
+ break;
+ case GL_MAP2_TEXTURE_COORD_3:
+ break;
+ case GL_MAP2_TEXTURE_COORD_4:
+ break;
+ case GL_MAP2_VERTEX_3:
+ break;
+ case GL_MAP2_VERTEX_4:
+ break;
+ case GL_NORMALIZE:
+ break;
+ case GL_POINT_SMOOTH:
+ break;
+ case GL_POLYGON_SMOOTH:
+ break;
+ case GL_POLYGON_STIPPLE:
+ break;
+ case GL_POLYGON_OFFSET_POINT:
+ break;
+ case GL_POLYGON_OFFSET_LINE:
+ break;
+ case GL_POLYGON_OFFSET_FILL:
+ case GL_POLYGON_OFFSET_EXT:
+ break;
+ case GL_RESCALE_NORMAL_EXT:
+ break;
+*/
+ case GL_SCISSOR_TEST:
+ sis_set_scissor (ctx);
+ break;
+/*
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ break;
+*/
+ case GL_STENCIL_TEST:
+ if (state)
+ {
+ current->hwCapEnable |= (MASK_StencilTestEnable |
+ MASK_StencilWriteEnable);
+ }
+ else
+ {
+ current->hwCapEnable &= ~(MASK_StencilTestEnable |
+ MASK_StencilWriteEnable);
+ }
+ break;
+/*
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ break;
+ case GL_TEXTURE_GEN_Q:
+ break;
+ case GL_TEXTURE_GEN_R:
+ break;
+ case GL_TEXTURE_GEN_S:
+ break;
+ case GL_TEXTURE_GEN_T:
+ break;
+
+ case GL_VERTEX_ARRAY:
+ break;
+ case GL_NORMAL_ARRAY:
+ break;
+ case GL_COLOR_ARRAY:
+ break;
+ case GL_INDEX_ARRAY:
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ break;
+*/
+ }
+}
+
+void
+sis_Hint (GLcontext * ctx, GLenum target, GLenum mode)
+{
+#if 0
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ __GLSiSHardware *current = &hwcx->current;
+#endif
+
+ switch (target)
+ {
+ case GL_FOG_HINT:
+ switch (mode)
+ {
+ case GL_DONT_CARE:
+ break;
+ case GL_FASTEST:
+ /* vertex fog */
+ /* TODO */
+ break;
+ case GL_NICEST:
+ /* pixel fog */
+ break;
+ }
+ break;
+ case GL_LINE_SMOOTH_HINT:
+ break;
+ case GL_PERSPECTIVE_CORRECTION_HINT:
+#if 0
+ if (mode == GL_NICEST)
+ current->hwCapEnable |= MASK_TexturePerspectiveEnable;
+ else if (!(ctx->RasterMask & FOG_BIT))
+ current->hwCapEnable &= ~MASK_TexturePerspectiveEnable;
+#endif
+ break;
+ case GL_POINT_SMOOTH_HINT:
+ break;
+ case GL_POLYGON_SMOOTH_HINT:
+ break;
+ }
+}
+
+void
+sis_Lightfv (GLcontext * ctx, GLenum light,
+ GLenum pname, const GLfloat * params, GLint nparams)
+{
+}
+
+void
+sis_LightModelfv (GLcontext * ctx, GLenum pname, const GLfloat * params)
+{
+}
+
+void
+sis_PolygonMode (GLcontext * ctx, GLenum face, GLenum mode)
+{
+}
+
+void
+sis_Scissor (GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ if (ctx->Scissor.Enabled)
+ sis_set_scissor (ctx);
+}
+
+void
+sis_ShadeModel (GLcontext * ctx, GLenum mode)
+{
+}
+
+void
+sis_Viewport (GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+}
+
+void
+sis_ClearColor (GLcontext * ctx, GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ set_color_pattern (hwcx, red, green, blue, alpha);
+
+}
+
+/* TODO */
+void
+sis_ClearIndex (GLcontext * ctx, GLuint index)
+{
+}
+
+void sis_set_render_pos(GLcontext * ctx, GLubyte *base, GLuint pitch)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ assert (base != NULL);
+
+ if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){
+ fprintf(stderr, "set drawing position: base=%x, pitch=%u\n",
+ (unsigned int)base, pitch);
+ }
+
+ /* software render */
+ hwcx->swRenderBase = base;
+ hwcx->swRenderPitch = pitch;
+
+ current->hwOffsetDest = ((DWORD) base - (DWORD) GET_FbBase (hwcx)) >> 1;
+ current->hwDstSet &= ~MASK_DstBufferPitch;
+ current->hwDstSet |= pitch >> 2;
+
+ /* destination setting */
+ if (current->hwDstSet ^ prev->hwDstSet)
+ {
+ prev->hwDstSet = current->hwDstSet;
+ hwcx->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+
+ if (current->hwOffsetDest ^ prev->hwOffsetDest)
+ {
+ prev->hwOffsetDest = current->hwOffsetDest;
+ hwcx->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+}
+
+GLboolean
+sis_SetDrawBuffer (GLcontext * ctx, GLenum mode)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ XMesaBuffer xm_buffer = xmesa->xm_buffer;
+ GLubyte *base;
+ GLuint pitch;
+ GLboolean retval = GL_FALSE;
+
+ /* if new context bind, the function will be call? */
+ switch (mode)
+ {
+ case GL_BACK_LEFT:
+ base = (GLubyte *) xm_buffer->backimage->data;
+ pitch = xm_buffer->backimage->bytes_per_line;
+
+ retval = GL_TRUE;
+ break;
+ case GL_FRONT_LEFT:
+ base = sis_get_drawable_pos (xmesa);
+ pitch = GET_PITCH (hwcx);
+ retval = GL_TRUE;
+ break;
+ case GL_BACK_RIGHT:
+ case GL_FRONT_RIGHT:
+ default:
+ assert (0);
+ return GL_FALSE;
+ }
+
+ sis_set_render_pos(ctx, base, pitch);
+
+ return retval;
+}
+
+void
+sis_SetReadBuffer (GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum buffer)
+{
+ /* TODO */
+}
+
+GLboolean
+sis_ColorMask (GLcontext * ctx,
+ GLboolean rmask, GLboolean gmask,
+ GLboolean bmask, GLboolean amask)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+
+ if (rmask & gmask & bmask &
+ (!xmesa->xm_visual->gl_visual->AlphaBits | amask))
+ {
+ current->hwCapEnable2 &= ~(MASK_AlphaMaskWriteEnable |
+ MASK_ColorMaskWriteEnable);
+ }
+ else
+ {
+ current->hwCapEnable2 |= (MASK_AlphaMaskWriteEnable |
+ MASK_ColorMaskWriteEnable);
+
+ current->hwDstMask = (rmask) ? GET_RMASK (hwcx) : 0 |
+ (gmask) ? GET_GMASK (hwcx) : 0 |
+ (bmask) ? GET_BMASK (hwcx) : 0 |
+ (amask) ? GET_AMASK (hwcx) : 0;
+ }
+
+ if (current->hwDstMask ^ prev->hwDstMask)
+ {
+ prev->hwDstMask = current->hwDstMask;
+ hwcx->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+
+ return GL_TRUE;
+}
+
+GLboolean
+sis_LogicOp (GLcontext * ctx, GLenum op)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ if (ctx->Color.ColorLogicOpEnabled)
+ {
+ current->hwDstSet &= ~MASK_ROP2;
+ switch (op)
+ {
+ case GL_CLEAR:
+ current->hwDstSet |= LOP_CLEAR;
+ break;
+ case GL_SET:
+ current->hwDstSet |= LOP_SET;
+ break;
+ case GL_COPY:
+ current->hwDstSet |= LOP_COPY;
+ break;
+ case GL_COPY_INVERTED:
+ current->hwDstSet |= LOP_COPY_INVERTED;
+ break;
+ case GL_NOOP:
+ current->hwDstSet |= LOP_NOOP;
+ break;
+ case GL_INVERT:
+ current->hwDstSet |= LOP_INVERT;
+ break;
+ case GL_AND:
+ current->hwDstSet |= LOP_AND;
+ break;
+ case GL_NAND:
+ current->hwDstSet |= LOP_NAND;
+ break;
+ case GL_OR:
+ current->hwDstSet |= LOP_OR;
+ break;
+ case GL_NOR:
+ current->hwDstSet |= LOP_NOR;
+ break;
+ case GL_XOR:
+ current->hwDstSet |= LOP_XOR;
+ break;
+ case GL_EQUIV:
+ current->hwDstSet |= LOP_EQUIV;
+ break;
+ case GL_AND_REVERSE:
+ current->hwDstSet |= LOP_AND_REVERSE;
+ break;
+ case GL_AND_INVERTED:
+ current->hwDstSet |= LOP_AND_INVERTED;
+ break;
+ case GL_OR_REVERSE:
+ current->hwDstSet |= LOP_OR_REVERSE;
+ break;
+ case GL_OR_INVERTED:
+ current->hwDstSet |= LOP_OR_INVERTED;
+ break;
+ }
+
+ if (current->hwDstSet ^ prev->hwDstSet)
+ {
+ prev->hwDstSet = current->hwDstSet;
+ hwcx->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+ }
+ return GL_TRUE;
+}
+
+void
+sis_Dither (GLcontext * ctx, GLboolean enable)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *current = &hwcx->current;
+
+ if (enable)
+ {
+ current->hwCapEnable |= MASK_DitherEnable;
+ }
+ else
+ {
+ current->hwCapEnable &= ~MASK_DitherEnable;
+ }
+}
+
+GLint
+sis_GetParameteri (const GLcontext * ctx, GLint param)
+{
+ switch (param)
+ {
+ case DD_HAVE_HARDWARE_FOG:
+ /*
+ * fragment fogging is not free when compared with hardware
+ * vertex fogging because of the overhead of W
+ */
+ return 0;
+/*
+ case DD_MAX_TEXTURE_SIZE:
+ return SIS_MAX_TEXTURE_SIZE;
+ case DD_MAX_TEXTURES:
+ return SIS_MAX_TEXTURES;
+*/
+ }
+ return 0;
+}
+
+/* just sync between CPU and rendering-engine */
+GLboolean sis_DrawPixels (GLcontext * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ WaitEngIdle (hwcx);
+ return 0;
+}
+
+GLboolean sis_Bitmap (GLcontext * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte * bitmap)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ ctx->Driver.RenderStart( ctx );
+
+ WaitEngIdle (hwcx);
+ /* TODO: use tdfx's Bitmap */
+
+ ctx->Driver.RenderFinish( ctx );
+
+ return 0;
+}
+
+void
+set_color_pattern (__GLSiScontext * hwcx, GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha)
+{
+ /* XXX only RGB565 and ARGB8888 */
+ switch (GET_ColorFormat (hwcx))
+ {
+ case DST_FORMAT_ARGB_8888:
+ hwcx->clearColorPattern = (alpha << 24) +
+ (red << 16) + (green << 8) + (blue);
+ break;
+ case DST_FORMAT_RGB_565:
+ hwcx->clearColorPattern = ((red >> 3) << 11) +
+ ((green >> 2) << 5) + (blue >> 3);
+ hwcx->clearColorPattern |= hwcx->clearColorPattern << 16;
+ break;
+ default:
+ assert (0);
+ }
+}
+
+void
+set_z_stencil_pattern (__GLSiScontext * hwcx, GLclampd z, int stencil)
+{
+ GLuint zPattern, stencilPattern;
+ GLboolean dword_pattern;
+
+ if (z <= (float) 0.0)
+ zPattern = 0x0;
+ else if (z >= (float) 1.0)
+ zPattern = 0xFFFFFFFF;
+ else
+ zPattern = doFPtoFixedNoRound (*(DWORD *) & z, 32);
+
+ stencilPattern = 0;
+
+ switch (hwcx->zFormat)
+ {
+ case Z_16:
+ zPattern = zPattern >> 16;
+ zPattern &= 0x0000FFFF;
+ dword_pattern = GL_FALSE;
+ break;
+ case S_8_Z_24:
+ zPattern = zPattern >> 8;
+ zPattern &= 0x00FFFFFF;
+ stencilPattern = (stencilPattern << 24);
+ dword_pattern = GL_TRUE;
+ break;
+ case Z_32:
+ dword_pattern = GL_TRUE;
+ break;
+ default:
+ assert (0);
+ }
+ hwcx->clearZStencilPattern = zPattern | stencilPattern;
+ /* ?? */
+ if (!dword_pattern)
+ hwcx->clearZStencilPattern |= (zPattern | stencilPattern) << 16;
+}
+
+void
+sis_update_drawable_state (GLcontext * ctx)
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *current = &hwcx->current;
+ __GLSiSHardware *prev = &hwcx->prev;
+
+ XMesaBuffer xm_buffer = xmesa->xm_buffer;
+ GLuint z_depth;
+
+ sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer);
+ /* TODO: call sis_SetReadBuffer? */
+
+ switch (hwcx->zFormat)
+ {
+ case Z_16:
+ z_depth = 2;
+ break;
+ case Z_32:
+ case S_8_Z_24:
+ z_depth = 4;
+ break;
+ default:
+ assert (0);
+ }
+
+ 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) -
+ (DWORD) GET_FbBase (hwcx)) >> 2;
+
+ if ((current->hwOffsetZ ^ prev->hwOffsetZ)
+ || (current->hwZ ^ prev->hwZ))
+ {
+ prev->hwOffsetZ = current->hwOffsetZ;
+ prev->hwZ = current->hwZ;
+
+ /* Z setting */
+ hwcx->GlobalFlag |= GFLAG_ZSETTING;
+ }
+}
+
+void
+sis_GetBufferSize (GLcontext * ctx, GLuint * width, GLuint * height)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *current = &hwcx->current;
+ __GLSiSHardware *prev = &hwcx->prev;
+
+ GLuint winwidth, winheight;
+ XMesaBuffer xm_buffer = xmesa->xm_buffer;
+
+#ifndef XFree86Server
+ SIS_VALIDATE_DRAWABLE_INFO (xmesa->display,
+ xmesa->driContextPriv->driScreenPriv,
+ xmesa->driContextPriv->driDrawablePriv);
+#endif
+ sis_get_drawable_size (xmesa, &winwidth, &winheight);
+
+ *width = winwidth;
+ *height = winheight;
+
+ if (winwidth != xm_buffer->width || winheight != xm_buffer->height)
+ {
+ GLuint z_depth;
+
+ if (SIS_VERBOSE&VERBOSE_SIS_BUFFER)
+ {
+ fprintf(stderr, "GetBufferSize: before=(%d,%d), after=(%d,%d)\n",
+ xm_buffer->width, xm_buffer->height, winwidth, winheight);
+ }
+
+ xm_buffer->width = winwidth;
+ xm_buffer->height = winheight;
+
+ /* update hwcx->isFullScreen */
+ /* TODO: Does X-server have exclusive-mode? */
+ /* TODO: physical screen width/height will be changed dynamicly */
+
+#if SIS_STEREO
+ if((hwcx->virtualX == winwidth) && (hwcx->virtualY == winheight))
+ hwcx->isFullScreen = GL_TRUE;
+ else
+ hwcx->isFullScreen = GL_FALSE;
+#endif
+
+ if (xm_buffer->db_state)
+ {
+ sisBufferInfo *priv = (sisBufferInfo *) xm_buffer->private;
+
+ sis_alloc_back_image (ctx, xm_buffer->backimage, &priv->bbFree,
+ &priv->cbClearPacket);
+ }
+
+ if (xm_buffer->xm_visual->gl_visual->DepthBits)
+ sis_alloc_z_stencil_buffer (ctx);
+
+ switch (hwcx->zFormat)
+ {
+ case Z_16:
+ z_depth = 2;
+ break;
+ case Z_32:
+ case S_8_Z_24:
+ z_depth = 4;
+ break;
+ default:
+ assert (0);
+ }
+
+ sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer);
+ /* TODO: call sis_SetReadBuffer? */
+
+ 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) -
+ (DWORD) GET_FbBase (hwcx)) >> 2;
+
+ if ((current->hwOffsetZ ^ prev->hwOffsetZ)
+ || (current->hwZ ^ prev->hwZ))
+ {
+ prev->hwOffsetZ = current->hwOffsetZ;
+ prev->hwZ = current->hwZ;
+
+ /* Z setting */
+ hwcx->GlobalFlag |= GFLAG_ZSETTING;
+ }
+ }
+
+ /* Needed by Y_FLIP macro */
+ xm_buffer->bottom = (int) winheight - 1;
+
+ sis_set_scissor (ctx);
+}
+
+const GLubyte *
+sis_GetString (GLcontext * ctx, GLenum name)
+{
+ (void) ctx;
+
+ switch (name)
+ {
+ case GL_RENDERER:
+#ifdef XFree86Server
+ return (GLubyte *)"SIS 300/630/530 IR Mode";
+#else
+ return (GLubyte *)"SiS 300/630/530 DR Mode";
+#endif
+ default:
+ return NULL;
+ }
+}
+
+const char *
+sis_ExtensionString (GLcontext * ctx)
+{
+ return NULL;
+}
+
+void
+sis_set_scissor (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ GLint x1, y1, x2, y2;
+
+ /* ?? from context.c, do it 2 times */
+
+ x1 = 0;
+ y1 = 0;
+ x2 = xmesa->xm_buffer->width - 1;
+ y2 = xmesa->xm_buffer->height - 1;
+
+ if (ctx->Scissor.Enabled)
+ {
+ if (ctx->Scissor.X > x1)
+ {
+ x1 = ctx->Scissor.X;
+ }
+ if (ctx->Scissor.Y > y1)
+ {
+ y1 = ctx->Scissor.Y;
+ }
+ if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2)
+ {
+ x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ }
+ if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2)
+ {
+ y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1;
+ }
+ }
+
+ y1 = Y_FLIP (y1);
+ y2 = Y_FLIP (y2);
+
+ current->clipTopBottom = (y2 << 13) | y1;
+ current->clipLeftRight = (x1 << 13) | x2;
+
+ if ((current->clipTopBottom ^ prev->clipTopBottom) ||
+ (current->clipLeftRight ^ prev->clipLeftRight))
+ {
+ prev->clipTopBottom = current->clipTopBottom;
+ prev->clipLeftRight = current->clipLeftRight;
+ hwcx->GlobalFlag |= GFLAG_CLIPPING;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_mesa.h b/xc/lib/GL/mesa/src/drv/sis/sis_mesa.h
new file mode 100644
index 000000000..9d3d05db7
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_mesa.h
@@ -0,0 +1,201 @@
+#ifndef _sis_mesa_h_
+#define _sis_mesa_h_
+
+void sis_UpdateState (GLcontext * ctx);
+void sis_ClearIndex (GLcontext * ctx, GLuint index);
+void sis_ClearColor (GLcontext * ctx, GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha);
+GLbitfield sis_Clear (GLcontext * ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height);
+GLboolean sis_SetDrawBuffer (GLcontext * ctx, GLenum mode);
+void sis_SetReadBuffer (GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum buffer);
+void sis_GetBufferSize (GLcontext * ctx, GLuint * width, GLuint * height);
+const char *sis_ExtensionString (GLcontext * ctx);
+const GLubyte *sis_GetString (GLcontext * ctx, GLenum name);
+void sis_Finish (GLcontext * ctx);
+void sis_Flush (GLcontext * ctx);
+GLboolean sis_IndexMask (GLcontext * ctx, GLuint mask);
+GLboolean sis_ColorMask (GLcontext * ctx,
+ GLboolean rmask, GLboolean gmask,
+ GLboolean bmask, GLboolean amask);
+GLboolean sis_LogicOp (GLcontext * ctx, GLenum op);
+void sis_Dither (GLcontext * ctx, GLboolean enable);
+void sis_Error (GLcontext * ctx);
+void sis_NearFar (GLcontext * ctx, GLfloat nearVal, GLfloat farVal);
+GLint sis_GetParameteri (const GLcontext * ctx, GLint param);
+GLboolean sis_DrawPixels (GLcontext * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels);
+GLboolean sis_Bitmap (GLcontext * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte * bitmap);
+void sis_RenderStart (GLcontext * ctx);
+void sis_RenderFinish (GLcontext * ctx);
+
+typedef void (*sis_setup_func_t)(struct vertex_buffer *, GLuint, GLuint);
+sis_setup_func_t sis_ChooseRasterSetupFunc (GLcontext * ctx);
+
+void sis_ReducedPrimitiveChange (GLcontext * ctx, GLenum primitive);
+GLboolean sis_MultipassFunc (struct vertex_buffer *VB, GLuint passno);
+
+/*
+ * Texture
+ */
+void sis_validate_texture (GLcontext * ctx);
+
+void sis_TexEnv( GLcontext *ctx, GLenum target, GLenum pname,
+ const GLfloat *param );
+
+void sis_TexImage (GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj, GLint level,
+ GLint internalFormat,
+ const struct gl_texture_image *image);
+
+void sis_TexSubImage (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 sis_TexParameter (GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat * params);
+
+void sis_BindTexture (GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj);
+
+void sis_DeleteTexture (GLcontext * ctx, struct gl_texture_object *tObj);
+
+void sis_UpdateTexturePalette (GLcontext * ctx,
+ struct gl_texture_object *tObj);
+
+void sis_UseGlobalTexturePalette (GLcontext * ctx, GLboolean state);
+
+void sis_ActiveTexture (GLcontext * ctx, GLuint texUnitNumber);
+
+GLboolean sis_IsTextureResident (GLcontext * ctx,
+ struct gl_texture_object *t);
+void sis_PrioritizeTexture (GLcontext * ctx,
+ struct gl_texture_object *t, GLclampf priority);
+
+/*
+ * Optimization
+ */
+void sis_RegisterVB (struct vertex_buffer *VB);
+void sis_UnregisterVB (struct vertex_buffer *VB);
+void sis_ResetVB (struct vertex_buffer *VB);
+void sis_ResetCvaVB (struct vertex_buffer *VB, GLuint stages);
+GLuint sis_RegisterPipelineStages (struct gl_pipeline_stage *out,
+ const struct gl_pipeline_stage *in,
+ GLuint nr);
+GLboolean sis_BuildPrecalcPipeline (GLcontext * ctx);
+GLboolean sis_BuildEltPipeline (GLcontext * ctx);
+void sis_OptimizePrecalcPipeline (GLcontext * ctx, struct gl_pipeline *pipe);
+void sis_OptimizeImmediatePipeline (GLcontext * ctx,
+ struct gl_pipeline *pipe);
+
+/*
+ * State-Change
+ */
+void sis_AlphaFunc (GLcontext * ctx, GLenum func, GLclampf ref);
+void sis_BlendEquation (GLcontext * ctx, GLenum mode);
+void sis_BlendFunc (GLcontext * ctx, GLenum sfactor, GLenum dfactor);
+void sis_BlendFuncSeparate (GLcontext * ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA);
+void sis_ClearDepth (GLcontext * ctx, GLclampd d);
+void sis_CullFace (GLcontext * ctx, GLenum mode);
+void sis_FrontFace (GLcontext * ctx, GLenum mode);
+void sis_DepthFunc (GLcontext * ctx, GLenum func);
+void sis_DepthMask (GLcontext * ctx, GLboolean flag);
+void sis_DepthRange (GLcontext * ctx, GLclampd nearval, GLclampd farval);
+void sis_Enable (GLcontext * ctx, GLenum cap, GLboolean state);
+void sis_Fogfv (GLcontext * ctx, GLenum pname, const GLfloat * params);
+void sis_Hint (GLcontext * ctx, GLenum target, GLenum mode);
+void sis_Lightfv (GLcontext * ctx, GLenum light,
+ GLenum pname, const GLfloat * params, GLint nparams);
+void sis_LightModelfv (GLcontext * ctx, GLenum pname, const GLfloat * params);
+void sis_PolygonMode (GLcontext * ctx, GLenum face, GLenum mode);
+void sis_Scissor (GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+void sis_ShadeModel (GLcontext * ctx, GLenum mode);
+void sis_ClearStencil (GLcontext * ctx, GLint s);
+void sis_StencilFunc (GLcontext * ctx, GLenum func, GLint ref, GLuint mask);
+void sis_StencilMask (GLcontext * ctx, GLuint mask);
+void sis_StencilOp (GLcontext * ctx, GLenum fail, GLenum zfail, GLenum zpass);
+void sis_Viewport (GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+
+/*
+ * Buffer Allocation
+ */
+void sis_alloc_z_stencil_buffer (GLcontext * ctx);
+void sis_free_z_stencil_buffer (XMesaBuffer buf);
+void sis_alloc_back_image (GLcontext * ctx, XMesaImage *image, void **free,
+ ENGPACKET *packet);
+void sis_free_back_image (XMesaBuffer buf, XMesaImage *image, void *free);
+void sis_alloc_texture_image (GLcontext * ctx, GLtextureImage * image);
+void sis_free_texture_image (GLtextureImage * image);
+
+/*
+ * Raster-Function Picker
+ */
+void sis_set_render_func (GLcontext * ctx);
+
+/*
+ * VB Rendering Function
+ */
+void sis_init_vbrender (void);
+void sis_set_render_vb_tabs (GLcontext * ctx);
+
+/*
+ * Local
+ */
+void set_color_pattern (__GLSiScontext * hwcx, GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha);
+
+void set_z_stencil_pattern (__GLSiScontext * hwcx, GLclampd z, int stencil);
+
+void sis_init_driver (GLcontext * ctx);
+void sis_sw_init_driver (GLcontext * ctx);
+void sis_sw_set_zfuncs_static (GLcontext * ctx);
+
+void WaitEngIdle (__GLSiScontext * hwcx);
+void Wait2DEngIdle (__GLSiScontext * hwcx);
+
+void sis_set_buffer_static (GLcontext * ctx);
+void sis_set_render_pos(GLcontext * ctx, GLubyte *base, GLuint pitch);
+
+/*
+ * X window system Information
+ */
+#define sis_is_window(xmesa) (!((xmesa)->xm_buffer->pixmap_flag))
+GLboolean sis_get_clip_rects (XMesaContext xmesa, BoxPtr * ppExtents,
+ int *pCount);
+void *sis_get_drawable_pos (XMesaContext xmesa);
+void sis_get_drawable_origin (XMesaContext xmesa, GLuint * x, GLuint * y);
+void sis_get_drawable_size (XMesaContext xmesa, GLuint * w, GLuint * h);
+void sis_get_drawable_box (XMesaContext xmesa, BoxPtr pBox);
+
+/* GLX */
+void SiSCreateContext (XMesaContext xmesa);
+void SiSDestroyContext (XMesaContext xmesa);
+void sis_swap_buffers (XMesaBuffer b);
+void SiSDestroyBuffer (XMesaBuffer buf);
+
+/* Profile */
+#ifndef SIS_DEBUG
+# define SIS_VERBOSE 0
+#else
+extern int SIS_VERBOSE;
+#endif
+
+enum _sis_verbose {
+ VERBOSE_SIS_BUFFER = 0x1,
+ VERBOSE_SIS_MEMORY = 0x2
+};
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_reg.h b/xc/lib/GL/mesa/src/drv/sis/sis_reg.h
new file mode 100644
index 000000000..d9b408b42
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_reg.h
@@ -0,0 +1,948 @@
+#ifndef _sis_reg_h_
+#define _sis_reg_h_
+
+/*
+ * Define All the Register Address of 6327
+ */
+#define REG_3D_TSFSa 0x8800
+#define REG_3D_TSZa 0x8804
+#define REG_3D_TSXa 0x8808
+#define REG_3D_TSYa 0x880C
+#define REG_3D_TSARGBa 0x8810
+#define REG_3D_TSWGa 0x8814
+#define REG_3D_TSUAa 0x8818
+#define REG_3D_TSVAa 0x881C
+#define REG_3D_TSUBa 0x8820
+#define REG_3D_TSVBa 0x8824
+#define REG_3D_TSUCa 0x8828
+#define REG_3D_TSVCa 0x882C
+
+#define REG_3D_TSFSb 0x8830
+#define REG_3D_TSZb 0x8834
+#define REG_3D_TSXb 0x8838
+#define REG_3D_TSYb 0x883C
+#define REG_3D_TSARGBb 0x8840
+#define REG_3D_TSWGb 0x8844
+#define REG_3D_TSUAb 0x8848
+#define REG_3D_TSVAb 0x884C
+#define REG_3D_TSUBb 0x8850
+#define REG_3D_TSVBb 0x8854
+#define REG_3D_TSUCb 0x8858
+#define REG_3D_TSVCb 0x885C
+
+#define REG_3D_TSFSc 0x8860
+#define REG_3D_TSZc 0x8864
+#define REG_3D_TSXc 0x8868
+#define REG_3D_TSYc 0x886C
+#define REG_3D_TSARGBc 0x8870
+#define REG_3D_TSWGc 0x8874
+#define REG_3D_TSUAc 0x8878
+#define REG_3D_TSVAc 0x887C
+#define REG_3D_TSUBc 0x8880
+#define REG_3D_TSVBc 0x8884
+#define REG_3D_TSUCc 0x8888
+#define REG_3D_TSVCc 0x888C
+
+/*
+ * REG_3D_AGPCmdSetting (89e4h-89f7)
+ */
+#define REG_3D_AGPCmBase 0x89E4
+#define REG_3D_AGPRmDwNum 0x89E8
+#define REG_3D_AGPTtDwNum 0x89EC
+#define REG_3D_AGPCmFire 0x89F0
+
+#define REG_3D_ParsingSet 0x89F4
+#define REG_3D_PrimitiveSet 0x89F8
+#define REG_3D_ShadeMode 0x89F8
+#define REG_3D_EngineFire 0x89FC
+#define REG_3D_EngineStatus 0x89FC
+#define REG_3D_TEnable 0x8A00
+#define REG_3D_TEnable2 0x8A04
+
+#define REG_3D_ZSet 0x8A08
+#define REG_3D_ZBias 0x8A0C
+#define REG_3D_ZStWriteMask 0x8A10
+
+#define REG_3D_ZAddress 0x8A14
+#define REG_3D_AlphaSet 0x8A18
+#define REG_3D_AlphaAddress 0x8A1C
+#define REG_3D_DstSet 0x8A20
+#define REG_3D_DstAlphaWriteMask 0x8A24
+
+#define REG_3D_DstAddress 0x8A28
+
+#define REG_3D_LinePattern 0x8A2C
+
+#define REG_3D_FogSet 0x8A30
+
+#define REG_3D_FogFarDistance 0x8A34
+#define REG_3D_FogInverseDistance 0x8A38
+#define REG_3D_FogFactorDensity 0x8A3C
+
+#define REG_3D_StencilSet 0x8A44
+#define REG_3D_StencilSet2 0x8A48
+#define REG_3D_StencilAddress 0x8A4C
+
+#define REG_3D_DstBlendMode 0x8A50
+#define REG_3D_SrcBlendMode 0x8A50
+#define REG_3D_ClipTopBottom 0x8A54
+#define REG_3D_ClipLeftRight 0x8A58
+
+#define REG_3D_Brightness 0x8A5C
+
+#define REG_3D_BumpMapSet 0x8A68
+#define REG_3D_BumpMapAddress 0x8A6C
+#define REG_3D_BumpMapPitch 0x8A70
+#define REG_3D_BumpMapMatrix0 0x8A74
+#define REG_3D_BumpMapMatrix1 0x8A78
+
+/*
+ * Define the Texture Register Address of 6326
+ */
+#define REG_3D_TextureSet 0x8A7C
+#define REG_3D_TextureWidthHeight 0x8A7C
+#define REG_3D_TextureMip 0x8A80
+
+#define REG_3D_TextureTransparencyColorHigh 0x8A84
+#define REG_3D_TextureTransparencyColorLow 0x8A88
+#define REG_3D_TextureBorderColor 0x8A8C
+#define REG_3D_TextureAddress0 0x8A90
+#define REG_3D_TextureAddress1 0x8A94
+#define REG_3D_TextureAddress2 0x8A98
+#define REG_3D_TextureAddress3 0x8A9C
+#define REG_3D_TextureAddress4 0x8AA0
+#define REG_3D_TextureAddress5 0x8AA4
+#define REG_3D_TextureAddress6 0x8AA8
+#define REG_3D_TextureAddress7 0x8AAC
+#define REG_3D_TextureAddress8 0x8AB0
+#define REG_3D_TextureAddress9 0x8AB4
+#define REG_3D_TextureAddress10 0x8AB8
+#define REG_3D_TextureAddress11 0x8ABC
+#define REG_3D_TexturePitch0 0x8AC0
+#define REG_3D_TexturePitch1 0x8AC0
+#define REG_3D_TexturePitch2 0x8AC4
+#define REG_3D_TexturePitch3 0x8AC4
+#define REG_3D_TexturePitch4 0x8AC8
+#define REG_3D_TexturePitch5 0x8AC8
+#define REG_3D_TexturePitch6 0x8ACC
+#define REG_3D_TexturePitch7 0x8ACC
+#define REG_3D_TexturePitch8 0x8AD0
+#define REG_3D_TexturePitch9 0x8AD0
+#define REG_3D_TexturePitch10 0x8AD4
+
+#define REG_3D_Texture1Set 0x8ADC
+#define REG_3D_Texture1WidthHeight 0x8ADC
+#define REG_3D_Texture1Mip 0x8AE0
+
+#define REG_3D_Texture1TransparencyColorHigh 0x8AE4
+#define REG_3D_Texture1TransparencyColorLow 0x8AE8
+#define REG_3D_Texture1BorderColor 0x8AEC
+#define REG_3D_Texture1Address0 0x8AF0
+#define REG_3D_Texture1Address1 0x8AF4
+#define REG_3D_Texture1Address2 0x8AF8
+#define REG_3D_Texture1Address3 0x8AFC
+#define REG_3D_Texture1Address4 0x8B00
+#define REG_3D_Texture1Address5 0x8B04
+#define REG_3D_Texture1Address6 0x8B08
+#define REG_3D_Texture1Address7 0x8B0C
+#define REG_3D_Texture1Address8 0x8B10
+#define REG_3D_Texture1Address9 0x8B14
+#define REG_3D_Texture1Address10 0x8B18
+#define REG_3D_Texture1Address11 0x8B1C
+#define REG_3D_Texture1Pitch0 0x8B20
+#define REG_3D_Texture1Pitch1 0x8B20
+#define REG_3D_Texture1Pitch2 0x8B24
+#define REG_3D_Texture1Pitch3 0x8B24
+#define REG_3D_Texture1Pitch4 0x8B28
+#define REG_3D_Texture1Pitch5 0x8B28
+#define REG_3D_Texture1Pitch6 0x8B2C
+#define REG_3D_Texture1Pitch7 0x8B2C
+#define REG_3D_Texture1Pitch8 0x8B30
+#define REG_3D_Texture1Pitch9 0x8B30
+#define REG_3D_Texture1Pitch10 0x8B34
+
+#define REG_3D_TextureBlendFactor 0x8B3C
+#define REG_3D_TextureColorBlendSet0 0x8B40
+#define REG_3D_TextureColorBlendSet1 0x8B44
+#define REG_3D_TextureAlphaBlendSet0 0x8B48
+#define REG_3D_TextureAlphaBlendSet1 0x8B4C
+/*
+ * Define the End of Primitive List of 6326
+ */
+#define REG_3D_EndPrimitiveList 0X8B50
+
+
+/*
+ * Define the Stipple Register Address of 6326
+ */
+#define REG_3D_Stipple0 0X8B60
+
+#define REG_3D_TexturePalette 0x8C00
+
+
+/*
+ * Define All the Register Address of 6327
+ */
+#define X_REG_3D_TSFSa 0
+#define X_REG_3D_TSZa 4
+#define X_REG_3D_TSXa 8
+#define X_REG_3D_TSYa 12
+#define X_REG_3D_TSARGBa 16
+#define X_REG_3D_TSWGa 20
+#define X_REG_3D_TSUAa 24
+#define X_REG_3D_TSVAa 28
+#define X_REG_3D_TSUBa 32
+#define X_REG_3D_TSVBa 36
+#define X_REG_3D_TSUCa 40
+#define X_REG_3D_TSVCa 44
+
+#define X_REG_3D_TSFSb 48
+#define X_REG_3D_TSZb 52
+#define X_REG_3D_TSXb 56
+#define X_REG_3D_TSYb 60
+#define X_REG_3D_TSARGBb 64
+#define X_REG_3D_TSWGb 68
+#define X_REG_3D_TSUAb 72
+#define X_REG_3D_TSVAb 76
+#define X_REG_3D_TSUBb 80
+#define X_REG_3D_TSVBb 84
+#define X_REG_3D_TSUCb 88
+#define X_REG_3D_TSVCb 92
+
+#define X_REG_3D_TSFSc 96
+#define X_REG_3D_TSZc 100
+#define X_REG_3D_TSXc 104
+#define X_REG_3D_TSYc 108
+#define X_REG_3D_TSARGBc 112
+#define X_REG_3D_TSWGc 116
+#define X_REG_3D_TSUAc 120
+#define X_REG_3D_TSVAc 124
+#define X_REG_3D_TSUBc 128
+#define X_REG_3D_TSVBc 132
+#define X_REG_3D_TSUCc 136
+#define X_REG_3D_TSVCc 140
+
+#define X_REG_3D_ParsingSet 176
+#define X_REG_3D_PrimitiveSet 180
+#define X_REG_3D_ShadeMode 180
+#define X_REG_3D_EngineFire 184
+#define X_REG_3D_EngineStatus 184
+#define X_REG_3D_TEnable 188
+#define X_REG_3D_TEnable2 192
+
+#define X_REG_3D_ZSet 196
+#define X_REG_3D_ZBias 200
+#define X_REG_3D_ZStWriteMask 204
+
+#define X_REG_3D_ZAddress 208
+#define X_REG_3D_AlphaSet 212
+#define X_REG_3D_AlphaAddress 216
+#define X_REG_3D_DstSet 220
+#define X_REG_3D_DstAlphaWriteMask 224
+
+#define X_REG_3D_DstAddress 228
+
+#define X_REG_3D_LinePattern 232
+
+#define X_REG_3D_FogSet 236
+#define X_REG_3D_FogFarDistance 240
+#define X_REG_3D_FogInverseDistance 244
+#define X_REG_3D_FogFactorDensity 248
+
+#define X_REG_3D_StencilSet 256
+#define X_REG_3D_StencilSet2 260
+#define X_REG_3D_StencilAddress 264
+
+#define X_REG_3D_DstBlendMode 268
+#define X_REG_3D_SrcBlendMode 268
+#define X_REG_3D_ClipTopBottom 272
+#define X_REG_3D_ClipLeftRight 276
+#define X_REG_3D_Brightness 280
+
+#define X_REG_3D_BumpMapSet 292
+#define X_REG_3D_BumpMapAddress 296
+#define X_REG_3D_BumpMapPitch 300
+#define X_REG_3D_BumpMapMatrix0 304
+#define X_REG_3D_BumpMapMatrix1 308
+
+
+/*
+ * Define the Texture Register Address of 6327
+ */
+#define X_REG_3D_Texture0Set 312
+#define X_REG_3D_Texture0WidthHeight 312
+#define X_REG_3D_Texture0Set2 316
+
+#define X_REG_3D_Texture0TransparencyColorHigh 320
+#define X_REG_3D_Texture0TransparencyColorLow 324
+#define X_REG_3D_Texture0BorderColor 328
+#define X_REG_3D_Texture0Address0 332
+#define X_REG_3D_Texture0Address1 336
+#define X_REG_3D_Texture0Address2 340
+#define X_REG_3D_Texture0Address3 344
+#define X_REG_3D_Texture0Address4 348
+#define X_REG_3D_Texture0Address5 352
+#define X_REG_3D_Texture0Address6 356
+#define X_REG_3D_Texture0Address7 360
+#define X_REG_3D_Texture0Address8 364
+#define X_REG_3D_Texture0Address9 368
+#define X_REG_3D_Texture0Address10 372
+#define X_REG_3D_Texture0Address11 376
+#define X_REG_3D_Texture0Pitch0 380
+#define X_REG_3D_Texture0Pitch1 380
+#define X_REG_3D_Texture0Pitch2 384
+#define X_REG_3D_Texture0Pitch3 384
+#define X_REG_3D_Texture0Pitch4 388
+#define X_REG_3D_Texture0Pitch5 388
+#define X_REG_3D_Texture0Pitch6 392
+#define X_REG_3D_Texture0Pitch7 392
+#define X_REG_3D_Texture0Pitch8 396
+#define X_REG_3D_Texture0Pitch9 396
+#define X_REG_3D_Texture0Pitch10 400
+
+#define X_REG_3D_Texture1Set 408
+#define X_REG_3D_Texture1WidthHeight 408
+#define X_REG_3D_Texture1Set2 412
+
+#define X_REG_3D_Texture1TransparencyColorHigh 416
+#define X_REG_3D_Texture1TransparencyColorLow 420
+#define X_REG_3D_Texture1BorderColor 424
+#define X_REG_3D_Texture1Address0 428
+#define X_REG_3D_Texture1Address1 432
+#define X_REG_3D_Texture1Address2 436
+#define X_REG_3D_Texture1Address3 440
+#define X_REG_3D_Texture1Address4 444
+#define X_REG_3D_Texture1Address5 448
+#define X_REG_3D_Texture1Address6 452
+#define X_REG_3D_Texture1Address7 456
+#define X_REG_3D_Texture1Address8 460
+#define X_REG_3D_Texture1Address9 464
+#define X_REG_3D_Texture1Address10 468
+#define X_REG_3D_Texture1Address11 472
+#define X_REG_3D_Texture1Pitch0 476
+#define X_REG_3D_Texture1Pitch1 476
+#define X_REG_3D_Texture1Pitch2 480
+#define X_REG_3D_Texture1Pitch3 480
+#define X_REG_3D_Texture1Pitch4 484
+#define X_REG_3D_Texture1Pitch5 484
+#define X_REG_3D_Texture1Pitch6 488
+#define X_REG_3D_Texture1Pitch7 488
+#define X_REG_3D_Texture1Pitch8 492
+#define X_REG_3D_Texture1Pitch9 492
+#define X_REG_3D_Texture1Pitch10 496
+
+#define X_REG_3D_TextureBlendFactor 504
+#define X_REG_3D_TextureColorBlendSet0 508
+#define X_REG_3D_TextureColorBlendSet1 512
+#define X_REG_3D_TextureAlphaBlendSet0 516
+#define X_REG_3D_TextureAlphaBlendSet1 520
+
+/*
+ * Define the End of Primitive List of 6326
+ */
+#define X_REG_3D_EndPrimitiveList 524
+
+
+/*
+ * Define the Stipple Register Address of 6326
+ */
+#define X_REG_3D_Stipple0 540
+
+#define X_REG_3D_TexturePalette 1520
+
+
+/*
+ * REG_3D_ParsingSet -- Define Parsing Mask (89F4h-89F7h)
+ */
+#define MASK_VertexDWSize 0xF0000000
+#define MASK_VertexDataFormat 0x0FFF0000
+#define MASK_PsVertex_HAS_RHW 0x08000000
+#define MASK_PsVertex_HAS_NORMALXYZ 0x04000000
+#define MASK_PsVertex_HAS_DIFFUSE 0x02000000
+#define MASK_PsVertex_HAS_SPECULAR 0x01000000
+#define MASK_PsUVSet 0x00FF0000
+#define MASK_PsVertex_HAS_1SetUV 0x00800000
+#define MASK_PsVertex_HAS_2SetUV 0x00C00000
+#define MASK_PsVertex_HAS_3SetUV 0x00E00000
+#define MASK_PsVertex_HAS_UVSet1 0x00800000
+#define MASK_PsVertex_HAS_UVSet2 0x00400000
+#define MASK_PsVertex_HAS_UVSet3 0x00200000
+#define MASK_PsCullDirection_CCW 0x00008000
+#define MASK_PsShadingMode 0x00007000
+#define MASK_PsTextureFrom 0x000003F0
+#define MASK_PsTexture0FromA 0x00000000
+#define MASK_PsTexture1FromA 0x00000000
+#define MASK_PsTexture1FromB 0x00000040
+#define MASK_PsBumpTextureFromA 0x00000000
+#define MASK_PsBumpTextureFromB 0x00000010
+#define MASK_PsBumpTextureFromC 0x00000020
+#define MASK_PsDataType 0x0000000F
+#define MASK_PsPointList 0x00000000
+#define MASK_PsLineList 0x00000004
+#define MASK_PsLineStrip 0x00000005
+#define MASK_PsTriangleList 0x00000008
+#define MASK_PsTriangleStrip 0x00000009
+#define MASK_PsTriangleFan 0x0000000A
+/*
+ * REG_3D_PrimitiveSet -- Define Fire Primitive Mask (89F8h-89FBh)
+ */
+#define MASK_DrawPrimitiveCommand 0x00000007
+#define MASK_SetFirePosition 0x00001F00
+#define MASK_BumpTextureFrom 0x00030000
+#define MASK_Texture1From 0x000C0000
+#define MASK_Texture0From 0x00300000
+#define MASK_ShadingMode 0x07000000
+#define MASK_CullDirection 0x08000000
+/*
+ * Define Command Queue Length Mask (89FCh-89FF)
+ */
+#define MASK_CmdQueueLen 0x0FFF0000
+
+/*
+ * REG_3D_TEnable -- Define Capility Enable Mask (8A00h-8A03h)
+ */
+#define MASK_DitherEnable 0x00000001
+#define MASK_BlendEnable 0x00000002
+#define MASK_FogTestEnable 0x00000004
+#define MASK_FogEnable 0x00000008
+#define MASK_SpecularEnable 0x00000010
+#define MASK_FogPerspectiveEnable 0x00000020
+#define MASK_TextureCacheClear 0x00000040
+#define MASK_TextureCacheEnable 0x00000080
+#define MASK_BumpMapEnable 0x00000100
+#define MASK_TexturePerspectiveEnable 0x00000200
+#define MASK_TextureEnable 0x00000400
+#define MASK_CullEnable 0x00000800
+#define MASK_TextureNumUsed 0x0000F000
+#define MASK_AlphaBufferEnable 0x00010000
+#define MASK_AlphaTestEnable 0x00020000
+#define MASK_AlphaWriteEnable 0x00040000
+#define MASK_ZTestEnable 0x00080000
+#define MASK_ZWriteEnable 0x00100000
+#define MASK_StencilBufferEnable 0x00200000
+#define MASK_StencilTestEnable 0x00400000
+#define MASK_StencilWriteEnable 0x00800000
+#define MASK_Texture0TransparencyEnable 0x01000000
+#define MASK_Texture1TransparencyEnable 0x02000000
+#define MASK_TextureAWrapUCorrection 0x04000000
+#define MASK_TextureAWrapVCorrection 0x08000000
+#define MASK_TextureBWrapUCorrection 0x10000000
+#define MASK_TextureBWrapVCorrection 0x20000000
+#define MASK_TextureCWrapUCorrection 0x40000000
+#define MASK_TextureCWrapVCorrection 0x80000000
+
+
+
+/*
+ * REG_3D_TEnable2 -- Define Capility Enable Mask2 (8A04h-8A07h)
+ */
+#define MASK_Texture0BlockTextureEnable 0x00000001
+#define MASK_Texture1BlockTextureEnable 0x00000002
+#define MASK_Texture0AnisotropicEnable 0x00000010
+#define MASK_Texture1AnisotropicEnable 0x00000020
+#define MASK_TextureMipmapBiasEnable 0x00000040
+#define MASK_LinePatternEnable 0x00000100
+#define MASK_StippleAlphaEnable 0x00000200
+#define MASK_StippleEnable 0x00000400
+#define MASK_AntiAliasEnable 0x00000800
+#define MASK_ZMaskWriteEnable 0x00001000
+#define MASK_StencilMaskWriteEnable 0x00002000
+#define MASK_AlphaMaskWriteEnable 0x00004000
+#define MASK_ColorMaskWriteEnable 0x00008000
+#define MASK_ZCacheClear 0x00010000
+#define MASK_ZCacheEnable 0x00020000
+#define MASK_StencilCacheClear 0x00040000
+#define MASK_StencilCacheEnable 0x00080000
+#define MASK_AlphaCacheClear 0x00100000
+#define MASK_AlphaCacheEnable 0x00200000
+#define MASK_ColorCacheClear 0x00400000
+#define MASK_ColorCacheEnable 0x00800000
+
+/*
+ * REG_3D_ZSet -- Define Z Buffer Setting Mask (8A08h-8A0Bh)
+ */
+#define MASK_ZBufferPitch 0x00000FFF
+#define MASK_ZTestMode 0x00070000
+#define MASK_ZBufferInSystem 0x00080000
+#define MASK_ZBufferFormat 0x01F00000
+
+/*
+ * REG_3D_ZBias -- Define Z Buffer Setting Mask (8A0Ch-8A0Fh)
+ */
+#define MASK_ZBias 0xFFFFFFFF
+
+/*
+ * REG_3D_ZStWriteMask -- Define Z and Stencil Buffer Mask (8A10h-8A13h)
+ */
+#define MASK_ZWriteMask 0x00FFFFFF
+
+/*
+ * REG_3D_ZAddress -- Define Z Buffer Base Address(8A14h-8A17h)
+ */
+#define MASK_ZAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_AlphaSet -- Define Alpha Buffer Setting Mask (8A18h-8A1Bh)
+ */
+#define MASK_AlphaBufferPitch 0x000003FF
+#define MASK_AlphaRefValue 0x00FF0000
+#define MASK_AlphaTestMode 0x07000000
+#define MASK_AlphaBufferInSystem 0x08000000
+#define MASK_AlphaBufferFormat 0x30000000
+
+/*
+ * REG_3D_AlphaAddress -- Define Alpha Buffer Base Address(8A1Ch-8A1Fh)
+ */
+#define MASK_AlphaAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_DstSet -- Define Destination Buffer Setting Mask (8A20h-8A23h)
+ */
+#define MASK_DstBufferPitch 0x00000FFF
+#define MASK_DstBufferFormat 0x000F0000
+#define MASK_DstBufferBitDepth 0x00300000
+#define MASK_DstBufferRgbOrder 0x00400000
+#define MASK_DstBufferInSystem 0x00800000
+#define MASK_Dst7BitFormat 0x007F0000
+#define MASK_ROP2 0x0F000000
+
+/*
+ * REG_3D_DstAlphaWriteMask -- Define Destination/Alpha Buffer Write Mask (8A24h-8A27h)
+ */
+#define MASK_ColorWriteMask 0x00FFFFFF
+#define MASK_AlphaWriteMask 0xFF000000
+
+/*
+ * REG_3D_DstAddress -- Define Destination Buffer Base Address(8A1Ch-8A1Fh)
+ */
+#define MASK_DstAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_LinePattern -- Define Line Pattern (8A2Ch-8A2Fh)
+ */
+#define MASK_LinePatternRepeatFactor 0x00007FFF
+#define MASK_LinePatternLastPixelFlag 0x00008000
+#define MASK_LinePattern 0xFFFF0000
+
+/*
+ * REG_3D_FogSet -- Define Fog Mask (8A30h-8A33h)
+ */
+#define MASK_FogColor 0x00FFFFFF
+#define MASK_FogMode 0x07000000
+#define MASK_FogZLookup 0x08000000
+
+/*
+ * REG_3D_FogStartEnd -- Define Fog Start End Setting (8A34h-8A37h)
+ */
+#define MASK_FogFarDistance 0x0007FFFF
+
+/*
+ * REG_3D_FogStartEnd -- Define Fog End Setting (8A38h-8A3Bh)
+ */
+#define MASK_FogInvFarDistance 0x0007FFFF
+
+#define MASK_FogDensity 0x0003FFFF
+#define MASK_FogFactor 0xFF000000
+
+#define MASK_StencilMaskValue 0x000000FF
+#define MASK_StencilReferenceValue 0x0000FF00
+#define MASK_StencilTestMode 0x07000000
+#define MASK_StencilBufferInSystem 0x08000000
+#define MASK_StencilFormat 0x30000000
+
+#define MASK_StencilMode_ALWAYS 0x07000000
+#define MASK_StencilBufferPitch 0x00000FFF
+#define MASK_StencilZPassOp 0x00007000
+#define MASK_StencilZFailOp 0x00070000
+#define MASK_StencilFailOp 0x00700000
+#define MASK_StencilWriteMask 0xFF000000
+
+#define MASK_StencilZPassOp_REPLACE 0x00002000
+#define MASK_StencilZFailOp_REPLACE 0x00020000
+#define MASK_StencilFailOp_REPLACE 0x00200000
+#define MASK_StencilAddress 0xFFFFFFFF
+
+#define MASK_SrcBlendMode 0x0000000F
+#define MASK_DstBlendMode 0x000000F0
+#define MASK_DSTBLEND_ZERO 0x00000000
+#define MASK_DSTBLEND_ONE 0x00000010
+#define MASK_DSTBLEND_SRC_COLOR 0x00000020
+#define MASK_DSTBLEND_INV_SRC_COLOR 0x00000030
+#define MASK_DSTBLEND_SRC_ALPHA 0x00000040
+#define MASK_DSTBLEND_INV_SRC_ALPHA 0x00000050
+#define MASK_DSTBLEND_DST_ALPHA 0x00000060
+#define MASK_DSTBLEND_INV_DST_ALPHA 0x00000070
+#define MASK_DSTBLEND_DST_COLOR 0x00000080
+#define MASK_DSTBLEND_INV_DST_COLOR 0x00000090
+#define MASK_DSTBLEND_SRC_ALPHA_SAT 0x000000A0
+
+#define MASK_SRCBLEND_ZERO 0x00000000
+#define MASK_SRCBLEND_ONE 0x00000001
+#define MASK_SRCBLEND_SRC_COLOR 0x00000002
+#define MASK_SRCBLEND_INV_SRC_COLOR 0x00000003
+#define MASK_SRCBLEND_SRC_ALPHA 0x00000004
+#define MASK_SRCBLEND_INV_SRC_ALPHA 0x00000005
+#define MASK_SRCBLEND_DST_ALPHA 0x00000006
+#define MASK_SRCBLEND_INV_DST_ALPHA 0x00000007
+#define MASK_SRCBLEND_DST_COLOR 0x00000008
+#define MASK_SRCBLEND_INV_DST_COLOR 0x00000009
+#define MASK_SRCBLEND_SRC_ALPHA_SAT 0x0000000A
+#define MASK_SRCBLEND_BOTH_SRC_ALPHA 0x0000000B
+#define MASK_SRCBLEND_BOTH_INV_SRC_ALPHA 0x0000000C
+
+#define MASK_BottomClip 0x00001FFF
+#define MASK_TopClip 0x03FFE000
+
+#define MASK_RightClip 0x00001FFF
+#define MASK_LeftClip 0x03FFE000
+
+#define MASK_BMMemoryInSystem 0x00000080
+#define MASK_BMHeight 0x00000F00
+#define MASK_BMWidth 0x0000F000
+#define MASK_BMFilter 0x00010000
+#define MASK_BMMappingMode 0x007E0000
+#define MASK_BMFormat 0x07800000
+#define MASK_BMTxBumpmap 0x08000000
+
+#define MASK_BMAddress 0xFFFFFFFC
+
+#define MASK_BMOffset 0xFF800000
+#define MASK_BMScale 0x007FE000
+#define MASK_BMPitch 0x00001FFF
+
+#define MASK_BMMatrix00 0x000007FF
+#define MASK_BMMatrix01 0x07FF0000
+#define MASK_BMMatrix10 0x000007FF
+#define MASK_BMMatrix11 0x07FF0000
+
+#define MASK_TextureHeight 0x0000000F
+#define MASK_TextureWidth 0x000000F0
+#define MASK_TextureLevel 0x00000F00
+#define MASK_TextureSignYUVFormat 0x00001000
+#define MASK_TextureMappingMode 0x00FF0000
+#define MASK_TextureWrapU 0x00010000
+#define MASK_TextureWrapV 0x00020000
+#define MASK_TextureMirrorU 0x00040000
+#define MASK_TextureMirrorV 0x00080000
+#define MASK_TextureClampU 0x00100000
+#define MASK_TextureClampV 0x00200000
+#define MASK_TextureBorderU 0x00400000
+#define MASK_TextureBorderV 0x00800000
+#define MASK_TextureFormat 0xFF000000
+#define MASK_TextureBitDepth 0x70000000
+#define MASK_TextureRgbOrder 0x80000000
+
+#define MASK_TextureAnisotropyRatio 0x0000000F
+#define MASK_TextureMipmapLodBias 0x00003FF0
+#define MASK_TextureFilterMin 0x0001C000
+#define MASK_TextureFilterMag 0x00020000
+#define MASK_TextureFilter 0x0003C000
+#define MASK_TextureLevelInSystem 0x3FFC0000
+#define MASK_TextureLevel0InSystem 0x00040000
+#define MASK_TextureBlockLength 0xF0000000
+
+#define MASK_TextureTransparencyColorHighB 0x000000FF
+#define MASK_TextureTransparencyColorHighG 0x0000FF00
+#define MASK_TextureTransparencyColorHighR 0x00FF0000
+#define MASK_TextureAlphaTransparencyMode 0x08000000
+
+#define MASK_TextureTransparencyColorLowB 0x000000FF
+#define MASK_TextureTransparencyColorLowG 0x0000FF00
+#define MASK_TextureTransparencyColorLowR 0x00FF0000
+#define MASK_TextureBlockHeight 0x07000000
+#define MASK_TextureBlockWidth 0x70000000
+
+#define MASK_TextureBorderColorB 0x000000FF
+#define MASK_TextureBorderColorG 0x0000FF00
+#define MASK_TextureBorderColorR 0x00FF0000
+#define MASK_TextureBorderColorA 0xFF000000
+
+#define MASK_TexturePitchOdd 0x000003FF
+#define MASK_TexturePitchEven 0x03FF0000
+#define SHIFT_TexturePitchEven 16
+
+#define MASK_TextureRealInSystem 0x00000001
+#define MASK_TextureDowngrade 0x00000002
+
+#define OP_3D_POINT_DRAW 0x00000000
+#define OP_3D_LINE_DRAW 0x00000001
+#define OP_3D_TRIANGLE_DRAW 0x00000002
+
+#define OP_3D_DIRECTION_RIGHT 0x00000000
+#define OP_3D_DIRECTION_LEFT 0x00000100
+#define OP_3D_DIRECTION_HORIZONTAL 0x00000000
+#define OP_3D_DIRECTION_VERTICAL 0x00000100
+
+#define OP_3D_FIRE_TFIRE 0x00000000
+#define OP_3D_FIRE_TSARGBa 0x00000100
+#define OP_3D_FIRE_TSWa 0x00000200
+#define OP_3D_FIRE_TSVAa 0x00000300
+#define OP_3D_FIRE_TSVBa 0x00000400
+#define OP_3D_FIRE_TSVCa 0x00000500
+
+#define OP_3D_FIRE_TSARGBb 0x00000900
+#define OP_3D_FIRE_TSWb 0x00000a00
+#define OP_3D_FIRE_TSVAb 0x00000b00
+#define OP_3D_FIRE_TSVBb 0x00000c00
+#define OP_3D_FIRE_TSVCb 0x00000d00
+
+#define OP_3D_FIRE_TSARGBc 0x00001100
+#define OP_3D_FIRE_TSWc 0x00001200
+#define OP_3D_FIRE_TSVAc 0x00001300
+#define OP_3D_FIRE_TSVBc 0x00001400
+#define OP_3D_FIRE_TSVCc 0x00001500
+
+#define OP_3D_Texture0FromA 0x00000000
+#define OP_3D_Texture0FromB 0x00100000
+#define OP_3D_Texture0FromC 0x00200000
+#define OP_3D_Texture1FromA 0x00000000
+#define OP_3D_Texture1FromB 0x00040000
+#define OP_3D_Texture1FromC 0x00080000
+#define OP_3D_TextureBumpFromA 0x00000000
+#define OP_3D_TextureBumpFromB 0x00010000
+#define OP_3D_TextureBumpFromC 0x00020000
+
+#define SHADE_FLAT_VertexA 0x01000000
+#define SHADE_FLAT_VertexB 0x02000000
+#define SHADE_FLAT_VertexC 0x03000000
+#define SHADE_GOURAUD 0x04000000
+
+#define Z_BUFFER_FORMAT_Z16 0x00000000
+#define Z_BUFFER_FORMAT_Z16_INT 0x00100000
+#define Z_BUFFER_FORMAT_S1Z15 0x00400000
+#define Z_BUFFER_FORMAT_S1Z15_INT 0x00500000
+#define Z_BUFFER_FORMAT_Z32 0x00800000
+#define Z_BUFFER_FORMAT_S1Z31 0x00C00000
+#define Z_BUFFER_FORMAT_S2Z30 0x00D00000
+#define Z_BUFFER_FORMAT_S4Z28 0x00E00000
+#define Z_BUFFER_FORMAT_S8Z24 0x00F00000
+#define Z_BUFFER_FORMAT_FZ30 0x01800000
+#define Z_BUFFER_FORMAT_FS1Z30 0x01C00000
+#define Z_BUFFER_FORMAT_FS2Z30 0x01D00000
+#define MASK_Z_BUFFER_FORMAT 0x01F00000
+
+#define ALPHA_BUFFER_FORMAT_1 0x00000000
+#define ALPHA_BUFFER_FORMAT_2 0x10000000
+#define ALPHA_BUFFER_FORMAT_4 0x20000000
+#define ALPHA_BUFFER_FORMAT_8 0x30000000
+
+#define DST_FORMAT_RGB_555 0x00100000
+#define DST_FORMAT_RGB_565 0x00110000
+#define DST_FORMAT_ARGB_1555 0x00120000
+#define DST_FORMAT_ARGB_4444 0x00130000
+#define DST_FORMAT_ARGB_1888 0x00300000
+#define DST_FORMAT_ARGB_2888 0x00310000
+#define DST_FORMAT_ARGB_4888 0x00320000
+#define DST_FORMAT_ARGB_8888 0x00330000
+#define DST_FORMAT_ARGB_0888 0x00340000
+
+#define DST_FORMAT_BGR_555 0x00500000
+#define DST_FORMAT_BGR_565 0x00510000
+#define DST_FORMAT_ABGR_1555 0x00520000
+#define DST_FORMAT_ABGR_4444 0x00530000
+#define DST_FORMAT_ABGR_1888 0x00700000
+#define DST_FORMAT_ABGR_2888 0x00710000
+#define DST_FORMAT_ABGR_4888 0x00720000
+#define DST_FORMAT_ABGR_8888 0x00730000
+#define DST_FORMAT_ABGR_0888 0x00740000
+
+#define MASK_TEXTURE_FORMAT 0xFF000000
+
+#define TEXEL_INDEX1 0x00000000
+#define TEXEL_INDEX2 0x01000000
+#define TEXEL_INDEX4 0x02000000
+#define TEXEL_INDEX8 0x03000000
+
+#define TEXEL_INDEX1WithAlpha 0x04000000
+#define TEXEL_INDEX2WithAlpha 0x05000000
+#define TEXEL_INDEX4WithAlpha 0x06000000
+#define TEXEL_INDEX8WithAlpha 0x07000000
+
+#define TEXEL_I1 0x10000000
+#define TEXEL_I2 0x11000000
+#define TEXEL_I4 0x12000000
+#define TEXEL_I8 0x13000000
+
+#define TEXEL_DXT1 0x19000000
+#define TEXEL_DXT2 0x1A000000
+#define TEXEL_DXT3 0x1B000000
+
+#define TEXEL_YUV422 0x20000000
+#define TEXEL_YVU422 0x21000000
+#define TEXEL_UVY422 0x22000000
+#define TEXEL_VUY422 0x23000000
+#define TEXEL_YUV411 0x24000000
+
+#define TEXEL_L1 0x30000000
+#define TEXEL_L2 0x31000000
+#define TEXEL_L4 0x32000000
+#define TEXEL_L8 0x33000000
+
+#define TEXEL_AL11 0x34000000
+#define TEXEL_AL44 0x35000000
+#define TEXEL_AL26 0x37000000
+#define TEXEL_AL88 0x38000000
+
+#define TEXEL_A1 0x40000000
+#define TEXEL_A2 0x41000000
+#define TEXEL_A4 0x42000000
+#define TEXEL_A8 0x43000000
+
+#define TEXEL_RGB_332_8 0x50000000
+#define TEXEL_RGB_233_8 0x51000000
+#define TEXEL_RGB_232_8 0x52000000
+#define TEXEL_ARGB_1232_8 0x53000000
+#define TEXEL_ARGB_2222_8 0x54000000
+
+#define TEXEL_RGB_555_16 0x60000000
+#define TEXEL_RGB_565_16 0x61000000
+#define TEXEL_ARGB_1555_16 0x62000000
+#define TEXEL_ARGB_4444_16 0x63000000
+
+#define TEXEL_ARGB_1888_32 0x70000000
+#define TEXEL_ARGB_2888_32 0x71000000
+#define TEXEL_ARGB_4888_32 0x72000000
+#define TEXEL_ARGB_8888_32 0x73000000
+#define TEXEL_ARGB_0888_32 0x74000000
+
+#define TEXEL_BGR_332_8 0xD0000000
+#define TEXEL_BGR_233_8 0xD1000000
+#define TEXEL_BGR_232_8 0xD2000000
+#define TEXEL_ABGR_1232_8 0xD3000000
+#define TEXEL_ABGR_2222_8 0xD4000000
+
+#define TEXEL_BGR_555_16 0xE0000000
+#define TEXEL_BGR_565_16 0xE1000000
+#define TEXEL_ABGR_1555_16 0xE2000000
+#define TEXEL_ABGR_4444_16 0xE3000000
+
+#define TEXEL_ABGR_1888_32 0xF0000000
+#define TEXEL_ABGR_2888_32 0xF1000000
+#define TEXEL_ABGR_4888_32 0xF2000000
+#define TEXEL_ABGR_8888_32 0xF3000000
+#define TEXEL_ABGR_0888_32 0xF4000000
+
+#define TEXEL_VU88 0x00000000
+#define TEXEL_LVU655 0x00800000
+#define TEXEL_LVU888 0x01000000
+#define TEXEL_UV88 0x02000000
+#define TEXEL_LUV655 0x02800000
+#define TEXEL_LUV888 0x03000000
+
+#define FOGMODE_CHEAP 0x04000000
+#define FOGMODE_LINEAR 0x05000000
+#define FOGMODE_EXP 0x06000000
+#define FOGMODE_EXP2 0x07000000
+
+#define Z_16 0x00000000
+#define S_1_Z_15 0x00400000
+#define Z_32 0x00800000
+#define S_1_Z_31 0x00c00000
+#define S_2_Z_30 0x00d00000
+#define S_4_Z_28 0x00e00000
+#define S_8_Z_24 0x00f00000
+
+#define S_1 0x00000000
+#define S_2 0x10000000
+#define S_4 0x20000000
+#define S_8 0x30000000
+
+#define TEXTURE_FILTER_NEAREST 0x00000000
+#define TEXTURE_FILTER_LINEAR 0x00004000
+#define TEXTURE_FILTER_NEAREST_MIP_NEAREST 0x00008000
+#define TEXTURE_FILTER_NEAREST_MIP_LINEAR 0x00010000
+#define TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x0000c000
+#define TEXTURE_FILTER_LINEAR_MIP_LINEAR 0x00014000
+
+#define A_REPLACE_RGB_STAGE0 0xa1485000
+#define A_REPLACE_A_STAGE0 0xc3230000
+#define L_REPLACE__RGB_STAGE0 0xc1485000
+#define L_REPLACE__A_STAGE0 0x63230000
+#define LA_REPLACE__RGB_STAGE0 0xc1485000
+#define LA_REPLACE__A_STAGE0 0xc3230000
+#define I_REPLACE__RGB_STAGE0 0xc1485000
+#define I_REPLACE__A_STAGE0 0xc3230000
+#define RGB_REPLACE__RGB_STAGE0 0xc1485000
+#define RGB_REPLACE__A_STAGE0 0x63230000
+#define RGBA_REPLACE__RGB_STAGE0 0xc1485000
+#define RGBA_REPLACE__A_STAGE0 0xc3230000
+
+#define A_MODULATE_RGB_STAGE0 0xa1485000
+#define A_MODULATE_A_STAGE0 0x63c30000
+#define L_MODULATE__RGB_STAGE0 0xa1705000
+#define L_MODULATE__A_STAGE0 0x63230000
+#define LA_MODULATE__RGB_STAGE0 0xa1705000
+#define LA_MODULATE__A_STAGE0 0x63c30000
+#define I_MODULATE__RGB_STAGE0 0xa1705000
+#define I_MODULATE__A_STAGE0 0x63c30000
+#define RGB_MODULATE__RGB_STAGE0 0xa1705000
+#define RGB_MODULATE__A_STAGE0 0x63230000
+#define RGBA_MODULATE__RGB_STAGE0 0xa1705000
+#define RGBA_MODULATE__A_STAGE0 0x63c30000
+
+#define RGB_DECAL__RGB_STAGE0 0xc1485000
+#define RGB_DECAL__A_STAGE0 0x63230000
+#define RGBA_DECAL__RGB_STAGE0 0xc534c001
+#define RGBA_DECAL__A_STAGE0 0x63230000
+
+#define A_BLEND_RGB_STAGE0 0xa1485000
+#define A_BLEND_A_STAGE0 0x63c30000
+#define L_BLEND__RGB_STAGE0 0x4530c001
+#define L_BLEND__A_STAGE0 0x63230000
+#define LA_BLEND__RGB_STAGE0 0x4530c001
+#define LA_BLEND__A_STAGE0 0x63c30000
+#define I_BLEND__RGB_STAGE0 0x4530c001
+#define I_BLEND__A_STAGE0 0x46c60001
+#define RGB_BLEND__RGB_STAGE0 0x4530c001
+#define RGB_BLEND__A_STAGE0 0x63230000
+#define RGBA_BLEND__RGB_STAGE0 0x4530c001
+#define RGBA_BLEND__A_STAGE0 0x63c30000
+
+#define RGB_STAGE1 0xa1485000
+#define A_STAGE1 0xa3230000
+
+#define A_REPLACE_RGB_STAGE1 0xa1485000
+#define A_REPLACE_A_STAGE1 0xe3230000
+#define L_REPLACE__RGB_STAGE1 0xe1485000
+#define L_REPLACE__A_STAGE1 0xa3230000
+#define LA_REPLACE__RGB_STAGE1 0xe1485000
+#define LA_REPLACE__A_STAGE1 0xe3230000
+#define I_REPLACE__RGB_STAGE1 0xe1485000
+#define I_REPLACE__A_STAGE1 0xe3230000
+#define RGB_REPLACE__RGB_STAGE1 0xe1485000
+#define RGB_REPLACE__A_STAGE1 0xa3230000
+#define RGBA_REPLACE__RGB_STAGE1 0xe1485000
+#define RGBA_REPLACE__A_STAGE1 0xe3230000
+
+#define A_MODULATE_RGB_STAGE1 0xa1485000
+#define A_MODULATE_A_STAGE1 0xa3e30000
+#define L_MODULATE__RGB_STAGE1 0xa1785000
+#define L_MODULATE__A_STAGE1 0xa3230000
+#define LA_MODULATE__RGB_STAGE1 0xa1785000
+#define LA_MODULATE__A_STAGE1 0xa3e30000
+#define I_MODULATE__RGB_STAGE1 0xa1785000
+#define I_MODULATE__A_STAGE1 0xa3e30000
+#define RGB_MODULATE__RGB_STAGE1 0xa1785000
+#define RGB_MODULATE__A_STAGE1 0xa3230000
+#define RGBA_MODULATE__RGB_STAGE1 0xa1785000
+#define RGBA_MODULATE__A_STAGE1 0xa3e30000
+
+#define RGB_DECAL__RGB_STAGE1 0xe1485000
+#define RGB_DECAL__A_STAGE1 0xa3230000
+#define RGBA_DECAL__RGB_STAGE1 0xe5394001
+#define RGBA_DECAL__A_STAGE1 0xa3230000
+
+#define A_BLEND_RGB_STAGE1 0xa1485000
+#define A_BLEND_A_STAGE1 0xa3e30000
+#define L_BLEND__RGB_STAGE1 0x45394001
+#define L_BLEND__A_STAGE1 0xa3230000
+#define LA_BLEND__RGB_STAGE1 0x45394001
+#define LA_BLEND__A_STAGE1 0xa3e30000
+#define I_BLEND__RGB_STAGE1 0x45394001
+#define I_BLEND__A_STAGE1 0x4aea0001
+#define RGB_BLEND__RGB_STAGE1 0x45394001
+#define RGB_BLEND__A_STAGE1 0xa3230000
+#define RGBA_BLEND__RGB_STAGE1 0x45394001
+#define RGBA_BLEND__A_STAGE1 0xa3e30000
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_render.c b/xc/lib/GL/mesa/src/drv/sis/sis_render.c
new file mode 100644
index 000000000..558f8d040
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_render.c
@@ -0,0 +1,491 @@
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+#define SIS_SMOOTH 0x1
+#define SIS_USE_W 0x2
+#define SIS_TEXTURE0 0x4
+#define SIS_TEXTURE1 0x8
+#define SIS_TRI_OFFSET 0x10
+#define SIS_USE_Z 0x11
+#define SIS_FALLBACK 0x80000000
+
+/*
+ * TODO: assert(hwcx->AGPCmdBufSize % AGP_ALLOC_SIZE == 0)
+ * depends on VB_SIZE is better
+ */
+#define AGP_ALLOC_SIZE 0x10000
+/* #define AGP_ALLOC_SIZE (VB_SIZE/3*4 * 9) */
+static DWORD AGP_EngineOffset;
+static DWORD *AGP_StartPtr;
+/* export to sis_fastpath.c */
+float *AGP_CurrentPtr;
+
+#define SIS_TAG(x) x##_flat
+#define SIS_STATES (0)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_smooth
+#define SIS_STATES (SIS_SMOOTH)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_flat_w
+#define SIS_STATES (SIS_USE_W)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_smooth_w
+#define SIS_STATES (SIS_SMOOTH | SIS_USE_W)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_flat_t0
+#define SIS_STATES (SIS_TEXTURE0)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_smooth_t0
+#define SIS_STATES (SIS_SMOOTH | SIS_TEXTURE0)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_flat_w_t0
+#define SIS_STATES (SIS_USE_W | SIS_TEXTURE0)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_smooth_w_t0
+#define SIS_STATES (SIS_SMOOTH | SIS_USE_W | SIS_TEXTURE0)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_flat_t1
+#define SIS_STATES (SIS_TEXTURE1)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_smooth_t1
+#define SIS_STATES (SIS_SMOOTH | SIS_TEXTURE1)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_flat_w_t1
+#define SIS_STATES (SIS_USE_W | SIS_TEXTURE1)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_smooth_w_t1
+#define SIS_STATES (SIS_SMOOTH | SIS_USE_W | SIS_TEXTURE1)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_flat_t2
+#define SIS_STATES (SIS_TEXTURE0 | SIS_TEXTURE1)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_smooth_t2
+#define SIS_STATES (SIS_SMOOTH | SIS_TEXTURE0 | SIS_TEXTURE1)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_flat_w_t2
+#define SIS_STATES (SIS_USE_W | SIS_TEXTURE0 | SIS_TEXTURE1)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+#define SIS_TAG(x) x##_smooth_w_t2
+#define SIS_STATES (SIS_SMOOTH | SIS_USE_W | SIS_TEXTURE0 | SIS_TEXTURE1)
+#include "sis_linefunc.h"
+#include "sis_trifunc.h"
+
+static line_func sis_draw_line_func[32] = {
+ sis_line_flat,
+ sis_line_smooth,
+ sis_line_flat_w,
+ sis_line_smooth_w,
+ sis_line_flat_t0,
+ sis_line_smooth_t0,
+ sis_line_flat_w_t0,
+ sis_line_smooth_w_t0,
+ sis_line_flat_t1,
+ sis_line_smooth_t1,
+ sis_line_flat_w_t1,
+ sis_line_smooth_w_t1,
+ sis_line_flat_t2,
+ sis_line_smooth_t2,
+ sis_line_flat_w_t2,
+ sis_line_smooth_w_t2,
+};
+
+static line_func sis_agp_draw_line_func[32] = {
+ sis_agp_line_flat,
+ sis_agp_line_smooth,
+ sis_agp_line_flat_w,
+ sis_agp_line_smooth_w,
+ sis_agp_line_flat_t0,
+ sis_agp_line_smooth_t0,
+ sis_agp_line_flat_w_t0,
+ sis_agp_line_smooth_w_t0,
+ sis_agp_line_flat_t1,
+ sis_agp_line_smooth_t1,
+ sis_agp_line_flat_w_t1,
+ sis_agp_line_smooth_w_t1,
+ sis_agp_line_flat_t2,
+ sis_agp_line_smooth_t2,
+ sis_agp_line_flat_w_t2,
+ sis_agp_line_smooth_w_t2,
+};
+
+/* TODO: get another path if not clipped */
+static void
+sis_line_clip (GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pv)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ BoxPtr pExtents;
+ int count;
+ GLuint x, y;
+
+ sis_get_drawable_origin (xmesa, &x, &y);
+ sis_get_clip_rects (xmesa, &pExtents, &count);
+
+ while (count--)
+ {
+ DWORD clipTopBottom, clipLeftRight;
+
+ clipTopBottom = ((pExtents->y1 - y) << 13) | (pExtents->y2 - y - 1);
+ clipLeftRight = ((pExtents->x1 - x) << 13) | (pExtents->x2 - x - 1);
+
+ mWait3DCmdQueue (5);
+
+ MMIO (REG_3D_ClipTopBottom, clipTopBottom);
+ MMIO (REG_3D_ClipLeftRight, clipLeftRight);
+
+ (hwcx->LineFunc) (ctx, vert0, vert1, pv);
+ mEndPrimitive ();
+
+ pExtents++;
+ }
+ hwcx->GlobalFlag |= GFLAG_CLIPPING;
+}
+
+static triangle_func sis_fill_triangle_func[32] = {
+ sis_tri_flat,
+ sis_tri_smooth,
+ sis_tri_flat_w,
+ sis_tri_smooth_w,
+ sis_tri_flat_t0,
+ sis_tri_smooth_t0,
+ sis_tri_flat_w_t0,
+ sis_tri_smooth_w_t0,
+ sis_tri_flat_t1,
+ sis_tri_smooth_t1,
+ sis_tri_flat_w_t1,
+ sis_tri_smooth_w_t1,
+ sis_tri_flat_t2,
+ sis_tri_smooth_t2,
+ sis_tri_flat_w_t2,
+ sis_tri_smooth_w_t2,
+};
+
+static triangle_func sis_agp_fill_triangle_func[32] = {
+ sis_agp_tri_flat,
+ sis_agp_tri_smooth,
+ sis_agp_tri_flat_w,
+ sis_agp_tri_smooth_w,
+ sis_agp_tri_flat_t0,
+ sis_agp_tri_smooth_t0,
+ sis_agp_tri_flat_w_t0,
+ sis_agp_tri_smooth_w_t0,
+ sis_agp_tri_flat_t1,
+ sis_agp_tri_smooth_t1,
+ sis_agp_tri_flat_w_t1,
+ sis_agp_tri_smooth_w_t1,
+ sis_agp_tri_flat_t2,
+ sis_agp_tri_smooth_t2,
+ sis_agp_tri_flat_w_t2,
+ sis_agp_tri_smooth_w_t2,
+};
+
+#define USE_XYZ 0x08000000
+#define USE_W 0x04000000
+#define USE_RGB 0x01000000
+#define USE_UV1 0x00400000
+#define USE_UV2 0x00200000
+#define USE_FLAT 0x0001000
+#define USE_SMOOTH 0x0004000
+
+static DWORD AGPParsingValues[32] = {
+ (4 << 28) | USE_XYZ | USE_RGB | USE_FLAT,
+ (4 << 28) | USE_XYZ | USE_RGB | USE_SMOOTH,
+ (5 << 28) | USE_XYZ | USE_W | USE_RGB | USE_FLAT,
+ (5 << 28) | USE_XYZ | USE_W | USE_RGB | USE_SMOOTH,
+ (6 << 28) | USE_XYZ | USE_RGB | USE_UV1 | USE_FLAT,
+ (6 << 28) | USE_XYZ | USE_RGB | USE_UV1 | USE_SMOOTH,
+ (7 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV1 | USE_FLAT,
+ (7 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV1 | USE_SMOOTH,
+ (6 << 28) | USE_XYZ | USE_RGB | USE_UV2 | USE_FLAT,
+ (6 << 28) | USE_XYZ | USE_RGB | USE_UV2 | USE_SMOOTH,
+ (7 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV2 | USE_FLAT,
+ (7 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV2 | USE_SMOOTH,
+ (8 << 28) | USE_XYZ | USE_RGB | USE_UV1 | USE_UV2 | USE_FLAT,
+ (8 << 28) | USE_XYZ | USE_RGB | USE_UV1 | USE_UV2 | USE_SMOOTH,
+ (9 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV1 | USE_UV2 | USE_FLAT,
+ (9 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV1 | USE_UV2 | USE_SMOOTH,
+};
+
+static void
+sis_tri_clip (GLcontext * ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ BoxPtr pExtents;
+ int count;
+ GLuint x, y;
+
+ sis_get_drawable_origin (xmesa, &x, &y);
+ sis_get_clip_rects (xmesa, &pExtents, &count);
+
+ while (count--)
+ {
+ DWORD clipTopBottom, clipLeftRight;
+
+ clipTopBottom = ((pExtents->y1 - y) << 13) | (pExtents->y2 - y - 1);
+ clipLeftRight = ((pExtents->x1 - x) << 13) | (pExtents->x2 - x - 1);
+
+ mWait3DCmdQueue (5);
+
+ MMIO (REG_3D_ClipTopBottom, clipTopBottom);
+ MMIO (REG_3D_ClipLeftRight, clipLeftRight);
+
+ (hwcx->TriangleFunc) (ctx, v0, v1, v2, pv);
+ mEndPrimitive ();
+
+ pExtents++;
+ }
+ hwcx->GlobalFlag |= GFLAG_CLIPPING;
+}
+
+void
+sis_set_render_func (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ GLuint caps = ctx->TriangleCaps;
+ int line_index = 0;
+ int tri_index = 0;
+
+ if(hwcx->swForceRender){
+ ctx->Driver.LineFunc = NULL;
+ ctx->Driver.TriangleFunc = NULL;
+ return;
+ }
+
+ ctx->IndirectTriangles &= ~(DD_LINE_SW_RASTERIZE | DD_TRI_SW_RASTERIZE);
+ hwcx->swRenderFlag &= ~(SIS_SW_POINT | SIS_SW_LINE | SIS_SW_TRIANGLE);
+
+/*
+ * TODO: Mesa 3.3 will set ctx->TriangleCaps to DD_SELECT
+ */
+#if 0
+ if ((caps & (DD_SELECT | DD_FEEDBACK))
+ /* Fixme */
+ || (ctx->Texture.ReallyEnabled & (TEXTURE0_3D | TEXTURE1_3D)))
+ {
+ line_index |= SIS_FALLBACK;
+ tri_index |= SIS_FALLBACK;
+ }
+#endif
+
+ /* always set */
+ hwcx->swRenderFlag |= SIS_SW_POINT;
+
+ if ((caps & DD_LINE_STIPPLE) || (caps & DD_LINE_WIDTH))
+ {
+ line_index |= SIS_FALLBACK;
+ hwcx->swRenderFlag |= SIS_SW_LINE;
+ }
+
+ if ((caps & DD_TRI_STIPPLE))
+ {
+ tri_index |= SIS_FALLBACK;
+ hwcx->swRenderFlag |= SIS_SW_TRIANGLE;
+ }
+
+ if (ctx->Light.ShadeModel == GL_SMOOTH)
+ {
+ line_index |= SIS_SMOOTH;
+ tri_index |= SIS_SMOOTH;
+ }
+
+ if (ctx->RasterMask & FOG_BIT)
+ {
+ line_index |= SIS_USE_W;
+ tri_index |= SIS_USE_W;
+ }
+
+ if (ctx->Texture.ReallyEnabled)
+ {
+ line_index |= SIS_USE_W;
+ tri_index |= SIS_USE_W;
+
+ if (ctx->Texture.ReallyEnabled & TEXTURE0_ANY)
+ {
+ line_index |= SIS_TEXTURE0;
+ tri_index |= SIS_TEXTURE0;
+ }
+ if (ctx->Texture.ReallyEnabled & TEXTURE1_ANY)
+ {
+ line_index |= SIS_TEXTURE1;
+ tri_index |= SIS_TEXTURE1;
+ }
+ }
+
+ /* TODO, use Pick */
+ hwcx->UseAGPCmdMode = GL_FALSE;
+
+ if (line_index & SIS_FALLBACK)
+ {
+ ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+ hwcx->LineFunc = NULL;
+ }
+ else
+ {
+ if ((ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) &&
+ sis_is_window (xmesa))
+ {
+ hwcx->LineFunc = sis_draw_line_func[line_index];
+ ctx->Driver.LineFunc = sis_line_clip;
+ }
+ else
+ {
+ if (hwcx->AGPCmdModeEnabled)
+ {
+ ctx->Driver.LineFunc = sis_agp_draw_line_func[line_index];
+ hwcx->UseAGPCmdMode = GL_TRUE;
+ }
+ else
+ {
+ ctx->Driver.LineFunc = sis_draw_line_func[line_index];
+ }
+ }
+ }
+
+ if (tri_index & SIS_FALLBACK)
+ {
+ ctx->IndirectTriangles |= DD_TRI_SW_RASTERIZE;
+ hwcx->TriangleFunc = NULL;
+ }
+ else
+ {
+ if ((ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) &&
+ sis_is_window (xmesa))
+ {
+ hwcx->TriangleFunc = sis_fill_triangle_func[tri_index];
+ ctx->Driver.TriangleFunc = sis_tri_clip;
+ }
+ else
+ {
+ if (hwcx->AGPCmdModeEnabled)
+ {
+ ctx->Driver.TriangleFunc = sis_agp_fill_triangle_func[tri_index];
+ hwcx->UseAGPCmdMode = GL_TRUE;
+ }
+ else
+ {
+ ctx->Driver.TriangleFunc = sis_fill_triangle_func[tri_index];
+ }
+ }
+ }
+
+ /* fast path */
+ if(!(ctx->TriangleCaps & (DD_TRI_UNFILLED | DD_TRI_LIGHT_TWOSIDE)) &&
+ (ctx->Driver.TriangleFunc == sis_agp_tri_smooth_w_t2) &&
+ (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT)){
+ hwcx->useFastPath = GL_TRUE;
+ }
+ else{
+ hwcx->useFastPath = GL_FALSE;
+ }
+
+ /* TODO: AGP and MMIO use different sis_set_render_state */
+ hwcx->AGPParseSet &= ~0xffff7000;
+ hwcx->AGPParseSet |= AGPParsingValues[line_index & ~SIS_FALLBACK];
+
+ /* Debug, test sw-render
+ ctx->Driver.LineFunc = NULL;
+ ctx->Driver.TriangleFunc = NULL;
+ */
+}
+
+void
+sis_StartAGP (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ DWORD start, end;
+
+ start = *(hwcx->pAGPCmdBufNext);
+ end = start + AGP_ALLOC_SIZE;
+ if (end >= hwcx->AGPCmdBufSize)
+ {
+ start = 0;
+ end = AGP_ALLOC_SIZE;
+ }
+
+ /*
+ * TODO: use AGP_EngineOffset to get a safe value and not query current
+ * postion processed every time
+ * ?? use < instead of <=
+ */
+ do
+ {
+ AGP_EngineOffset =
+ *(DWORD volatile *) (GET_IOBase (hwcx) + REG_3D_AGPCmBase) -
+ (DWORD) hwcx->AGPCmdBufAddr;
+ }
+ while ((AGP_EngineOffset <= end) && (AGP_EngineOffset >= start)
+ && ((*(GET_IOBase (hwcx) + 0x8243) & 0xe0) != 0xe0));
+
+ AGP_StartPtr = (DWORD *) (start + hwcx->AGPCmdBufBase);
+ AGP_CurrentPtr = (float *) AGP_StartPtr;
+}
+
+void
+sis_FlushAGP (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ /* TODO: wait queue length */
+
+ if((DWORD *)AGP_CurrentPtr == AGP_StartPtr)
+ {
+ return;
+ }
+
+ /* debug
+ d2f_once(ctx);
+ */
+
+ mWait3DCmdQueue (5);
+ mEndPrimitive ();
+ MMIO (REG_3D_AGPCmBase, ((DWORD) AGP_StartPtr - (DWORD) hwcx->AGPCmdBufBase)
+ + (DWORD) hwcx->AGPCmdBufAddr);
+ MMIO (REG_3D_AGPTtDwNum,
+ (((DWORD) AGP_CurrentPtr - (DWORD) AGP_StartPtr) >> 2) | 0x50000000);
+ MMIO (REG_3D_ParsingSet, hwcx->AGPParseSet);
+
+ MMIO (REG_3D_AGPCmFire, (DWORD) (-1));
+ mEndPrimitive ();
+
+ *(hwcx->pAGPCmdBufNext) =
+ (DWORD) AGP_CurrentPtr - (DWORD) hwcx->AGPCmdBufBase;
+ *(hwcx->pAGPCmdBufNext) = (*(hwcx->pAGPCmdBufNext) + 0xf) & ~0xf;
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_span.c b/xc/lib/GL/mesa/src/drv/sis/sis_span.c
new file mode 100644
index 000000000..aa154ed66
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_span.c
@@ -0,0 +1,285 @@
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+#define DBG 0
+
+/* from mga */
+/* TODO: should lock drawable in these routines because glBitmap will
+ * call this function without locking, or modify sis_Bitmap
+ */
+
+#define LOCAL_VARS \
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; \
+ GLuint pitch = hwcx->swRenderPitch; \
+ char *buf = hwcx->swRenderBase
+
+#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); \
+ }
+
+#define HW_LOCK() do{}while(0);
+
+#define HW_CLIPLOOP() \
+ do { \
+ BoxPtr _pExtents; \
+ int _nc; \
+ GLuint _x, _y; \
+ sis_get_drawable_origin (xmesa, &_x, &_y); \
+ sis_get_clip_rects (xmesa, &_pExtents, &_nc); \
+ while (_nc--) { \
+ int minx = _pExtents->x1 - _x; \
+ int miny = _pExtents->y1 - _y; \
+ int maxx = _pExtents->x2 - _x; \
+ int maxy = _pExtents->y2 - _y; \
+ _pExtents++;
+
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+
+#define HW_UNLOCK() do{}while(0);
+
+/* RGB565 */
+#define INIT_MONO_PIXEL(p) \
+ GLushort p = hwcx->pixelValue;
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0xf8) << 8) | \
+ ((g & 0xfc) << 3) | \
+ (b >> 3))
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+do { \
+ GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
+ rgba[0] = (p & 0xf800) >> 8; \
+ rgba[1] = (p & 0x07e0) >> 3; \
+ rgba[2] = (p & 0x001f) << 3; \
+ rgba[3] = 0; \
+} while(0)
+
+#define TAG(x) sis_##x##_565
+#include "spantmp.h"
+static void sis_Color_565( GLcontext *ctx,
+ GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ hwcx->pixelValue = ((red & 0xf8) << 8) |
+ ((green & 0xfc) << 3) |
+ (blue >> 3);
+}
+
+
+/* ARGB8888 */
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p) \
+ GLuint p = hwcx->pixelValue;
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = ( ((a) << 24) | \
+ ((r) << 16) | \
+ ((g) << 8) | \
+ ((b)))
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+do { \
+ GLuint p = *(GLuint *)(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) sis_##x##_8888
+#include "spantmp.h"
+static void sis_Color_8888( GLcontext *ctx,
+ GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ hwcx->pixelValue = (red << 16) |
+ (green << 8) |
+ (blue) |
+ (alpha << 24);
+}
+
+void sis_sw_init_driver( GLcontext *ctx )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ if (hwcx->colorFormat == DST_FORMAT_RGB_565) {
+ ctx->Driver.Color = sis_Color_565;
+ ctx->Driver.WriteRGBASpan = sis_WriteRGBASpan_565;
+ ctx->Driver.WriteRGBSpan = sis_WriteRGBSpan_565;
+ ctx->Driver.WriteMonoRGBASpan = sis_WriteMonoRGBASpan_565;
+ ctx->Driver.WriteRGBAPixels = sis_WriteRGBAPixels_565;
+ ctx->Driver.WriteMonoRGBAPixels = sis_WriteMonoRGBAPixels_565;
+ ctx->Driver.ReadRGBASpan = sis_ReadRGBASpan_565;
+ ctx->Driver.ReadRGBAPixels = sis_ReadRGBAPixels_565;
+ }
+ else if(hwcx->colorFormat == DST_FORMAT_ARGB_8888){
+ ctx->Driver.Color = sis_Color_8888;
+ ctx->Driver.WriteRGBASpan = sis_WriteRGBASpan_8888;
+ ctx->Driver.WriteRGBSpan = sis_WriteRGBSpan_8888;
+ ctx->Driver.WriteMonoRGBASpan = sis_WriteMonoRGBASpan_8888;
+ ctx->Driver.WriteRGBAPixels = sis_WriteRGBAPixels_8888;
+ ctx->Driver.WriteMonoRGBAPixels = sis_WriteMonoRGBAPixels_8888;
+ ctx->Driver.ReadRGBASpan = sis_ReadRGBASpan_8888;
+ ctx->Driver.ReadRGBAPixels = sis_ReadRGBAPixels_8888;
+ }
+ else{
+ assert(0);
+ }
+
+ 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;
+}
+
+/* Depth/Stencil Functions
+ * use sizeof(GLdepth) to know the Z rnage of mesa is
+ * 0 ~ 2^16-1 or 0 ~ 2^32-1
+ */
+#define SIS_SW_Z_BASE(x,y) \
+ ((SIS_SW_DTYPE *)(hwcx->swZBase + (x)*sizeof(SIS_SW_DTYPE) + \
+ (y)*hwcx->swZPitch))
+
+/* Z16 */
+#define SIS_TAG(x) x##_Z16
+#define SIS_SW_DTYPE GLushort
+#define SIS_SW_D2I(D,I) \
+ do{ \
+ if(sizeof(GLdepth) == 2) \
+ I = D; \
+ else \
+ I = D << 16; \
+ }while(0)
+#define SIS_SW_I2D(I,D) \
+ do{ \
+ if(sizeof(GLdepth) == 2) \
+ D = I; \
+ else \
+ D = I >> 16; \
+ }while(0)
+#include "sis_swzfunc.h"
+
+/* Z32 */
+#define SIS_TAG(x) x##_Z32
+#define SIS_SW_DTYPE GLuint
+#define SIS_SW_D2I(D,I) \
+ do{ \
+ if(sizeof(GLdepth) == 4) \
+ I = D; \
+ else \
+ I = D >> 16; \
+ }while(0)
+#define SIS_SW_I2D(I,D) \
+ do{ \
+ if(sizeof(GLdepth) == 4) \
+ D = I; \
+ else \
+ D = I << 16; \
+ }while(0)
+#include "sis_swzfunc.h"
+
+#define SIS_SW_STENCIL_FUNC
+
+/* S8Z24 */
+# define SIS_TAG(x) x##_S8Z24
+# define SIS_SW_DTYPE GLuint
+# define SIS_SW_D2I(D,I) \
+ do{ \
+ if(sizeof(GLdepth) == 4) \
+ I = (D << 8); \
+ else \
+ I = (D >> 8); \
+ }while(0)
+# define SIS_SW_I2D(I,D) \
+ do{ \
+ if(sizeof(GLdepth) == 4){ \
+ D &= 0xff000000; \
+ D |= (I >> 8); \
+ } \
+ else{ \
+ D &= 0xff000000; \
+ D |= (I << 8); \
+ } \
+ }while(0)
+# define SIS_SW_S2I(S,I) \
+ do{ \
+ I = (S >> 24); \
+ }while(0)
+# define SIS_SW_I2S(I,S) \
+ do{ \
+ S &= 0x00ffffff; \
+ S |= (I << 24); \
+ }while(0)
+# include "sis_swzfunc.h"
+
+#undef SIS_SW_STENCIL_FUNC
+
+void
+sis_sw_set_zfuncs_static (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ switch (hwcx->zFormat)
+ {
+ case Z_16:
+ ctx->Driver.ReadDepthSpan = sis_ReadDepthSpan_Z16;
+ ctx->Driver.ReadDepthPixels = sis_ReadDepthPixels_Z16;
+ ctx->Driver.WriteDepthSpan = sis_WriteDepthSpan_Z16;
+ ctx->Driver.WriteDepthPixels = sis_WriteDepthPixels_Z16;
+
+ ctx->Driver.ReadStencilSpan = NULL;
+ ctx->Driver.ReadStencilPixels = NULL;
+ ctx->Driver.WriteStencilSpan = NULL;
+ ctx->Driver.WriteStencilPixels = NULL;
+ break;
+ case Z_32:
+ ctx->Driver.ReadDepthSpan = sis_ReadDepthSpan_Z32;
+ ctx->Driver.ReadDepthPixels = sis_ReadDepthPixels_Z32;
+ ctx->Driver.WriteDepthSpan = sis_WriteDepthSpan_Z32;
+ ctx->Driver.WriteDepthPixels = sis_WriteDepthPixels_Z32;
+
+ ctx->Driver.ReadStencilSpan = NULL;
+ ctx->Driver.ReadStencilPixels = NULL;
+ ctx->Driver.WriteStencilSpan = NULL;
+ ctx->Driver.WriteStencilPixels = NULL;
+ break;
+ case S_8_Z_24:
+ ctx->Driver.ReadDepthSpan = sis_ReadDepthSpan_S8Z24;
+ ctx->Driver.ReadDepthPixels = sis_ReadDepthPixels_S8Z24;
+ ctx->Driver.WriteDepthSpan = sis_WriteDepthSpan_S8Z24;
+ ctx->Driver.WriteDepthPixels = sis_WriteDepthPixels_S8Z24;
+
+ ctx->Driver.ReadStencilSpan = sis_ReadStencilSpan_S8Z24;
+ ctx->Driver.ReadStencilPixels = sis_ReadStencilPixels_S8Z24;
+ ctx->Driver.WriteStencilSpan = sis_WriteStencilSpan_S8Z24;
+ ctx->Driver.WriteStencilPixels = sis_WriteStencilPixels_S8Z24;
+ break;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_stencil.c b/xc/lib/GL/mesa/src/drv/sis/sis_stencil.c
new file mode 100644
index 000000000..950435cf4
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_stencil.c
@@ -0,0 +1,149 @@
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+void
+sis_StencilFunc (GLcontext * ctx, GLenum func, GLint ref, GLuint mask)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ /* set reference */
+ current->hwStSetting = ((DWORD) ref << 8) | mask;
+
+ current->hwStSetting &= ~0x07000000;
+ switch (func)
+ {
+ case GL_NEVER:
+ current->hwStSetting |= SiS_STENCIL_NEVER;
+ break;
+ case GL_LESS:
+ current->hwStSetting |= SiS_STENCIL_LESS;
+ break;
+ case GL_EQUAL:
+ current->hwStSetting |= SiS_STENCIL_EQUAL;
+ break;
+ case GL_LEQUAL:
+ current->hwStSetting |= SiS_STENCIL_LEQUAL;
+ break;
+ case GL_GREATER:
+ current->hwStSetting |= SiS_STENCIL_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ current->hwStSetting |= SiS_STENCIL_NOTEQUAL;
+ break;
+ case GL_GEQUAL:
+ current->hwStSetting |= SiS_STENCIL_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ current->hwStSetting |= SiS_STENCIL_ALWAYS;
+ break;
+ }
+
+ if ((current->hwStSetting2 ^ prev->hwStSetting2) ||
+ (current->hwStSetting ^ prev->hwStSetting))
+ {
+ prev->hwStSetting = current->hwStSetting;
+ prev->hwStSetting2 = current->hwStSetting2;
+
+ hwcx->GlobalFlag |= GFLAG_STENCILSETTING;
+ }
+}
+
+void
+sis_StencilMask (GLcontext * ctx, GLuint mask)
+{
+ if (!ctx->Visual->StencilBits)
+ return;
+
+ /* set Z buffer Write Enable */
+ sis_DepthMask (ctx, ctx->Depth.Mask);
+}
+
+void
+sis_StencilOp (GLcontext * ctx, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ current->hwStSetting2 &= ~0x00777000;
+
+ switch (fail)
+ {
+ case GL_KEEP:
+ current->hwStSetting2 |= SiS_SFAIL_KEEP;
+ break;
+ case GL_ZERO:
+ current->hwStSetting2 |= SiS_SFAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ current->hwStSetting2 |= SiS_SFAIL_REPLACE;
+ break;
+ case GL_INVERT:
+ current->hwStSetting2 |= SiS_SFAIL_INVERT;
+ break;
+ case GL_INCR:
+ current->hwStSetting2 |= SiS_SFAIL_INCR;
+ break;
+ case GL_DECR:
+ current->hwStSetting2 |= SiS_SFAIL_DECR;
+ break;
+ }
+
+ switch (zfail)
+ {
+ case GL_KEEP:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_KEEP;
+ break;
+ case GL_ZERO:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_REPLACE;
+ break;
+ case GL_INVERT:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_INVERT;
+ break;
+ case GL_INCR:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_INCR;
+ break;
+ case GL_DECR:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_DECR;
+ break;
+ }
+
+ switch (zpass)
+ {
+ case GL_KEEP:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_KEEP;
+ break;
+ case GL_ZERO:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_ZERO;
+ break;
+ case GL_REPLACE:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_REPLACE;
+ break;
+ case GL_INVERT:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_INVERT;
+ break;
+ case GL_INCR:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_INCR;
+ break;
+ case GL_DECR:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_DECR;
+ break;
+ }
+
+ if ((current->hwStSetting2 ^ prev->hwStSetting2) ||
+ (current->hwStSetting ^ prev->hwStSetting))
+ {
+ prev->hwStSetting = current->hwStSetting;
+ prev->hwStSetting2 = current->hwStSetting2;
+
+ hwcx->GlobalFlag |= GFLAG_STENCILSETTING;
+
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h b/xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h
new file mode 100644
index 000000000..322a7ad40
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h
@@ -0,0 +1,153 @@
+static void SIS_TAG (sis_WriteDepthSpan) (GLcontext * ctx, GLuint n, GLint x,
+ GLint y, const GLdepth depth[],
+ const GLubyte mask[])
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIS_SW_DTYPE *base = SIS_SW_Z_BASE (x, Y_FLIP (y));
+
+ int i;
+ for (i = 0; i < n; i++, base++)
+ {
+ if (mask[i])
+ SIS_SW_I2D (depth[i], *base);
+ }
+}
+
+static void SIS_TAG (sis_ReadDepthSpan) (GLcontext * ctx, GLuint n, GLint x,
+ GLint y, GLdepth depth[])
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIS_SW_DTYPE *base = SIS_SW_Z_BASE (x, Y_FLIP (y));
+
+ int i;
+ for (i = 0; i < n; i++, base++)
+ {
+ SIS_SW_D2I (*base, depth[i]);
+ }
+}
+
+static void SIS_TAG (sis_WriteDepthPixels) (GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth depth[],
+ const GLubyte mask[])
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIS_SW_DTYPE *base;
+
+ int i;
+ for (i = 0; i < n; i++, base++)
+ {
+ if (mask[i])
+ {
+ base = SIS_SW_Z_BASE (x[i], Y_FLIP (y[i]));
+ SIS_SW_I2D (depth[i], *base);
+ }
+ }
+}
+
+static void SIS_TAG (sis_ReadDepthPixels) (GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ GLdepth depth[])
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIS_SW_DTYPE *base;
+
+ int i;
+ for (i = 0; i < n; i++, base++)
+ {
+ base = SIS_SW_Z_BASE (x[i], Y_FLIP (y[i]));
+ SIS_SW_D2I (*base, depth[i]);
+ }
+}
+
+#ifdef SIS_SW_STENCIL_FUNC
+
+static void SIS_TAG (sis_WriteStencilSpan) (GLcontext * ctx, GLuint n,
+ GLint x, GLint y,
+ const GLstencil depth[],
+ const GLubyte mask[])
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIS_SW_DTYPE *base = SIS_SW_Z_BASE (x, Y_FLIP (y));
+
+ int i;
+ for (i = 0; i < n; i++, base++)
+ {
+ if (mask[i])
+ SIS_SW_I2S (depth[i], *base);
+ }
+}
+
+static void SIS_TAG (sis_ReadStencilSpan) (GLcontext * ctx, GLuint n, GLint x,
+ GLint y, GLstencil depth[])
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIS_SW_DTYPE *base = SIS_SW_Z_BASE (x, Y_FLIP (y));
+
+ int i;
+ for (i = 0; i < n; i++, base++)
+ {
+ SIS_SW_S2I (*base, depth[i]);
+ }
+}
+
+static void SIS_TAG (sis_WriteStencilPixels) (GLcontext * ctx, GLuint n,
+ const GLint x[],
+ const GLint y[],
+ const GLstencil depth[],
+ const GLubyte mask[])
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIS_SW_DTYPE *base;
+
+ int i;
+ for (i = 0; i < n; i++, base++)
+ {
+ if (mask[i])
+ {
+ base = SIS_SW_Z_BASE (x[i], Y_FLIP (y[i]));
+ SIS_SW_I2S (depth[i], *base);
+ }
+ }
+}
+
+static void SIS_TAG (sis_ReadStencilPixels) (GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ GLstencil depth[])
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIS_SW_DTYPE *base;
+
+ int i;
+ for (i = 0; i < n; i++, base++)
+ {
+ base = SIS_SW_Z_BASE (x[i], Y_FLIP (y[i]));
+ SIS_SW_S2I (*base, depth[i]);
+ }
+}
+
+# undef SIS_SW_S2I
+# undef SIS_SW_I2S
+
+#endif
+
+#undef SIS_TAG
+#undef SIS_SW_DTYPE
+#undef SIS_SW_D2I
+#undef SIS_SW_I2D
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_texture.c b/xc/lib/GL/mesa/src/drv/sis/sis_texture.c
new file mode 100644
index 000000000..75ca83186
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_texture.c
@@ -0,0 +1,884 @@
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+static void
+sis_set_texture_env0 (GLcontext * ctx, GLtextureObject * object, int unit);
+
+static void
+sis_set_texture_env1 (GLcontext * ctx, GLtextureObject * object, int unit);
+
+static void
+sis_set_texobj_parm (GLcontext * ctx, GLtextureObject * object, int hw_unit);
+
+static void sis_reset_texture_env (GLcontext * ctx, int hw_unit);
+
+static DWORD TransferTexturePitch (DWORD dwPitch);
+
+void
+sis_validate_texture (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ struct gl_texture_unit *tex_unit;
+ struct gl_texture_object *tObj;
+ sisTexobjInfo *texObjArea;
+
+ if(ctx->Texture.ReallyEnabled & (TEXTURE0_3D | TEXTURE1_3D))
+ {
+ hwcx->swRenderFlag |= SIS_SW_TEXTURE_DIM;
+ return;
+ }
+ else
+ {
+ hwcx->swRenderFlag &= ~SIS_SW_TEXTURE_DIM;
+ }
+
+ if ((ctx->Texture.ReallyEnabled & TEXTURE0_ANY) &&
+ (ctx->Texture.ReallyEnabled & TEXTURE1_ANY))
+ {
+ int unit;
+
+ for (unit = 0; unit <= 1; unit++)
+ {
+ tex_unit = &ctx->Texture.Unit[unit];
+ tObj = tex_unit->Current;
+ texObjArea = (sisTexobjInfo *) tObj->DriverData;
+
+ if (hwcx->TexStates[unit] & NEW_TEXTURING)
+ {
+ hwcx->swRenderFlag &= ~(SIS_SW_TEXTURE_OBJ << unit);
+ sis_set_texobj_parm (ctx, tObj, unit);
+ }
+
+ if (hwcx->TexStates[unit] & NEW_TEXTURE_ENV)
+ {
+ hwcx->swRenderFlag &= ~(SIS_SW_TEXTURE_ENV << unit);
+ if (unit == 0)
+ sis_set_texture_env0 (ctx, tObj, unit);
+ else
+ sis_set_texture_env1 (ctx, tObj, unit);
+ }
+
+ hwcx->TexStates[unit] = 0;
+ }
+ }
+ else
+ {
+ int unit = (ctx->Texture.ReallyEnabled & TEXTURE0_ANY) ? 0 : 1;
+
+ tex_unit = &ctx->Texture.Unit[unit];
+ tObj = tex_unit->Current;
+ texObjArea = (sisTexobjInfo *) tObj->DriverData;
+
+ if (hwcx->TexStates[unit] & NEW_TEXTURING)
+ sis_set_texobj_parm (ctx, tObj, unit);
+
+ if (hwcx->TexStates[unit] & NEW_TEXTURE_ENV)
+ {
+ if(unit == 0){
+ sis_set_texture_env0 (ctx, tObj, unit);
+ sis_reset_texture_env (ctx, 1);
+ }
+ else{
+ sis_set_texture_env1 (ctx, tObj, unit);
+ sis_reset_texture_env (ctx, 0);
+ }
+ }
+
+ hwcx->TexStates[unit] = 0;
+ }
+}
+
+void
+sis_TexEnv( GLcontext *ctx, GLenum target, GLenum pname,
+ const GLfloat *param )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+}
+
+void
+sis_TexImage (GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj, GLint level,
+ GLint internalFormat, const struct gl_texture_image *image)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIStextureArea *area;
+
+ if (target == GL_TEXTURE_3D || image->Border)
+ {
+ return;
+ }
+
+ if (!tObj->DriverData)
+ {
+ sisTexobjInfo *info;
+
+ info = (sisTexobjInfo *)calloc (1, sizeof (sisTexobjInfo));
+
+ /* TODO */
+ assert(info);
+
+ info->prev = info->next = NULL;
+ info->valid = GL_FALSE;
+ tObj->DriverData = info;
+ }
+
+ if (image->DriverData)
+ {
+ /* image has a copy in video memory, and it may be in the cache */
+
+ ((sisTexobjInfo *) tObj->DriverData)->dirtyFlag |= SIS_TEX_ALL;
+ }
+ else
+ {
+ /* Optimize */
+
+ ((sisTexobjInfo *) tObj->DriverData)->dirtyFlag |= (SIS_TEX_PARAMETER
+ | SIS_TEX_ENV);
+ }
+
+ sis_alloc_texture_image (ctx, (struct gl_texture_image *) image);
+
+ area = (SIStextureArea *) image->DriverData;
+ assert (area->Data);
+
+ if (area->Format == GL_RGB8)
+ {
+ int i;
+ GLbyte *src = image->Data;
+ GLbyte *dst = area->Data;
+
+ for (i = 0; i < area->Size / 4; i++)
+ {
+ *(DWORD *)dst = *(DWORD *)src & 0x00ffffff;
+ src += 3;
+ dst += 4;
+ }
+ }
+ else
+ {
+ memcpy (area->Data, image->Data, area->Size);
+ }
+
+ if (hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] != area->Format)
+ {
+ hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+ hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] = area->Format;
+ }
+ hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+void
+sis_TexSubImage (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)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ SIStextureArea *area;
+ int i, j;
+ GLbyte *src, *dst;
+ GLuint soffset, doffset;
+
+ area = (SIStextureArea *) image->DriverData;
+
+ hwcx->clearTexCache = GL_TRUE;
+
+ {
+ /*
+ * Optimize
+ */
+ WaitEngIdle (hwcx);
+ }
+
+ if (area->Format == GL_RGB8)
+ {
+ src = 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;
+ for (j = yoffset; j < yoffset + height; j++)
+ {
+ for (i = xoffset; i < xoffset + width; i++)
+ {
+ *(DWORD *)dst = *(DWORD *)src & 0x00ffffff;
+ src += 3;
+ dst += 4;
+ }
+ src += soffset;
+ dst += doffset;
+ }
+ }
+ else
+ {
+ GLuint texelSize = area->texelSize;
+ GLuint copySize = texelSize * width;
+
+ src = image->Data + (xoffset + yoffset * image->Width) * texelSize;
+ dst = area->Data + (xoffset + yoffset * image->Width) * texelSize;
+ soffset = image->Width * texelSize;
+
+ for (j = yoffset; j < yoffset + height; j++)
+ {
+ memcpy (dst, src, copySize);
+ src += soffset;
+ dst += soffset;
+ }
+ }
+}
+
+void
+sis_TexParameter (GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj, GLenum pname, const
+ GLfloat * params)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ if (tObj->DriverData)
+ ((sisTexobjInfo *) tObj->DriverData)->dirtyFlag |= SIS_TEX_PARAMETER;
+
+ hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+void
+sis_BindTexture (GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ SIStextureArea *area;
+
+ if (!tObj->Image[0])
+ return;
+
+ if (!(area = (SIStextureArea *) tObj->Image[0]->DriverData))
+ return;
+
+ if (hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] != area->Format)
+ {
+ hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+ hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] = area->Format;
+ }
+ hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+void
+sis_DeleteTexture (GLcontext * ctx, struct gl_texture_object *tObj)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ int i;
+
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
+ {
+ if (tObj->Image[i])
+ sis_free_texture_image (tObj->Image[i]);
+ }
+
+ if (tObj->DriverData)
+ {
+ free (tObj->DriverData);
+ tObj->DriverData = NULL;
+ }
+ else
+ {
+ /*
+ * this shows the texture is default object and never be a
+ * argument of sis_TexImage
+ */
+ }
+
+ hwcx->clearTexCache = GL_TRUE;
+}
+
+void
+sis_UpdateTexturePalette (GLcontext * ctx, struct gl_texture_object *tObj)
+{
+
+}
+
+void
+sis_UseGlobalTexturePalette (GLcontext * ctx, GLboolean state)
+{
+
+}
+
+void
+sis_ActiveTexture (GLcontext * ctx, GLuint texUnitNumber)
+{
+}
+
+GLboolean sis_IsTextureResident (GLcontext * ctx, struct gl_texture_object *t)
+{
+ return GL_TRUE;
+}
+
+void
+sis_PrioritizeTexture (GLcontext * ctx,
+ struct gl_texture_object *t, GLclampf priority)
+{
+}
+
+static void
+sis_set_texture_env0 (GLcontext * ctx, GLtextureObject * object, int unit)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit];
+
+ GLtextureImage *image = object->Image[0];
+ SIStextureArea *area = (SIStextureArea *) image->DriverData;
+
+ /*
+ current->hwTexBlendClr1 = RGB_STAGE1;
+ current->hwTexBlendAlpha1 = A_STAGE1;
+ */
+
+ switch (texture_unit->EnvMode)
+ {
+ case GL_REPLACE:
+ switch (area->Format)
+ {
+ case GL_ALPHA8:
+ current->hwTexBlendClr0 = A_REPLACE_RGB_STAGE0;
+ current->hwTexBlendAlpha0 = A_REPLACE_A_STAGE0;
+ break;
+ case GL_INTENSITY8:
+ case GL_RGB8:
+ current->hwTexBlendClr0 = RGB_REPLACE__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = RGB_REPLACE__A_STAGE0;
+ break;
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_RGBA8:
+ current->hwTexBlendClr0 = RGBA_REPLACE__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = RGBA_REPLACE__A_STAGE0;
+ break;
+ }
+ break;
+
+ case GL_MODULATE:
+ switch (area->Format)
+ {
+ case GL_ALPHA8:
+ current->hwTexBlendClr0 = A_MODULATE_RGB_STAGE0;
+ current->hwTexBlendAlpha0 = A_MODULATE_A_STAGE0;
+ break;
+ case GL_LUMINANCE8:
+ case GL_RGB8:
+ current->hwTexBlendClr0 = RGB_MODULATE__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = RGB_MODULATE__A_STAGE0;
+ break;
+ case GL_INTENSITY8:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_RGBA8:
+ current->hwTexBlendClr0 = RGBA_MODULATE__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = RGBA_MODULATE__A_STAGE0;
+ break;
+ }
+ break;
+
+ case GL_DECAL:
+ switch (area->Format)
+ {
+ case GL_RGB8:
+ current->hwTexBlendClr0 = RGB_DECAL__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = RGB_DECAL__A_STAGE0;
+ break;
+ case GL_RGBA8:
+ current->hwTexBlendClr0 = RGBA_DECAL__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = RGBA_DECAL__A_STAGE0;
+ break;
+ }
+ break;
+
+ case GL_BLEND:
+ current->hwTexEnvColor =
+ ((DWORD) (texture_unit->EnvColor[3])) << 24 |
+ ((DWORD) (texture_unit->EnvColor[0])) << 16 |
+ ((DWORD) (texture_unit->EnvColor[1])) << 8 |
+ ((DWORD) (texture_unit->EnvColor[2]));
+ switch (area->Format)
+ {
+ case GL_ALPHA8:
+ current->hwTexBlendClr0 = A_BLEND_RGB_STAGE0;
+ current->hwTexBlendAlpha0 = A_BLEND_A_STAGE0;
+ break;
+ case GL_LUMINANCE8:
+ case GL_RGB8:
+ current->hwTexBlendClr0 = RGB_BLEND__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = RGB_BLEND__A_STAGE0;
+ break;
+ case GL_INTENSITY8:
+ current->hwTexBlendClr0 = I_BLEND__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = I_BLEND__A_STAGE0;
+ break;
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_RGBA8:
+ current->hwTexBlendClr0 = RGBA_BLEND__RGB_STAGE0;
+ current->hwTexBlendAlpha0 = RGBA_BLEND__A_STAGE0;
+ break;
+ }
+ break;
+ }
+
+ if ((current->hwTexBlendClr0 ^ prev->hwTexBlendClr0) ||
+ (current->hwTexBlendAlpha0 ^ prev->hwTexBlendAlpha0) ||
+ (current->hwTexEnvColor ^ prev->hwTexEnvColor))
+ {
+ prev->hwTexEnvColor = current->hwTexEnvColor;
+ prev->hwTexBlendClr0 = current->hwTexBlendClr0;
+ prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0;
+ hwcx->GlobalFlag |= GFLAG_TEXTUREENV;
+ }
+}
+
+void
+sis_set_texture_env1 (GLcontext * ctx, GLtextureObject * object, int unit)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit];
+ GLtextureImage *image = object->Image[0];
+ SIStextureArea *area = (SIStextureArea *) image->DriverData;
+
+ /*
+ current->hwTexBlendClr1 = RGB_STAGE1; current->hwTexBlendAlpha1 =
+ A_STAGE1;
+ */
+
+ switch (texture_unit->EnvMode)
+ {
+ case GL_REPLACE:
+ switch (area->Format)
+ {
+ case GL_ALPHA8:
+ current->hwTexBlendClr1 = A_REPLACE_RGB_STAGE1;
+ current->hwTexBlendAlpha1 = A_REPLACE_A_STAGE1;
+ break;
+ case GL_INTENSITY8:
+ case GL_RGB8:
+ current->hwTexBlendClr1 = RGB_REPLACE__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = RGB_REPLACE__A_STAGE1;
+ break;
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_RGBA8:
+ current->hwTexBlendClr1 = RGBA_REPLACE__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = RGBA_REPLACE__A_STAGE1;
+ break;
+ }
+ break;
+
+ case GL_MODULATE:
+ switch (area->Format)
+ {
+ case GL_ALPHA8:
+ current->hwTexBlendClr1 = A_MODULATE_RGB_STAGE1;
+ current->hwTexBlendAlpha1 = A_MODULATE_A_STAGE1;
+ break;
+ case GL_LUMINANCE8:
+ case GL_RGB8:
+ current->hwTexBlendClr1 = RGB_MODULATE__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = RGB_MODULATE__A_STAGE1;
+ break;
+ case GL_INTENSITY8:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_RGBA8:
+ current->hwTexBlendClr1 = RGBA_MODULATE__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = RGBA_MODULATE__A_STAGE1;
+ break;
+ }
+ break;
+
+ case GL_DECAL:
+
+ switch (area->Format)
+ {
+ case GL_RGB8:
+ current->hwTexBlendClr1 = RGB_DECAL__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = RGB_DECAL__A_STAGE1;
+ break;
+ case GL_RGBA8:
+ current->hwTexBlendClr1 = RGBA_DECAL__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = RGBA_DECAL__A_STAGE1;
+ break;
+ }
+ break;
+
+ case GL_BLEND:
+ current->hwTexEnvColor =
+ ((DWORD) (texture_unit->EnvColor[3])) << 24 |
+ ((DWORD) (texture_unit->EnvColor[0])) << 16 |
+ ((DWORD) (texture_unit->EnvColor[1])) << 8 |
+ ((DWORD) (texture_unit->EnvColor[2]));
+ switch (area->Format)
+ {
+ case GL_ALPHA8:
+ current->hwTexBlendClr1 = A_BLEND_RGB_STAGE1;
+ current->hwTexBlendAlpha1 = A_BLEND_A_STAGE1;
+ break;
+ case GL_LUMINANCE8:
+ case GL_RGB8:
+ current->hwTexBlendClr1 = RGB_BLEND__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = RGB_BLEND__A_STAGE1;
+ break;
+ case GL_INTENSITY8:
+ current->hwTexBlendClr1 = I_BLEND__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = I_BLEND__A_STAGE1;
+ break;
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_RGBA8:
+ current->hwTexBlendClr1 = RGBA_BLEND__RGB_STAGE1;
+ current->hwTexBlendAlpha1 = RGBA_BLEND__A_STAGE1;
+ break;
+ }
+ break;
+ }
+
+ if ((current->hwTexBlendClr1 ^ prev->hwTexBlendClr1) ||
+ (current->hwTexBlendAlpha1 ^ prev->hwTexBlendAlpha1) ||
+ (current->hwTexEnvColor ^ prev->hwTexEnvColor))
+ {
+ prev->hwTexBlendClr1 = current->hwTexBlendClr1;
+ prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1;
+ prev->hwTexEnvColor = current->hwTexEnvColor;
+ hwcx->GlobalFlag |= GFLAG_TEXTUREENV_1;
+ }
+}
+
+static void
+sis_set_texobj_parm (GLcontext * ctx, GLtextureObject * object, int hw_unit)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ GLtextureImage *image = object->Image[0];
+ SIStextureArea *area = (SIStextureArea *) image->DriverData;
+
+ GLint TxLevel;
+ GLint i;
+
+ current->texture[hw_unit].hwTextureSet = 0UL;
+ current->texture[hw_unit].hwTextureMip = 0UL;
+
+ switch (area->Format)
+ {
+ case GL_RGBA8:
+ current->texture[hw_unit].hwTextureSet |= TEXEL_ABGR_8888_32;
+ break;
+ case GL_INTENSITY8:
+ current->texture[hw_unit].hwTextureSet |= TEXEL_I8;
+ break;
+ case GL_ALPHA8:
+ current->texture[hw_unit].hwTextureSet |= TEXEL_A8;
+ break;
+ case GL_LUMINANCE8:
+ current->texture[hw_unit].hwTextureSet |= TEXEL_L8;
+ break;
+ case GL_LUMINANCE8_ALPHA8:
+ current->texture[hw_unit].hwTextureSet |= TEXEL_AL88;
+ break;
+ case GL_RGB8:
+ current->texture[hw_unit].hwTextureSet |= TEXEL_ABGR_0888_32;
+ break;
+ default:
+ hwcx->swRenderFlag |= SIS_SW_TEXTURE_OBJ;
+ }
+
+ if ((object->MinFilter == GL_NEAREST) || (object->MinFilter == GL_LINEAR))
+ {
+ TxLevel = 0;
+ }
+ else
+ {
+ TxLevel = object->P;
+ }
+
+ if (TxLevel < SIS_MAX_MIPMAP_LEVEL)
+ {
+ current->texture[hw_unit].hwTextureSet |= (TxLevel << 8);
+ }
+ else
+ {
+ /* can i limit capacity */
+ hwcx->swRenderFlag |= SIS_SW_TEXTURE_OBJ;
+ }
+
+ switch (object->MagFilter)
+ {
+ case GL_NEAREST:
+ current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST;
+ break;
+
+ case GL_LINEAR:
+ current->texture[hw_unit].hwTextureMip |= (TEXTURE_FILTER_LINEAR << 3);
+ break;
+ }
+
+ switch (object->MinFilter)
+ {
+ case GL_NEAREST:
+ current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST;
+ break;
+
+ case GL_LINEAR:
+ current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_LINEAR;
+ break;
+
+ case GL_NEAREST_MIPMAP_NEAREST:
+ current->texture[hw_unit].hwTextureMip |=
+ TEXTURE_FILTER_NEAREST_MIP_NEAREST;
+ break;
+
+ case GL_NEAREST_MIPMAP_LINEAR:
+ current->texture[hw_unit].hwTextureMip |=
+ TEXTURE_FILTER_NEAREST_MIP_LINEAR;
+ break;
+
+ case GL_LINEAR_MIPMAP_NEAREST:
+ current->texture[hw_unit].hwTextureMip |=
+ TEXTURE_FILTER_LINEAR_MIP_NEAREST;
+ break;
+
+ case GL_LINEAR_MIPMAP_LINEAR:
+ current->texture[hw_unit].hwTextureMip |=
+ TEXTURE_FILTER_LINEAR_MIP_LINEAR;
+ break;
+ }
+
+ switch (object->WrapS)
+ {
+ case GL_REPEAT:
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapU;
+ break;
+ case GL_CLAMP:
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureClampU;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ /*
+ * ?? not support yet
+ */
+ break;
+ }
+
+ switch (object->WrapT)
+ {
+ case GL_REPEAT:
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapV;
+ break;
+ case GL_CLAMP:
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureClampV;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ /*
+ * ?? not support yet
+ */
+ break;
+ }
+
+/*
+ if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampU) {
+ current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampU;
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderU;
+ }
+
+ if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampV) {
+ current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampV;
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderV;
+ }
+*/
+ current->texture[hw_unit].hwTextureBorderColor =
+ ((GLuint) object->BorderColor[3] << 24) +
+ ((GLuint) object->BorderColor[0] << 16) +
+ ((GLuint) object->BorderColor[1] << 8) +
+ ((GLuint) object->BorderColor[2]);
+
+ if (current->texture[hw_unit].hwTextureBorderColor ^
+ prev->texture[hw_unit].hwTextureBorderColor)
+ {
+ prev->texture[hw_unit].hwTextureBorderColor =
+ current->texture[hw_unit].hwTextureBorderColor;
+ if (hw_unit == 1)
+ hwcx->GlobalFlag |= GFLAG_TEXBORDERCOLOR_1;
+ else
+ hwcx->GlobalFlag |= GFLAG_TEXBORDERCOLOR;
+ }
+
+ current->texture[hw_unit].hwTextureSet |= (image->WidthLog2 << 4);
+ current->texture[hw_unit].hwTextureSet |= (image->HeightLog2);
+
+ {
+ if (hw_unit == 0)
+ hwcx->GlobalFlag |= GFLAG_TEXTUREADDRESS;
+ else
+ hwcx->GlobalFlag |= GFLAG_TEXTUREADDRESS_1;
+
+ for (i = 0; i < TxLevel + 1; i++)
+ {
+ SIStextureArea *area =
+ (SIStextureArea *) object->Image[i]->DriverData;
+ GLuint texOffset = ((GLuint) area->Data - (GLuint) GET_FbBase (hwcx));
+ GLuint texPitch = TransferTexturePitch (area->Pitch);
+
+ switch (i)
+ {
+ case 0:
+ prev->texture[hw_unit].texOffset0 = texOffset;
+ prev->texture[hw_unit].texPitch01 = texPitch << 16;
+ break;
+ case 1:
+ prev->texture[hw_unit].texOffset1 = texOffset;
+ prev->texture[hw_unit].texPitch01 |= texPitch;
+ break;
+ case 2:
+ prev->texture[hw_unit].texOffset2 = texOffset;
+ prev->texture[hw_unit].texPitch23 = texPitch << 16;
+ break;
+ case 3:
+ prev->texture[hw_unit].texOffset3 = texOffset;
+ prev->texture[hw_unit].texPitch23 |= texPitch;
+ break;
+ case 4:
+ prev->texture[hw_unit].texOffset4 = texOffset;
+ prev->texture[hw_unit].texPitch45 = texPitch << 16;
+ break;
+ case 5:
+ prev->texture[hw_unit].texOffset5 = texOffset;
+ prev->texture[hw_unit].texPitch45 |= texPitch;
+ break;
+ case 6:
+ prev->texture[hw_unit].texOffset6 = texOffset;
+ prev->texture[hw_unit].texPitch67 = texPitch << 16;
+ break;
+ case 7:
+ prev->texture[hw_unit].texOffset7 = texOffset;
+ prev->texture[hw_unit].texPitch67 |= texPitch;
+ break;
+ case 8:
+ prev->texture[hw_unit].texOffset8 = texOffset;
+ prev->texture[hw_unit].texPitch89 = texPitch << 16;
+ break;
+ case 9:
+ prev->texture[hw_unit].texOffset9 = texOffset;
+ prev->texture[hw_unit].texPitch89 |= texPitch;
+ break;
+ case 10:
+ prev->texture[hw_unit].texOffset10 = texOffset;
+ prev->texture[hw_unit].texPitch10 = texPitch << 16;
+ break;
+ case 11:
+ prev->texture[hw_unit].texOffset11 = texOffset;
+ prev->texture[hw_unit].texPitch10 |= texPitch;
+ break;
+ }
+ }
+ }
+
+ if (current->texture[hw_unit].hwTextureSet ^
+ prev->texture[hw_unit].hwTextureSet)
+ {
+ prev->texture[hw_unit].hwTextureSet =
+ current->texture[hw_unit].hwTextureSet;
+ if (hw_unit == 1)
+ hwcx->GlobalFlag |= CFLAG_TEXTURERESET_1;
+ else
+ hwcx->GlobalFlag |= CFLAG_TEXTURERESET;
+ }
+ if (current->texture[hw_unit].hwTextureMip ^
+ prev->texture[hw_unit].hwTextureMip)
+ {
+ prev->texture[hw_unit].hwTextureMip =
+ current->texture[hw_unit].hwTextureMip;
+ if (hw_unit == 1)
+ hwcx->GlobalFlag |= GFLAG_TEXTUREMIPMAP_1;
+ else
+ hwcx->GlobalFlag |= GFLAG_TEXTUREMIPMAP;
+ }
+}
+
+static void
+sis_reset_texture_env (GLcontext * ctx, int hw_unit)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __GLSiSHardware *prev = &hwcx->prev;
+ __GLSiSHardware *current = &hwcx->current;
+
+ if (hw_unit == 1)
+ {
+ current->hwTexBlendClr1 = RGB_STAGE1;
+ current->hwTexBlendAlpha1 = A_STAGE1;
+
+ if ((current->hwTexBlendClr1 ^ prev->hwTexBlendClr1) ||
+ (current->hwTexBlendAlpha1 ^ prev->hwTexBlendAlpha1) ||
+ (current->hwTexEnvColor ^ prev->hwTexEnvColor))
+ {
+ prev->hwTexBlendClr1 = current->hwTexBlendClr1;
+ prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1;
+ prev->hwTexEnvColor = current->hwTexEnvColor;
+ hwcx->GlobalFlag |= GFLAG_TEXTUREENV_1;
+ }
+ }
+ else
+ {
+ current->hwTexBlendClr0 = RGB_STAGE1;
+ current->hwTexBlendAlpha0 = A_STAGE1;
+
+ if ((current->hwTexBlendClr0 ^ prev->hwTexBlendClr0) ||
+ (current->hwTexBlendAlpha0 ^ prev->hwTexBlendAlpha0) ||
+ (current->hwTexEnvColor ^ prev->hwTexEnvColor))
+ {
+ prev->hwTexBlendClr0 = current->hwTexBlendClr0;
+ prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0;
+ prev->hwTexEnvColor = current->hwTexEnvColor;
+ hwcx->GlobalFlag |= GFLAG_TEXTUREENV;
+ }
+ }
+}
+
+static DWORD
+BitScanForward (WORD w)
+{
+ DWORD i;
+
+ for (i = 0; i < 16; i++)
+ {
+ if (w & (1 << i))
+ break;
+ }
+ return (i);
+}
+
+static DWORD
+TransferTexturePitch (DWORD dwPitch)
+{
+ DWORD dwRet, i;
+
+ i = BitScanForward ((WORD) dwPitch);
+ dwRet = dwPitch >> i;
+ dwRet |= i << 9;
+ return (dwRet);
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h b/xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h
new file mode 100644
index 000000000..126b1ac53
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h
@@ -0,0 +1,91 @@
+#define SIS_TRI_FUNC 1
+
+static void
+SIS_TAG (sis_tri) (GLcontext * ctx, GLuint v0, GLuint v1, GLuint v2,
+ GLuint pv)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ struct vertex_buffer *VB = ctx->VB;
+ float *MMIOBase = (float *) GET_IOBase (hwcx);
+
+ STEREO_SAMPLE(v0);
+
+ /* specular color is considered */
+ mWait3DCmdQueue (10 * 3 + 1);
+
+ if (SIS_STATES & (SIS_SMOOTH))
+ {
+ /*
+ * not move it to UpdateState because maybe optimization can be done
+ * according to FAN and STRIP
+ */
+ hwcx->dwPrimitiveSet &= ~0x07001f07;
+ hwcx->dwPrimitiveSet |=
+ (OP_3D_FIRE_TSARGBc | SHADE_GOURAUD | OP_3D_TRIANGLE_DRAW);
+ }
+ else
+ {
+ hwcx->dwPrimitiveSet &= ~0x07001f07;
+ hwcx->dwPrimitiveSet |=
+ (OP_3D_FIRE_TSARGBc | SHADE_FLAT_VertexC | OP_3D_TRIANGLE_DRAW);
+ }
+
+ {
+ ((DWORD *) MMIOBase)[REG_3D_PrimitiveSet / 4] = hwcx->dwPrimitiveSet;
+ }
+
+#define LAST_VERTEX 0
+ SIS_MMIO_WRITE_VERTEX (v0, 0);
+ SIS_MMIO_WRITE_VERTEX (v1, 1);
+#undef LAST_VERTEX
+#define LAST_VERTEX 1
+ SIS_MMIO_WRITE_VERTEX (v2, 2);
+#undef LAST_VERTEX
+
+ /* debug
+ mEndPrimitive ();
+ WaitEngIdle(hwcx);
+ d2f_once (ctx);
+ */
+}
+
+static void
+SIS_TAG (sis_agp_tri) (GLcontext * ctx, GLuint v0, GLuint v1,
+ GLuint v2, GLuint pv)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ struct vertex_buffer *VB = ctx->VB;
+
+ DWORD dcSARGB;
+
+ STEREO_SAMPLE(v0);
+
+ /* delete if VB size <= AGP_ALLOC_SIZE */
+#if 0
+ if ((DWORD) AGP_CurrentPtr - (DWORD) AGP_StartPtr >= (AGP_ALLOC_SIZE - 0x10))
+ {
+ sis_FlushAGP (ctx);
+ sis_StartAGP (ctx);
+ }
+#endif
+
+#define FIRST_VERTEX 1
+ SIS_AGP_WRITE_VERTEX (v0);
+#undef FIRST_VERTEX
+#define FIRST_VERTEX 0
+ SIS_AGP_WRITE_VERTEX (v1);
+ SIS_AGP_WRITE_VERTEX (v2);
+#undef FIRST_VERTEX
+}
+
+#undef SIS_MMIO_WRITE_VERTEX
+#undef SIS_AGP_WRITE_VERTEX
+
+#undef SIS_TAG
+#undef SIS_IS_SMOOTH
+#undef SIS_STATES
+#undef SIS_TRI_FUNC
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c b/xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c
new file mode 100644
index 000000000..497d1cf96
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c
@@ -0,0 +1,962 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c,v 1.1 2000/06/30 19:30:29 dawes 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:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $PI: xc/programs/Xserver/GL/mesa/src/X/xf86glx.c,v 1.15 1999/08/04 18:14:14 faith Exp $
+ */
+
+#include <miscstruct.h>
+#include <resource.h>
+#include <GL/gl.h>
+#include <GL/glxint.h>
+#include <GL/glxtokens.h>
+#include <scrnintstr.h>
+#include <config.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxext.h>
+#include <glxutil.h>
+#include "xf86glxint.h"
+#include "xmesaP.h"
+#include <GL/xf86glx.h>
+
+/*
+ * This define is for the glcore.h header file.
+ * If you add it here, then make sure you also add it in
+ * ../../../glx/Imakefile.
+ */
+#if 0
+#define DEBUG
+#include <GL/internal/glcore.h>
+#undef DEBUG
+#else
+#include <GL/internal/glcore.h>
+#endif
+
+
+/*
+ * This structure is statically allocated in the __glXScreens[]
+ * structure. This struct is not used anywhere other than in
+ * __glXScreenInit to initialize each of the active screens
+ * (__glXActiveScreens[]). Several of the fields must be initialized by
+ * the screenProbe routine before they are copied to the active screens
+ * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
+ * and numUsableVisuals fields must be initialized.
+ */
+__GLXscreenInfo __glDDXScreenInfo = {
+ __MESA_screenProbe, /* Must be generic and handle all screens */
+ __MESA_createContext, /* Substitute screen's createContext routine */
+ __MESA_createBuffer, /* Substitute screen's createBuffer routine */
+ NULL, /* Set up pGlxVisual in probe */
+ NULL, /* Set up pVisualPriv in probe */
+ 0, /* Set up numVisuals in probe */
+ 0, /* Set up numUsableVisuals in probe */
+ "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */
+ "Version String", /* GLXversion is overwritten by __glXScreenInit */
+ "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */
+ NULL /* WrappedPositionWindow is overwritten */
+};
+
+__GLXextensionInfo __glDDXExtensionInfo = {
+ GL_CORE_MESA,
+ __MESA_resetExtension,
+ __MESA_initVisuals,
+ __MESA_setVisualConfigs
+};
+
+__MESA_screen MESAScreens[MAXSCREENS];
+__GLcontext *MESA_CC = NULL;
+
+int numConfigs = 0;
+__GLXvisualConfig *visualConfigs = NULL;
+void **visualPrivates = NULL;
+
+static int count_bits(unsigned int n)
+{
+ int bits = 0;
+
+ while (n > 0) {
+ if (n & 1) bits++;
+ n >>= 1;
+ }
+ return bits;
+}
+
+static XMesaVisual find_mesa_visual(int screen, VisualID vid)
+{
+ XMesaVisual xm_vis = NULL;
+ __MESA_screen *pMScr = &MESAScreens[screen];
+ int i;
+
+ for (i = 0; i < pMScr->num_vis; i++) {
+ if (pMScr->glx_vis[i].vid == vid) {
+ break;
+ }
+ }
+
+ if (i < pMScr->num_vis) {
+ xm_vis = pMScr->xm_vis[i];
+ }
+ return xm_vis;
+}
+
+#define VISUAL_CONFIG(rgba,accum,back,depth,stencil,rating) \
+{ \
+ -1, /* vid */ \
+ -1, /* class */ \
+ rgba, /* rgba */ \
+ -1, -1, -1, 0, /* rgba sizes, alpha not supported, yet */ \
+ -1, -1, -1, 0, /* rgba masks, alpha not supported, yet */ \
+ accum, accum, accum, accum, /* rgba accum sizes */ \
+ back, /* doubleBuffer */ \
+ GL_FALSE, /* stereo */ \
+ -1, /* bufferSize */ \
+ depth, /* depthSize */ \
+ stencil, /* stencilSize */ \
+ 0, /* auxBuffers */ \
+ 0, /* level */ \
+ rating, /* visualRating */ \
+ 0, /* transparentPixel */ \
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ \
+ 0 /* transparentIndex */ \
+}
+
+#define IS_RGBA GL_TRUE
+#define IS_CI GL_FALSE
+#define HAS_ACCUM ACCUM_BITS
+#define NO_ACCUM 0
+#define HAS_BACK GL_TRUE
+#define NO_BACK GL_FALSE
+#define HAS_DEPTH DEPTH_BITS
+#define NO_DEPTH 0
+#define HAS_STENCIL STENCIL_BITS
+#define NO_STENCIL 0
+
+static __GLXvisualConfig __MESAvisualConfigs[] = {
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, 0, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, 16, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, 32, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, 24, 8, 0),
+
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, 0, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, 16, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, 32, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, 24, 8, 0),
+
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, NO_BACK, 0, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, NO_BACK, 16, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, NO_BACK, 32, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, NO_BACK, 24, 8, 0),
+
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, 0, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, 16, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, 32, 0, 0),
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, 24, 8, 0),
+/*
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, HAS_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0),
+*/
+};
+
+/*
+static __GLXvisualConfig __MESAvisualConfigs[] = {
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, HAS_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, HAS_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0),
+ VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, HAS_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0),
+ VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0),
+};
+*/
+
+static int __numMESAvisualConfigs =
+ sizeof(__MESAvisualConfigs)/sizeof(__GLXvisualConfig);
+static int __numRGBconfigs = -1;
+static int __numCIconfigs = -1;
+
+static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
+{
+ int numVisuals = *nvisualp;
+ int numMesaVisuals = 0;
+ int numMergedVisualConfigs = 0;
+ VisualPtr pVisual = *visualp;
+ VisualPtr pVisualNew = NULL;
+ VisualID *orig_vid = NULL;
+ __GLXvisualConfig *glXVisualPtr = NULL;
+ __GLXvisualConfig *pMergedVisualConfigs = NULL;
+ void **glXVisualPriv;
+ void **pMergedVisualPriv;
+ int *mesaConfigUsed;
+ int *driverConfigUsed;
+ int found_default = FALSE;
+ int i, j, k;
+ int is_rgb;
+ Bool match;
+
+ /* Alloc space for the list of merged GLX visuals */
+ pMergedVisualConfigs =
+ (__GLXvisualConfig *)__glXMalloc((numConfigs +
+ __numMESAvisualConfigs) *
+ sizeof(__GLXvisualConfig));
+ if (!pMergedVisualConfigs) {
+ return FALSE;
+ }
+
+ /* Alloc space for the list of merged GLX visual privates */
+ pMergedVisualPriv =
+ (void **)__glXMalloc((numConfigs + __numMESAvisualConfigs) *
+ sizeof(void *));
+ if (!pMergedVisualPriv) {
+ __glXFree(pMergedVisualConfigs);
+ return FALSE;
+ }
+
+ /* Compute the intersection of the driver's visual configs */
+ mesaConfigUsed = __glXCalloc(__numMESAvisualConfigs, sizeof(int));
+ driverConfigUsed = __glXCalloc(numConfigs, sizeof(int));
+
+ for (i = j = 0; i < numConfigs; i++) {
+ k = 0;
+ while ((k < __numMESAvisualConfigs) && (!driverConfigUsed[i])) {
+ if (!mesaConfigUsed[k]) {
+
+#ifdef DEBUG_VISUAL_CONFIG
+#define TEST_AND_COPY(fld) do { \
+ if (match) { \
+ if ((__MESAvisualConfigs[k].fld == visualConfigs[i].fld) || \
+ (__MESAvisualConfigs[k].fld == -1)) { \
+ pMergedVisualConfigs[j].fld = visualConfigs[i].fld; \
+ } \
+ else if (visualConfigs[i].fld == -1) { \
+ pMergedVisualConfigs[j].fld = __MESAvisualConfigs[k].fld; \
+ } \
+ else { \
+ match = FALSE; \
+ xf86DrvMsg (0, 0, "[GLXVisualInit] mismatch: " \
+ "(%s) DriverVisualConfig[%d] MesaVisualConfig[%d]\n", \
+ #fld, i, k); \
+ } \
+ } \
+ } while (0)
+#else
+#define TEST_AND_COPY(fld) do { \
+ if (match) { \
+ if ((__MESAvisualConfigs[k].fld == visualConfigs[i].fld) || \
+ (__MESAvisualConfigs[k].fld == -1)) { \
+ pMergedVisualConfigs[j].fld = visualConfigs[i].fld; \
+ } \
+ else if (visualConfigs[i].fld == -1) { \
+ pMergedVisualConfigs[j].fld = __MESAvisualConfigs[k].fld; \
+ } \
+ else { \
+ match = FALSE; \
+ } \
+ } \
+ } while (0)
+#endif
+
+ match = TRUE;
+ TEST_AND_COPY(class);
+ TEST_AND_COPY(rgba);
+ TEST_AND_COPY(redSize);
+ TEST_AND_COPY(greenSize);
+ TEST_AND_COPY(blueSize);
+ TEST_AND_COPY(alphaSize);
+ TEST_AND_COPY(redMask);
+ TEST_AND_COPY(greenMask);
+ TEST_AND_COPY(blueMask);
+ TEST_AND_COPY(alphaMask);
+ TEST_AND_COPY(accumRedSize);
+ TEST_AND_COPY(accumGreenSize);
+ TEST_AND_COPY(accumBlueSize);
+ TEST_AND_COPY(accumAlphaSize);
+ TEST_AND_COPY(doubleBuffer);
+ TEST_AND_COPY(stereo);
+ TEST_AND_COPY(bufferSize);
+ TEST_AND_COPY(depthSize);
+ TEST_AND_COPY(stencilSize);
+ TEST_AND_COPY(auxBuffers);
+ TEST_AND_COPY(level);
+ TEST_AND_COPY(visualRating);
+ TEST_AND_COPY(transparentPixel);
+ TEST_AND_COPY(transparentRed);
+ TEST_AND_COPY(transparentGreen);
+ TEST_AND_COPY(transparentBlue);
+ TEST_AND_COPY(transparentAlpha);
+ TEST_AND_COPY(transparentIndex);
+ if (match) {
+ driverConfigUsed[i] = TRUE;
+ mesaConfigUsed[k] = TRUE;
+ pMergedVisualPriv[j] = visualPrivates[i];
+ j++;
+#ifdef DEBUG_VISUAL_CONFIG
+ xf86DrvMsg (0, 0, "[GLXVisualInit] MATCH: "
+ "DriverVisualConfig[%d] MesaVisualConfig[%d]\n", i, k);
+#endif
+ }
+ }
+ k++;
+ }
+ }
+
+ /*
+ ** If SetVisualConfigs was not called, then just make all of Mesa's
+ ** visual configs available.
+ */
+ if (!numConfigs) {
+ memcpy(pMergedVisualConfigs, __MESAvisualConfigs,
+ sizeof(__GLXvisualConfig) * __numMESAvisualConfigs);
+ memset(pMergedVisualPriv, 0, sizeof(void *) * __numMESAvisualConfigs);
+ memset(mesaConfigUsed, TRUE, sizeof(int) * __numMESAvisualConfigs);
+ j = __numMESAvisualConfigs;
+ }
+
+ /*
+ ** This code is not currently used. When the visual caveat
+ ** extension is supported by the DRI and Mesa, we can take advantage
+ ** of this code.
+ */
+#if 0
+ /* Add any unclaimed MESA configs w/ slow caveat */
+ for (i = 0; i < __numMESAvisualConfigs; i++) {
+ if (!mesaConfigUsed[i]) {
+ memcpy(&pMergedVisualConfigs[j], &__MESAvisualConfigs[i],
+ sizeof(__GLXvisualConfig));
+ pMergedVisualConfigs[j].visualRating = GLX_SLOW_VISUAL_EXT;
+ j++;
+#ifdef DEBUG_VISUAL_CONFIG
+ xf86DrvMsg (0, 0, "[GLXVisualInit] slow config: "
+ "MesaVisualConfig[%d]\n", i);
+#endif
+ }
+ }
+
+ /* Add any unclaimed driver configs w/ nonconformant caveat */
+ for (i = 0; i < numConfigs; i++) {
+ if (!driverConfigUsed[i]) {
+ memcpy(&pMergedVisualConfigs[j], &visualConfigs[i],
+ sizeof(__GLXvisualConfig));
+ pMergedVisualConfigs[j].visualRating = GLX_NON_CONFORMANT_VISUAL_EXT;
+ j++;
+#ifdef DEBUG_VISUAL_CONFIG
+ xf86DrvMsg (0, 0, "[GLXVisualInit] non-conformant config: "
+ "DriverVisualConfig[%d]\n", i);
+#endif
+ }
+ }
+#endif
+
+ numMergedVisualConfigs = j;
+
+ /* Count the number of RGB and CI visual configs */
+ __numRGBconfigs = __numCIconfigs = 0;
+ for (i = 0; i < numMergedVisualConfigs; i++) {
+ if (pMergedVisualConfigs[i].rgba)
+ __numRGBconfigs++;
+ else
+ __numCIconfigs++;
+ }
+
+ /* Count the total number of visuals to compute */
+ for (i = 0; i < numVisuals; i++) {
+ numMesaVisuals +=
+ (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor)
+ ? __numRGBconfigs : __numCIconfigs;
+ }
+
+ /* Reset variables for use with the next screen/driver's visual configs */
+ visualConfigs = NULL;
+ numConfigs = 0;
+
+ /* Alloc temp space for the list of orig VisualIDs for each new visual */
+ orig_vid = (VisualID *)__glXMalloc(numMesaVisuals * sizeof(VisualID));
+ if (!orig_vid) {
+ __glXFree(pMergedVisualPriv);
+ __glXFree(pMergedVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisuals */
+ glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numMesaVisuals *
+ sizeof(__GLXvisualConfig));
+ if (!glXVisualPtr) {
+ __glXFree(orig_vid);
+ __glXFree(pMergedVisualPriv);
+ __glXFree(pMergedVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisualPrivates */
+ glXVisualPriv = (void **)__glXMalloc(numMesaVisuals * sizeof(void *));
+ if (!glXVisualPriv) {
+ __glXFree(glXVisualPtr);
+ __glXFree(orig_vid);
+ __glXFree(pMergedVisualPriv);
+ __glXFree(pMergedVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the new list of the X server's visuals */
+ pVisualNew = (VisualPtr)__glXMalloc(numMesaVisuals * sizeof(VisualRec));
+ if (!pVisualNew) {
+ __glXFree(glXVisualPriv);
+ __glXFree(glXVisualPtr);
+ __glXFree(orig_vid);
+ __glXFree(pMergedVisualPriv);
+ __glXFree(pMergedVisualConfigs);
+ return FALSE;
+ }
+
+ /* Initialize the new visuals */
+ for (i = j = 0; i < numVisuals; i++) {
+ is_rgb = (pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor);
+
+ for (k = 0; k < numMergedVisualConfigs; k++) {
+ if (pMergedVisualConfigs[k].rgba != is_rgb)
+ continue;
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ glXVisualPtr[j] = pMergedVisualConfigs[k];
+ glXVisualPtr[j].vid = pVisualNew[j].vid;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (glXVisualPtr[j].class == -1) {
+ glXVisualPtr[j].class = pVisual[i].class;
+ glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask);
+ glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask);
+ glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask);
+ glXVisualPtr[j].alphaSize = 0; /* Not supported in Mesa */
+ glXVisualPtr[j].redMask = pVisual[i].redMask;
+ glXVisualPtr[j].greenMask = pVisual[i].greenMask;
+ glXVisualPtr[j].blueMask = pVisual[i].blueMask;
+ glXVisualPtr[j].alphaMask = 0; /* Not supported in Mesa */
+ glXVisualPtr[j].bufferSize = rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pMergedVisualPriv[k];
+
+ j++;
+ }
+ }
+
+ /* Save the GLX visuals in the screen structure */
+ MESAScreens[screenInfo.numScreens-1].num_vis = numMesaVisuals;
+ MESAScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr;
+ MESAScreens[screenInfo.numScreens-1].private = glXVisualPriv;
+
+ /* Set up depth's VisualIDs */
+ for (i = 0; i < ndepth; i++) {
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numMesaVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numMesaVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
+ }
+
+ /* Update the X server's visuals */
+ *nvisualp = numMesaVisuals;
+ *visualp = pVisualNew;
+
+ /* Free the old list of the X server's visuals */
+ __glXFree(pVisual);
+
+ /* Clean up temporary allocations */
+ __glXFree(orig_vid);
+ __glXFree(pMergedVisualPriv);
+ __glXFree(pMergedVisualConfigs);
+
+ /* Free the private list created by DDX HW driver */
+ if (visualPrivates) xfree(visualPrivates);
+ visualPrivates = NULL;
+
+ return TRUE;
+}
+
+void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates)
+{
+ numConfigs = nconfigs;
+ visualConfigs = configs;
+ visualPrivates = privates;
+}
+
+Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp, int *rootDepthp,
+ VisualID *defaultVisp, unsigned long sizes,
+ int bitsPerRGB)
+{
+ /*
+ * Setup the visuals supported by this particular screen.
+ */
+ return init_visuals(nvisualp, visualp, defaultVisp,
+ *ndepthp, *depthp, *rootDepthp);
+}
+
+static void fixup_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ __MESA_screen *pMScr = &MESAScreens[screen];
+ __GLXvisualConfig *pGLXVis = pMScr->glx_vis;
+ VisualPtr pVis;
+ int i, j;
+
+ for (i = 0; i < pMScr->num_vis; i++, pGLXVis++) {
+ pVis = pScreen->visuals;
+
+ /* Find a visual that matches the GLX visual's class and size */
+ for (j = 0; j < pScreen->numVisuals; j++, pVis++) {
+ if (pVis->class == pGLXVis->class &&
+ pVis->nplanes == pGLXVis->bufferSize) {
+
+ /* Fixup the masks */
+ pGLXVis->redMask = pVis->redMask;
+ pGLXVis->greenMask = pVis->greenMask;
+ pGLXVis->blueMask = pVis->blueMask;
+
+ /* Recalc the sizes */
+ pGLXVis->redSize = count_bits(pGLXVis->redMask);
+ pGLXVis->greenSize = count_bits(pGLXVis->greenMask);
+ pGLXVis->blueSize = count_bits(pGLXVis->blueMask);
+ }
+ }
+ }
+}
+
+static void init_screen_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ __GLXvisualConfig *pGLXVis = MESAScreens[screen].glx_vis;
+ XMesaVisual *pXMesaVisual;
+ VisualPtr pVis;
+ int *used;
+ int i, j;
+
+ /* Alloc space for the list of XMesa visuals */
+ pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis *
+ sizeof(XMesaVisual));
+
+ used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
+ __glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
+
+ for (i = 0; i < MESAScreens[screen].num_vis; i++, pGLXVis++) {
+
+ pVis = pScreen->visuals;
+ for (j = 0; j < pScreen->numVisuals; j++, pVis++) {
+
+ if (pVis->class == pGLXVis->class &&
+ pVis->nplanes == pGLXVis->bufferSize &&
+ !used[j]) {
+
+ if (pVis->redMask == pGLXVis->redMask &&
+ pVis->greenMask == pGLXVis->greenMask &&
+ pVis->blueMask == pGLXVis->blueMask) {
+
+ /* Create the XMesa visual */
+ pXMesaVisual[i] =
+ XMesaCreateVisual(pScreen,
+ pVis,
+ pGLXVis->rgba,
+ (pGLXVis->alphaSize > 0),
+ pGLXVis->doubleBuffer,
+ pGLXVis->stereo,
+ GL_TRUE, /* ximage_flag */
+ pGLXVis->depthSize,
+ pGLXVis->stencilSize,
+ pGLXVis->accumRedSize,
+ pGLXVis->level);
+
+ /* Set the VisualID */
+ pGLXVis->vid = pVis->vid;
+
+ /* Mark this visual used */
+ used[j] = 1;
+ break;
+ }
+ }
+ }
+ }
+
+ __glXFree(used);
+
+ MESAScreens[screen].xm_vis = pXMesaVisual;
+}
+
+Bool __MESA_screenProbe(int screen)
+{
+ /*
+ * Set up the current screen's visuals.
+ */
+ __glDDXScreenInfo.pGlxVisual = MESAScreens[screen].glx_vis;
+ __glDDXScreenInfo.pVisualPriv = MESAScreens[screen].private;
+ __glDDXScreenInfo.numVisuals =
+ __glDDXScreenInfo.numUsableVisuals = MESAScreens[screen].num_vis;
+
+ /*
+ * Set the current screen's createContext routine. This could be
+ * wrapped by a DDX GLX context creation routine.
+ */
+ __glDDXScreenInfo.createContext = __MESA_createContext;
+
+ /*
+ * The ordering of the rgb compenents might have been changed by the
+ * driver after mi initialized them.
+ */
+ fixup_visuals(screen);
+
+ /*
+ * Find the GLX visuals that are supported by this screen and create
+ * XMesa's visuals.
+ */
+ init_screen_visuals(screen);
+
+ return TRUE;
+}
+
+extern void __MESA_resetExtension(void)
+{
+ int i, j;
+
+ XMesaReset();
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ for (j = 0; j < MESAScreens[i].num_vis; j++) {
+ XMesaDestroyVisual(MESAScreens[i].xm_vis[j]);
+ }
+ __glXFree(MESAScreens[i].glx_vis);
+ MESAScreens[i].glx_vis = NULL;
+ MESAScreens[i].num_vis = 0;
+ }
+ MESA_CC = NULL;
+}
+
+void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv)
+{
+ DrawablePtr pDraw = glxPriv->pDraw;
+ XMesaVisual xm_vis = find_mesa_visual(pDraw->pScreen->myNum,
+ glxPriv->pGlxVisual->vid);
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+ __MESA_buffer buf;
+
+ buf = (__MESA_buffer)__glXMalloc(sizeof(struct __MESA_bufferRec));
+
+ /* Create Mesa's buffers */
+ if (glxPriv->type == DRAWABLE_WINDOW) {
+ buf->xm_buf = (void *)XMesaCreateWindowBuffer(xm_vis,
+ (WindowPtr)pDraw);
+ } else {
+ buf->xm_buf = (void *)XMesaCreatePixmapBuffer(xm_vis,
+ (PixmapPtr)pDraw, 0);
+ }
+
+ /* Wrap the front buffer's resize routine */
+ buf->fbresize = glPriv->frontBuffer.resize;
+ glPriv->frontBuffer.resize = __MESA_resizeBuffers;
+
+ /* Wrap the swap buffers routine */
+ buf->fbswap = glxPriv->swapBuffers;
+ glxPriv->swapBuffers = __MESA_swapBuffers;
+
+ /* Save Mesa's private buffer structure */
+ glPriv->private = (void *)buf;
+ glPriv->freePrivate = __MESA_destroyBuffer;
+}
+
+GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buffer,
+ GLint x, GLint y,
+ GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv,
+ GLuint bufferMask)
+{
+ __MESA_buffer buf = (__MESA_buffer)glPriv->private;
+
+ if (buf->xm_buf && buf->xm_buf->xm_context) {
+ GLcontext *ctx = buf->xm_buf->xm_context->gl_ctx;
+ XMesaForceCurrent(buf->xm_buf->xm_context);
+ (*ctx->CurrentDispatch->ResizeBuffersMESA)();
+ if (MESA_CC)
+ XMesaForceCurrent(MESA_CC->xm_ctx);
+ }
+
+ return (*buf->fbresize)(buffer, x, y, width, height, glPriv, bufferMask);
+}
+
+GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv)
+{
+ __MESA_buffer buf = (__MESA_buffer)glxPriv->glPriv.private;
+
+ /*
+ ** Do not call the wrapped swap buffers routine since Mesa has
+ ** already done the swap.
+ */
+ XMesaSwapBuffers(buf->xm_buf);
+
+ return GL_TRUE;
+}
+
+void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv)
+{
+ __MESA_buffer buf = (__MESA_buffer)glPriv->private;
+ __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
+
+ /* Destroy Mesa's buffers */
+ if (buf->xm_buf)
+ XMesaDestroyBuffer(buf->xm_buf);
+
+ /* Unwrap these routines */
+ glxPriv->swapBuffers = buf->fbswap;
+ glPriv->frontBuffer.resize = buf->fbresize;
+
+ __glXFree(glPriv->private);
+ glPriv->private = NULL;
+}
+
+__GLinterface *__MESA_createContext(__GLimports *imports,
+ __GLcontextModes *modes,
+ __GLinterface *shareGC)
+{
+ __GLcontext *gl_ctx;
+ XMesaContext m_share = NULL;
+ XMesaVisual xm_vis;
+ __GLXcontext *glxc = (__GLXcontext *)imports->other;
+
+ gl_ctx = (__GLcontext *)__glXMalloc(sizeof(__GLcontext));
+ if (!gl_ctx)
+ return NULL;
+
+ gl_ctx->iface.imports = *imports;
+
+ gl_ctx->iface.exports.destroyContext = __MESA_destroyContext;
+ gl_ctx->iface.exports.loseCurrent = __MESA_loseCurrent;
+ gl_ctx->iface.exports.makeCurrent = __MESA_makeCurrent;
+ gl_ctx->iface.exports.shareContext = __MESA_shareContext;
+ gl_ctx->iface.exports.copyContext = __MESA_copyContext;
+ gl_ctx->iface.exports.forceCurrent = __MESA_forceCurrent;
+ gl_ctx->iface.exports.notifyResize = __MESA_notifyResize;
+ gl_ctx->iface.exports.notifyDestroy = __MESA_notifyDestroy;
+ gl_ctx->iface.exports.notifySwapBuffers = __MESA_notifySwapBuffers;
+ gl_ctx->iface.exports.dispatchExec = __MESA_dispatchExec;
+ gl_ctx->iface.exports.beginDispatchOverride = __MESA_beginDispatchOverride;
+ gl_ctx->iface.exports.endDispatchOverride = __MESA_endDispatchOverride;
+
+ if (shareGC) m_share = ((__GLcontext *)shareGC)->xm_ctx;
+ xm_vis = find_mesa_visual(glxc->pScreen->myNum, glxc->pGlxVisual->vid);
+ if (xm_vis) {
+ gl_ctx->xm_ctx = XMesaCreateContext(xm_vis, m_share);
+ } else {
+ __glXFree(gl_ctx);
+ gl_ctx = NULL;
+ }
+
+ return (__GLinterface *)gl_ctx;
+}
+
+GLboolean __MESA_destroyContext(__GLcontext *gc)
+{
+ XMesaDestroyContext(gc->xm_ctx);
+ __glXFree(gc);
+ return GL_TRUE;
+}
+
+GLboolean __MESA_loseCurrent(__GLcontext *gc)
+{
+ MESA_CC = NULL;
+ __glXLastContext = NULL;
+ return XMesaLoseCurrent(gc->xm_ctx);
+}
+
+GLboolean __MESA_makeCurrent(__GLcontext *gc, __GLdrawablePrivate *glPriv)
+{
+ __MESA_buffer buf = (__MESA_buffer)glPriv->private;
+
+ MESA_CC = gc;
+ return XMesaMakeCurrent(gc->xm_ctx, buf->xm_buf);
+}
+
+GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_shareContext\n");
+ return GL_FALSE;
+}
+
+GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_copyContext\n");
+ return GL_FALSE;
+}
+
+GLboolean __MESA_forceCurrent(__GLcontext *gc)
+{
+ MESA_CC = gc;
+ return XMesaForceCurrent(gc->xm_ctx);
+}
+
+GLboolean __MESA_notifyResize(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_notifyResize\n");
+ return GL_FALSE;
+}
+
+void __MESA_notifyDestroy(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_notifyDestroy\n");
+ return;
+}
+
+void __MESA_notifySwapBuffers(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_notifySwapBuffers\n");
+ return;
+}
+
+struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_dispatchExec\n");
+ return NULL;
+}
+
+void __MESA_beginDispatchOverride(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_beginDispatchOverride\n");
+ return;
+}
+
+void __MESA_endDispatchOverride(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_endDispatchOverride\n");
+ return;
+}
+
+GLint __glEvalComputeK(GLenum target)
+{
+ switch (target) {
+ case GL_MAP1_VERTEX_4:
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_4:
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_TEXTURE_COORD_4:
+ return 4;
+ case GL_MAP1_VERTEX_3:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_NORMAL:
+ case GL_MAP2_VERTEX_3:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_NORMAL:
+ return 3;
+ case GL_MAP1_TEXTURE_COORD_2:
+ case GL_MAP2_TEXTURE_COORD_2:
+ return 2;
+ case GL_MAP1_TEXTURE_COORD_1:
+ case GL_MAP2_TEXTURE_COORD_1:
+ case GL_MAP1_INDEX:
+ case GL_MAP2_INDEX:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+GLuint __glFloorLog2(GLuint val)
+{
+ int c = 0;
+
+ while (val > 1) {
+ c++;
+ val >>= 1;
+ }
+ return c;
+}
+
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c b/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c
new file mode 100644
index 000000000..7cce3e68b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c
@@ -0,0 +1,432 @@
+#include <unistd.h>
+#include <sys/mman.h>
+#include "sis_dri.h"
+
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+#include <X11/Xlibint.h>
+#include "context.h"
+#include "macros.h"
+#include "matrix.h"
+#include "mmath.h"
+#include "vbxform.h"
+#include "types.h"
+
+static XMesaContext XMesa = NULL; /* Current X/Mesa context pointer */
+
+#ifndef SIS_VERBOSE
+int SIS_VERBOSE = 0
+/* | VERBOSE_SIS_MEMORY */
+/* | VERBOSE_SIS_BUFFER */
+;
+#endif
+
+static GLboolean IsDriverInit = GL_FALSE;
+static sisRegion global_regs, global_agp;
+static GLubyte *global_FbBase;
+
+GLboolean XMesaInitDriver (__DRIscreenPrivate * driScrnPriv)
+{
+ SISDRIPtr priv = (SISDRIPtr) driScrnPriv->pDevPriv;
+
+ assert (driScrnPriv->devPrivSize == sizeof (SISDRIRec));
+
+ /* Fixme: in quake3, when context changed, XMesaInitDriver is called
+ * but XMesaResetDriver isn't. so i must check if regions are
+ * mapped two times.
+ * I can't use .map to know if they are mapped
+ */
+ if(IsDriverInit){
+ priv->regs = global_regs;
+ priv->agp = global_agp;
+ /* XXX */
+ driScrnPriv->pFB = global_FbBase;
+ return GL_TRUE;
+ }
+
+ if (drmMap (driScrnPriv->fd, priv->regs.handle, priv->regs.size,
+ &priv->regs.map))
+ {
+ return GL_FALSE;
+ }
+
+ if (priv->agp.size)
+ {
+ if (drmMap (driScrnPriv->fd, priv->agp.handle, priv->agp.size,
+ &priv->agp.map))
+ {
+ priv->agp.size = 0;
+ }
+ }
+
+ IsDriverInit = GL_TRUE;
+ global_regs = priv->regs;
+ global_agp = priv->agp;
+ global_FbBase = driScrnPriv->pFB;
+
+ return GL_TRUE;
+}
+
+void
+XMesaResetDriver (__DRIscreenPrivate * driScrnPriv)
+{
+ SISDRIPtr priv = (SISDRIPtr) driScrnPriv->pDevPriv;
+
+ drmUnmap (priv->regs.map, priv->regs.size);
+ priv->regs.map = 0;
+
+ if (priv->agp.size)
+ {
+ drmUnmap (priv->agp.map, priv->agp.size);
+ priv->agp.map = 0;
+ }
+
+ IsDriverInit = GL_FALSE;
+}
+
+/* from tdfx */
+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)
+{
+#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);
+ }
+ }
+#endif
+}
+
+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),
+ _mesa_bitcount(visinfo->green_mask),
+ _mesa_bitcount(visinfo->blue_mask),
+ config->alphaSize,
+ 0, /* index bits */
+ config->depthSize,
+ config->stencilSize,
+ config->accumRedSize,
+ config->accumGreenSize,
+ config->accumBlueSize,
+ config->accumAlphaSize,
+ 0 /* num samples */ );
+}
+
+GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
+ __DRIcontextPrivate *driContextPriv)
+{
+ XMesaContext c;
+
+ if (SIS_VERBOSE){
+ fprintf(stderr, "XMesaCreateContext\n");
+ }
+
+ c = (XMesaContext) calloc (1, sizeof (struct xmesa_context));
+ if (!c)
+ return GL_FALSE;
+
+ c->xm_visual = (XMesaVisual) calloc (1, sizeof (struct xmesa_visual));
+ if (!c->xm_visual)
+ return GL_FALSE;
+ c->xm_visual->gl_visual = mesaVis;
+ c->xm_visual->display = dpy;
+
+ c->gl_ctx = driContextPriv->mesaContext;
+
+ c->xm_buffer = NULL;
+ c->display = dpy;
+
+ c->gl_ctx->Driver.UpdateState = sis_UpdateState;
+
+ c->driContextPriv = driContextPriv;
+
+ c->gl_ctx->DriverCtx = (void *)c;
+
+ SiSCreateContext (c);
+
+ /* Fixme */
+ if (c->gl_ctx->NrPipelineStages)
+ c->gl_ctx->NrPipelineStages =
+ sis_RegisterPipelineStages( c->gl_ctx->PipelineStage,
+ c->gl_ctx->PipelineStage,
+ c->gl_ctx->NrPipelineStages);
+
+ driContextPriv->driverPrivate = (void *) c;
+
+ return GL_TRUE;
+}
+
+void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ XMesaContext c = (XMesaContext) driContextPriv->driverPrivate;
+
+ SiSDestroyContext (c);
+
+ if (c->xm_buffer)
+ c->xm_buffer->xm_context = NULL;
+
+ if (XMesa == c)
+ XMesa = NULL;
+
+ free(c->xm_visual);
+ free (c);
+}
+
+GLframebuffer *XMesaCreateWindowBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ GLvisual *mesaVis)
+{
+ if (mesaVis->RGBAflag){
+ return gl_create_framebuffer (mesaVis, GL_FALSE, GL_FALSE,
+ (mesaVis->AccumRedBits) ? GL_TRUE : GL_FALSE,
+ GL_FALSE);
+ }
+ else{
+ return gl_create_framebuffer (mesaVis,
+ (mesaVis->DepthBits) ? GL_TRUE : GL_FALSE,
+ (mesaVis->StencilBits) ? GL_TRUE : GL_FALSE,
+ (mesaVis->AccumRedBits) ? GL_TRUE : GL_FALSE,
+ GL_FALSE);
+ }
+}
+
+static XMesaBuffer SISCreateWindowBuffer ( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ GLvisual *mesaVis,
+ XMesaContext xmesa)
+{
+ XMesaBuffer b = (XMesaBuffer) calloc (1, sizeof (struct xmesa_buffer));
+
+ if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){
+ fprintf(stderr, "SISCreateWindowBuffer: drawable ID=%lu\n",
+ (DWORD)driDrawPriv);
+ }
+
+ if (!b)
+ 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->gl_buffer = driDrawPriv->mesaBuffer;
+
+ b->frontbuffer = driDrawPriv->draw;
+
+ /* set 0 for buffer update */
+ b->width = 0;
+ b->height = 0;
+
+ if (b->backimage)
+ {
+#if 0
+ XMesaDestroyImage (b->backimage);
+#else
+ free(b->backimage);
+#endif
+ b->backimage = NULL;
+ }
+
+#if 0
+ b->backimage = XCreateImage (b->display,
+ b->xm_visual->visinfo->visual,
+ GET_VISUAL_DEPTH (b->xm_visual), ZPixmap, 0,
+ NULL, b->width, b->height, 8, 0);
+#else
+ b->backimage = (XMesaImage *) calloc (1, sizeof (XImage));
+#endif
+
+ b->driDrawPriv = driDrawPriv;
+
+ {
+ sisBufferInfo *buf_info;
+
+ b->private = calloc (1, sizeof (sisBufferInfo));
+ buf_info = (sisBufferInfo *)(b->private);
+
+ buf_info->pZClearPacket = &buf_info->zClearPacket;
+ buf_info->pCbClearPacket = &buf_info->cbClearPacket;
+ }
+
+ return b;
+}
+
+GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ GLvisual *mesaVis)
+{
+ /* not implement yet */
+ return NULL;
+}
+
+static void SISDestroyBuffer (XMesaBuffer b)
+{
+ if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){
+ fprintf(stderr, "XMesaDestroyBuffer: b=%lu\n", (DWORD)b);
+ }
+
+ if (b->backimage && b->backimage->data)
+ {
+ sisBufferInfo *priv = (sisBufferInfo *) b->private;
+
+ sis_free_back_image (b, b->backimage, priv->bbFree);
+#if SIS_STEREO
+ {
+ XMesaContext xmesa = (XMesaContext) b->xm_context;
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ GLcontext *ctx = xmesa->gl_ctx;
+
+ if(hwcx->stereoEnabled){
+ sis_final_stereo(ctx);
+ hwcx->stereoEnabled = GL_FALSE;
+ }
+ }
+#endif
+ }
+
+ if (b->gl_buffer->DepthBuffer)
+ {
+ sis_free_z_stencil_buffer (b);
+ }
+
+ assert (b->private);
+ free (b->private);
+ b->private = NULL;
+
+ if (b->xm_context)
+ b->xm_context->xm_buffer = NULL;
+
+#if 0
+ XMesaDestroyImage (b->backimage);
+#else
+ free(b->backimage);
+#endif
+
+ /* TODO : if b doesn't exist, do something */
+
+ free (b);
+}
+
+void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
+{
+ __GLSiScontext *hwcx;
+
+ if(!XMesa)
+ return;
+
+ FLUSH_VB( XMesa->gl_ctx, "swap buffers" );
+
+ hwcx = (__GLSiScontext *) XMesa->private;
+ (hwcx->SwapBuffers)(XMesa->xm_buffer);
+}
+
+GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ /* TODO */
+ return GL_TRUE;
+}
+
+GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv)
+ {
+ XMesaContext c = (XMesaContext) driContextPriv->driverPrivate;
+ XMesaBuffer b;
+
+ /* TODO: ??? */
+ if ((c->gl_ctx == gl_get_current_context ()) &&
+ (driContextPriv->driDrawablePriv == driDrawPriv) &&
+ c->xm_buffer->wasCurrent)
+ {
+ return GL_TRUE;
+ }
+
+ if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){
+ fprintf(stderr, "XMesaMakeCurrent: c=%lu, b=%lu\n", (DWORD)c, (DWORD)b);
+ fprintf(stderr, "XMesaMakeCurrent: drawable ID=%lu\n", (DWORD)b->frontbuffer);
+ fprintf(stderr, "XMesaMakeCurrent: width=%d, height=%d\n",
+ b->width, b->height);
+ {
+ __DRIdrawablePrivate *dPriv = c->driContextPriv->driDrawablePriv;
+ fprintf(stderr, "XMesaMakeCurrent: width=%d, height=%d\n",
+ dPriv->w, dPriv->h);
+ }
+ }
+
+ b = SISCreateWindowBuffer(c->display,
+ driContextPriv->driScreenPriv,
+ driDrawPriv,
+ c->gl_ctx->Visual,
+ c);
+
+ if (c->xm_buffer){
+ /* TODO: ??? */
+ c->xm_buffer->xm_context = NULL;
+ SISDestroyBuffer(c->xm_buffer);
+ }
+
+ b->xm_context = c;
+ c->xm_buffer = b;
+
+ gl_make_current (c->gl_ctx, b->gl_buffer);
+ XMesa = c;
+
+ if(b->width == 0){
+ GLuint width, height;
+
+ sis_GetBufferSize (c->gl_ctx, &width, &height);
+ }
+
+ sis_update_drawable_state(c->gl_ctx);
+
+ if (c->gl_ctx->Viewport.Width == 0)
+ {
+ /* initialize viewport to window size */
+ gl_Viewport (c->gl_ctx, 0, 0, b->width, b->height);
+ c->gl_ctx->Scissor.Width = b->width;
+ c->gl_ctx->Scissor.Height = b->height;
+ }
+
+ c->xm_buffer->wasCurrent = GL_TRUE;
+ }
+ else
+ {
+ gl_make_current (NULL, NULL);
+ XMesa = NULL;
+ }
+
+ return GL_TRUE;
+}
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h b/xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h
new file mode 100644
index 000000000..7fcc026e8
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h
@@ -0,0 +1,557 @@
+
+/*
+ * 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.
+ */
+
+
+#ifndef XMESAP_H
+#define XMESAP_H
+
+
+#ifdef XFree86Server
+# include "GL/xf86glx.h"
+# include "xf86glx_util.h"
+#else
+# ifdef GLX_DIRECT_RENDERING
+# include "dri_mesa.h"
+# endif
+# ifdef USE_XSHM
+# include <X11/extensions/XShm.h>
+# endif
+#endif
+
+#ifdef XFree86Server
+# include "GL/xmesa.h"
+#else
+# include <X11/Xlib.h>
+# include <X11/Xutil.h>
+# include "GL/xmesa_x.h"
+# include "GL/gl.h"
+typedef struct xmesa_context *XMesaContext;
+typedef struct xmesa_visual *XMesaVisual;
+typedef struct xmesa_buffer *XMesaBuffer;
+#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"
+#else
+# define DRI_DRAWABLE_ARG
+# define DRI_DRAWABLE_PARM
+# 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 */
+ XMesaBuffer xm_buffer; /* current draw framebuffer */
+ XMesaBuffer xm_read_buffer; /* current read framebuffer */
+ 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
+};
+
+
+
+/*
+ * "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 */
+ XMesaVisual xm_visual; /* the X/Mesa visual */
+
+ XMesaContext xm_context; /* the context associated with this buffer */
+ 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
+
+ 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)))]
+
+
+
+/*
+ * 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}
+}
+};
+
+#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
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_xwin.c b/xc/lib/GL/mesa/src/drv/sis/sis_xwin.c
new file mode 100644
index 000000000..5b6268179
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_xwin.c
@@ -0,0 +1,171 @@
+#include "sis_ctx.h"
+#include "sis_mesa.h"
+
+#ifdef XFree86Server
+
+GLboolean
+sis_get_clip_rects (XMesaContext xmesa, BoxPtr *ppExtents, int *pCount)
+{
+ XMesaDrawable d = xmesa->xm_buffer->frontbuffer;
+
+ if (d->type == DRAWABLE_WINDOW)
+ {
+ RegionPtr pClipList = &((WindowPtr) d)->clipList;
+ RegDataPtr data = pClipList->data;
+
+ if (data)
+ {
+ *ppExtents =
+ (BoxPtr) ((GLubyte *) (pClipList->data) + sizeof (RegDataRec));
+ *pCount = data->numRects;
+ }
+ else
+ {
+ *ppExtents = &(pClipList->extents);
+ *pCount = 1;
+ }
+ }
+ else{
+ /* Pixmap */
+ /*
+ * TODO : sis_clear_color_buffer, sis_line_clip, sis_tri_clip don't
+ * consider this situation and result in page fault
+ */
+ *ppExtents = NULL;
+ *pCount = 0;
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+void *
+sis_get_drawable_pos (XMesaContext xmesa)
+{
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+ XMesaDrawable d = xmesa->xm_buffer->frontbuffer;
+
+ return GET_FbBase (hwcx) +
+ (d->x) * GET_DEPTH (hwcx) + (d->y) * GET_PITCH (hwcx);
+}
+
+void
+sis_get_drawable_origin (XMesaContext xmesa, GLuint * x, GLuint * y)
+{
+ XMesaDrawable d = xmesa->xm_buffer->frontbuffer;
+
+ *x = d->x;
+ *y = d->y;
+}
+
+void
+sis_get_drawable_size (XMesaContext xmesa, GLuint * w, GLuint * h)
+{
+ XMesaDrawable d = xmesa->xm_buffer->frontbuffer;
+
+ *w = d->width;
+ *h = d->height;
+}
+
+void
+sis_get_drawable_box (XMesaContext xmesa, BoxPtr pBox)
+{
+ XMesaDrawable d = xmesa->xm_buffer->frontbuffer;
+
+ pBox->x1 = d->x;
+ pBox->y1 = d->y;
+ pBox->x2 = d->x + d->width;
+ pBox->y2 = d->y + d->height;
+}
+
+#else
+
+GLboolean
+sis_get_clip_rects (XMesaContext xmesa, BoxPtr * ppExtents, int *pCount)
+{
+ __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv;
+
+/*
+ if (!sis_is_window (xmesa))
+ {
+ return GL_FALSE;
+ }
+*/
+
+/*
+ XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display,
+ xmesa->driContextPriv->driScreenPriv,
+ dPriv);
+*/
+
+ *ppExtents = (BoxPtr) dPriv->pClipRects;
+ *pCount = dPriv->numClipRects;
+
+ return GL_TRUE;
+}
+
+void *
+sis_get_drawable_pos (XMesaContext xmesa)
+{
+ __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
+
+ __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv;
+
+/*
+ XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display,
+ xmesa->driContextPriv->driScreenPriv,
+ dPriv);
+*/
+
+ return GET_FbBase (hwcx) + (dPriv->x) * GET_DEPTH (hwcx) +
+ (dPriv->y) * GET_PITCH (hwcx);
+}
+
+void
+sis_get_drawable_origin (XMesaContext xmesa, GLuint * x, GLuint * y)
+{
+ __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv;
+
+/*
+ XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display,
+ xmesa->driContextPriv->driScreenPriv,
+ dPriv);
+*/
+
+ *x = dPriv->x;
+ *y = dPriv->y;
+}
+
+void
+sis_get_drawable_size (XMesaContext xmesa, GLuint * w, GLuint * h)
+{
+ __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv;
+
+/*
+ XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display,
+ xmesa->driContextPriv->driScreenPriv,
+ dPriv);
+*/
+
+ *w = dPriv->w;
+ *h = dPriv->h;
+}
+
+void
+sis_get_drawable_box (XMesaContext xmesa, BoxPtr pBox)
+{
+ __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv;
+
+/*
+ XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display,
+ xmesa->driContextPriv->driScreenPriv,
+ dPriv);
+*/
+
+ pBox->x1 = dPriv->x;
+ pBox->y1 = dPriv->y;
+ pBox->x2 = dPriv->x + dPriv->w;
+ pBox->y2 = dPriv->y + dPriv->h;
+}
+
+#endif
diff --git a/xc/lib/X11/lcUniConv/iso8859_13.h b/xc/lib/X11/lcUniConv/iso8859_13.h
new file mode 100644
index 000000000..87edbffd0
--- /dev/null
+++ b/xc/lib/X11/lcUniConv/iso8859_13.h
@@ -0,0 +1,91 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_13.h,v 1.1 2000/06/23 19:50:59 dawes Exp $ */
+
+/*
+ * ISO-8859-13
+ */
+
+static const unsigned short iso8859_13_2uni[96] = {
+ /* 0xa0 */
+ 0x00a0, 0x201d, 0x00a2, 0x00a3, 0x00a4, 0x201e, 0x00a6, 0x00a7,
+ 0x00d8, 0x00a9, 0x0156, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00c6,
+ /* 0xb0 */
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x201c, 0x00b5, 0x00b6, 0x00b7,
+ 0x00f8, 0x00b9, 0x0157, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00e6,
+ /* 0xc0 */
+ 0x0104, 0x012e, 0x0100, 0x0106, 0x00c4, 0x00c5, 0x0118, 0x0112,
+ 0x010c, 0x00c9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012a, 0x013b,
+ /* 0xd0 */
+ 0x0160, 0x0143, 0x0145, 0x00d3, 0x014c, 0x00d5, 0x00d6, 0x00d7,
+ 0x0172, 0x0141, 0x015a, 0x016a, 0x00dc, 0x017b, 0x017d, 0x00df,
+ /* 0xe0 */
+ 0x0105, 0x012f, 0x0101, 0x0107, 0x00e4, 0x00e5, 0x0119, 0x0113,
+ 0x010d, 0x00e9, 0x017a, 0x0117, 0x0123, 0x0137, 0x012b, 0x013c,
+ /* 0xf0 */
+ 0x0161, 0x0144, 0x0146, 0x00f3, 0x014d, 0x00f5, 0x00f6, 0x00f7,
+ 0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019,
+};
+
+static int
+iso8859_13_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = *s;
+ if (c < 0xa0)
+ *pwc = (wchar_t) c;
+ else
+ *pwc = (wchar_t) iso8859_13_2uni[c-0xa0];
+ return 1;
+}
+
+static const unsigned char iso8859_13_page00[224] = {
+ 0xa0, 0x00, 0xa2, 0xa3, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */
+ 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+ 0xb0, 0xb1, 0xb2, 0xb3, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+ 0x00, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0x00, /* 0xb8-0xbf */
+ 0x00, 0x00, 0x00, 0x00, 0xc4, 0xc5, 0xaf, 0x00, /* 0xc0-0xc7 */
+ 0x00, 0xc9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+ 0x00, 0x00, 0x00, 0xd3, 0x00, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */
+ 0xa8, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */
+ 0x00, 0x00, 0x00, 0x00, 0xe4, 0xe5, 0xbf, 0x00, /* 0xe0-0xe7 */
+ 0x00, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+ 0x00, 0x00, 0x00, 0xf3, 0x00, 0xf5, 0xf6, 0xf7, /* 0xf0-0xf7 */
+ 0xb8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, /* 0xf8-0xff */
+ /* 0x0100 */
+ 0xc2, 0xe2, 0x00, 0x00, 0xc0, 0xe0, 0xc3, 0xe3, /* 0x00-0x07 */
+ 0x00, 0x00, 0x00, 0x00, 0xc8, 0xe8, 0x00, 0x00, /* 0x08-0x0f */
+ 0x00, 0x00, 0xc7, 0xe7, 0x00, 0x00, 0xcb, 0xeb, /* 0x10-0x17 */
+ 0xc6, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+ 0x00, 0x00, 0xcc, 0xec, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+ 0x00, 0x00, 0xce, 0xee, 0x00, 0x00, 0xc1, 0xe1, /* 0x28-0x2f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcd, 0xed, /* 0x30-0x37 */
+ 0x00, 0x00, 0x00, 0xcf, 0xef, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+ 0x00, 0xd9, 0xf9, 0xd1, 0xf1, 0xd2, 0xf2, 0x00, /* 0x40-0x47 */
+ 0x00, 0x00, 0x00, 0x00, 0xd4, 0xf4, 0x00, 0x00, /* 0x48-0x4f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xba, /* 0x50-0x57 */
+ 0x00, 0x00, 0xda, 0xfa, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+ 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+ 0x00, 0x00, 0xdb, 0xfb, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+ 0x00, 0x00, 0xd8, 0xf8, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+ 0x00, 0xca, 0xea, 0xdd, 0xfd, 0xde, 0xfe, 0x00, /* 0x78-0x7f */
+};
+static const unsigned char iso8859_13_page20[8] = {
+ 0x00, 0xff, 0x00, 0x00, 0xb4, 0xa1, 0xa5, 0x00, /* 0x18-0x1f */
+};
+
+static int
+iso8859_13_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+{
+ unsigned char c = 0;
+ if (wc < 0x00a0) {
+ *r = wc;
+ return 1;
+ }
+ else if (wc >= 0x00a0 && wc < 0x0180)
+ c = iso8859_13_page00[wc-0x00a0];
+ else if (wc >= 0x2018 && wc < 0x2020)
+ c = iso8859_13_page20[wc-0x2018];
+ if (c != 0) {
+ *r = c;
+ return 1;
+ }
+ return RET_ILSEQ;
+}
diff --git a/xc/lib/X11/lcUniConv/utf8.h b/xc/lib/X11/lcUniConv/utf8.h
new file mode 100644
index 000000000..0e6ad612f
--- /dev/null
+++ b/xc/lib/X11/lcUniConv/utf8.h
@@ -0,0 +1,110 @@
+/* $XFree86: xc/lib/X11/lcUniConv/utf8.h,v 1.1 2000/06/23 23:13:19 dawes Exp $ */
+
+/*
+ * UTF-8
+ */
+
+/* Specification: RFC 2279 */
+
+static int
+utf8_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+{
+ unsigned char c = s[0];
+
+ if (c < 0x80) {
+ *pwc = c;
+ return 1;
+ } else if (c < 0xc2) {
+ return RET_ILSEQ;
+ } else if (c < 0xe0) {
+ if (n < 2)
+ return RET_TOOFEW(0);
+ if (!((s[1] ^ 0x80) < 0x40))
+ return RET_ILSEQ;
+ *pwc = ((wchar_t) (c & 0x1f) << 6)
+ | (wchar_t) (s[1] ^ 0x80);
+ return 2;
+ } else if (c < 0xf0) {
+ if (n < 3)
+ return RET_TOOFEW(0);
+ 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);
+ return 3;
+ } else if (c < 0xf8 && sizeof(wchar_t)*8 >= 32) {
+ 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);
+ return 4;
+ } else if (c < 0xfc && sizeof(wchar_t)*8 >= 32) {
+ 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);
+ return 5;
+ } else if (c < 0xfe && sizeof(wchar_t)*8 >= 32) {
+ if (n < 6)
+ return RET_TOOFEW(0);
+ if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (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);
+ 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 */
+{
+ int count;
+ if (wc < 0x80)
+ count = 1;
+ else if (wc < 0x800)
+ count = 2;
+ else if (wc < 0x10000)
+ count = 3;
+ else if (wc < 0x200000)
+ count = 4;
+ else if (wc < 0x4000000)
+ count = 5;
+ else if (wc <= 0x7fffffff)
+ count = 6;
+ else
+ return RET_ILSEQ;
+ if (n < count)
+ return RET_TOOSMALL;
+ switch (count) { /* note: code falls through cases! */
+ case 6: r[5] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x4000000;
+ case 5: r[4] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x200000;
+ case 4: r[3] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x10000;
+ case 3: r[2] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x800;
+ case 2: r[1] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0xc0;
+ case 1: r[0] = wc;
+ }
+ return count;
+}
diff --git a/xc/lib/Xaw6/Xaw6os2.def b/xc/lib/Xaw6/Xaw6os2.def
new file mode 100644
index 000000000..8a92a2c28
--- /dev/null
+++ b/xc/lib/Xaw6/Xaw6os2.def
@@ -0,0 +1,205 @@
+LIBRARY Xaw6 INITINSTANCE TERMINSTANCE
+DESCRIPTION "@#XFREE86:4.0#@ $XFree86: xc/lib/Xaw6/Xaw6os2.def,v 1.1 2000/04/05 18:13:18 dawes Exp $"
+CODE
+ PRELOAD
+DATA
+ MULTIPLE NONSHARED
+STACKSIZE 32768
+EXPORTS
+ XawAsciiSourceFreeString @ 1
+ XawAsciiSave @ 2
+ XawAsciiSaveAsFile @ 3
+ XawAsciiSourceChanged @ 4
+ XawDialogAddButton @ 5
+ XawDialogGetValueString @ 6
+ XawFormDoLayout @ 7
+ XawListChange @ 8
+ XawListUnhighlight @ 9
+ XawListHighlight @ 10
+ XawListShowCurrent @ 11
+ XawPanedSetMinMax @ 13
+ XawPanedGetMinMax @ 14
+ XawPanedSetRefigureMode @ 15
+ XawPanedGetNumSub @ 16
+ XawScrollbarSetThumb @ 18
+ XawSimpleMenuAddGlobalActions @ 19
+ XawSimpleMenuGetActiveEntry @ 20
+ XawSimpleMenuClearActiveEntry @ 21
+ XawTextDisplay @ 22
+ XawTextEnableRedisplay @ 23
+ XawTextDisableRedisplay @ 24
+ XawTextSetSelectionArray @ 25
+ XawTextGetSelectionPos @ 26
+ XawTextSetSource @ 27
+ XawTextReplace @ 28
+ XawTextTopPosition @ 29
+ XawTextSetInsertionPoint @ 30
+ XawTextGetInsertionPoint @ 31
+ XawTextUnsetSelection @ 32
+ XawTextSetSelection @ 33
+ XawTextInvalidate @ 34
+ XawTextGetSource @ 35
+ XawTextSearch @ 36
+ XawTextDisplayCaret @ 37
+ XawTextSinkDisplayText @ 38
+ XawTextSinkInsertCursor @ 39
+ XawTextSinkClearToBackground @ 40
+ XawTextSinkFindPosition @ 41
+ XawTextSinkFindDistance @ 42
+ XawTextSinkResolve @ 43
+ XawTextSinkMaxLines @ 44
+ XawTextSinkMaxHeight @ 45
+ XawTextSinkSetTabs @ 46
+ XawTextSinkGetCursorBounds @ 47
+ XawTextSourceRead @ 48
+ XawTextSourceReplace @ 49
+ XawTextSourceScan @ 50
+ XawTextSourceSearch @ 51
+ XawTextSourceConvertSelection @ 52
+ XawTextSourceSetSelection @ 53
+ XawToggleChangeRadioGroup @ 54
+ XawToggleGetCurrent @ 55
+ XawToggleSetCurrent @ 56
+ XawToggleUnsetCurrent @ 57
+ XawTreeForceLayout @ 58
+ XawViewportSetLocation @ 59
+ XawViewportSetCoordinates @ 60
+ _XawMultiSinkPosToXY @ 61
+ _XawMultiSave @ 62
+ _XawMultiSaveAsFile @ 63
+ _XawMultiSourceFreeString @ 64
+ _XawTextFormat @ 65
+ _XawTextBuildLineTable @ 66
+ _XawTextGetSTRING @ 67
+ _XawTextSaltAwaySelection @ 68
+ _XawTextPosToXY @ 69
+ _XawTextWCToMB @ 70
+ _XawTextMBToWC @ 71
+ _Xaw_atowc @ 72
+ _XawImResizeVendorShell @ 73
+ _XawImGetShellHeight @ 74
+ _XawImRealize @ 75
+ _XawImInitialize @ 76
+ _XawImReconnect @ 77
+ _XawImRegister @ 78
+ _XawImUnregister @ 79
+ _XawImSetValues @ 80
+ _XawImSetFocusValues @ 82
+ _XawImUnsetFocus @ 84
+ _XawImWcLookupString @ 85
+ _XawImGetImAreaHeight @ 86
+ _XawImCallVendorShellExtResize @ 87
+ _XawImDestroy @ 88
+ _XawTextZapSelection @ 89
+ _XawTextInsertFileAction @ 90
+ _XawTextInsertFile @ 91
+ _XawTextDoSearchAction @ 92
+ _XawTextPopdownSearchAction @ 93
+ _XawTextSearch @ 94
+ _XawTextDoReplaceAction @ 95
+ _XawTextSetField @ 96
+ asciiSrcObjectClass @ 100
+ asciiSrcClassRec @ 101
+ dialogWidgetClass @ 102
+ dialogClassRec @ 103
+ formWidgetClass @ 104
+ formClassRec @ 105
+ listWidgetClass @ 106
+ listClassRec @ 107
+ multiSinkObjectClass @ 108
+ multiSinkClassRec @ 109
+ multiSrcObjectClass @ 110
+ multiSrcClassRec @ 111
+ panedWidgetClass @ 112
+ panedClassRec @ 113
+ scrollbarWidgetClass @ 114
+ scrollbarClassRec @ 115
+ simpleMenuWidgetClass @ 116
+ simpleMenuClassRec @ 117
+ FMT8BIT @ 118
+ XawFmt8Bit @ 119
+ XawFmtWide @ 120
+ _XawTextActionsTable @ 121
+ _XawTextActionsTableCount @ 122
+ textWidgetClass @ 123
+ textClassRec @ 124
+ textSinkObjectClass @ 125
+ textSinkClassRec @ 126
+ toggleWidgetClass @ 127
+ toggleClassRec @ 128
+ treeWidgetClass @ 129
+ treeClassRec @ 130
+ viewportWidgetClass @ 131
+ viewportClassRec @ 132
+ menuButtonClassRec @ 133
+ menuButtonWidgetClass @ 134
+ smeBSBClassRec @ 135
+ smeBSBObjectClass @ 136
+ smeLineClassRec @ 137
+ smeLineObjectClass @ 138
+ labelClassRec @ 139
+ labelWidgetClass @ 140
+ commandClassRec @ 141
+ commandWidgetClass @ 142
+ boxClassRec @ 143
+ boxWidgetClass @ 144
+ simpleClassRec @ 145
+ simpleWidgetClass @ 146
+ XawInitializeWidgetSet @ 147
+ asciiTextClassRec @ 148
+ asciiTextWidgetClass @ 149
+ portholeClassRec @ 150
+ portholeWidgetClass @ 151
+ pannerClassRec @ 152
+ pannerWidgetClass @ 153
+ textSrcClassRec @ 154
+ textSrcObjectClass @ 155
+ gripWidgetClass @ 156
+ XawWidgetArray @ 157
+ XawWidgetCount @ 158
+ XawPanedAllowResize @ 159
+ _XawTextNeedsUpdating @ 160
+ _XawTextGetText @ 161
+ _XawTextSetScrollBars @ 162
+ _XawTextVScroll @ 163
+ _XawTextReplace @ 164
+ _XawTextClearAndCenterDisplay @ 165
+ _XawTextCheckResize @ 166
+ _XawTextSelectionList @ 167
+ _XawTextSetSelection @ 168
+ _XawTextAlterSelection @ 169
+ _XawTextPrepareToUpdate @ 170
+ _XawTextShowPosition @ 171
+ _XawTextExecuteUpdate @ 172
+ XawVendorShellExtResize @ 173
+ asciiSinkClassRec @ 174
+ asciiSinkObjectClass @ 175
+ gripClassRec @ 176
+ vPanedWidgetClass @ 177
+ repeaterClassRec @ 178
+ repeaterWidgetClass @ 179
+ smeClassRec @ 180
+ smeObjectClass @ 181
+ stripChartClassRec @ 182
+ stripChartWidgetClass @ 183
+; _XawDefaultTextTranslations1 @ 184
+; _XawDefaultTextTranslations2 @ 185
+; _XawDefaultTextTranslations3 @ 186
+; vendorShellClassRec @ 187
+ _XawVendorShellClassRec @ 187
+; vendorShellWidgetClass @ 188
+; _XawDefaultTextTranslations4 @ 189
+ _XawDefaultTextTranslations @ 190
+;newAW _XawTextSrcUndo @ 191
+;newAW tipClassRec @ 192
+;newAW tipWidgetClass @ 193
+;newAW XawTipEnable @ 194
+;newAW XawTipDisable @ 195
+; XawTextSinkConvertPropertyList @ 196
+; XawTextGetSink @ 197
+; XawTextSourceClearEntities @ 198
+; XawTextSourceFindAnchor @ 199
+; XawTextSourcePrevAnchor @ 200
+; XawTextSourceNextAnchor @ 201
+; XawTextSourceAnchorAndEntity @ 202
+; XawTextSourceAddEntity @ 203
diff --git a/xc/lib/Xaw6/Xaw6os2.rsp b/xc/lib/Xaw6/Xaw6os2.rsp
new file mode 100644
index 000000000..a1bd96e42
--- /dev/null
+++ b/xc/lib/Xaw6/Xaw6os2.rsp
@@ -0,0 +1,10 @@
+Actions.obj AllWidgets.obj AsciiSink.obj AsciiSrc.obj AsciiText.obj Box.obj+
+Command.obj Converters.obj Dialog.obj DisplayList.obj Form.obj Grip.obj+
+Label.obj List.obj MenuButton.obj MultiSink.obj MultiSrc.obj OS.obj Paned.obj+
+Panner.obj Pixmap.obj Porthole.obj Repeater.obj Scrollbar.obj Simple.obj+
+SimpleMenu.obj Sme.obj SmeBSB.obj SmeLine.obj StripChart.obj Text.obj+
+TextAction.obj TextPop.obj TextSink.obj TextSrc.obj TextTr.obj+
+Toggle.obj Tree.obj Vendor.obj Viewport.obj XawI18n.obj XawIm.obj+
+XawInit.obj +/NOI /NOL /NOD /BAT
+Xaw6.dll
+Xaw6.map
diff --git a/xc/lib/dps/dpsops.h.os2 b/xc/lib/dps/dpsops.h.os2
new file mode 100644
index 000000000..44a2c3f60
--- /dev/null
+++ b/xc/lib/dps/dpsops.h.os2
@@ -0,0 +1,1601 @@
+/*
+ * dpsops.h
+ */
+
+/*
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+#ifndef DPSOPS_H
+#define DPSOPS_H
+
+#ifdef _NO_PROTO
+
+extern void DPSFontDirectory( /* DPSContext ctxt; */ );
+
+extern void DPSGlobalFontDirectory( /* DPSContext ctxt; */ );
+
+extern void DPSISOLatin1Encoding( /* DPSContext ctxt; */ );
+
+extern void DPSSharedFontDirectory( /* DPSContext ctxt; */ );
+
+extern void DPSStandardEncoding( /* DPSContext ctxt; */ );
+
+extern void DPSUserObjects( /* DPSContext ctxt; */ );
+
+extern void DPSabs( /* DPSContext ctxt; */ );
+
+extern void DPSadd( /* DPSContext ctxt; */ );
+
+extern void DPSaload( /* DPSContext ctxt; */ );
+
+extern void DPSanchorsearch( /* DPSContext ctxt; int *truth; */ );
+
+extern void DPSand( /* DPSContext ctxt; */ );
+
+extern void DPSarc( /* DPSContext ctxt; float x, y, r, angle1, angle2; */ );
+
+extern void DPSarcn( /* DPSContext ctxt; float x, y, r, angle1, angle2; */ );
+
+extern void DPSarct( /* DPSContext ctxt; float x1, y1, x2, y2, r; */ );
+
+extern void DPSarcto( /* DPSContext ctxt; float x1, y1, x2, y2, r; float *xt1, *yt1, *xt2, *yt2; */ );
+
+extern void DPSarray( /* DPSContext ctxt; int len; */ );
+
+extern void DPSashow( /* DPSContext ctxt; float x, y; char *s; */ );
+
+extern void DPSastore( /* DPSContext ctxt; */ );
+
+extern void DPSatan( /* DPSContext ctxt; */ );
+
+extern void DPSawidthshow( /* DPSContext ctxt; float cx, cy; int c; float ax, ay; char *s; */ );
+
+extern void DPSbanddevice( /* DPSContext ctxt; */ );
+
+extern void DPSbegin( /* DPSContext ctxt; */ );
+
+extern void DPSbind( /* DPSContext ctxt; */ );
+
+extern void DPSbitshift( /* DPSContext ctxt; int shift; */ );
+
+extern void DPSbytesavailable( /* DPSContext ctxt; int *n; */ );
+
+extern void DPScachestatus( /* DPSContext ctxt; */ );
+
+extern void DPSceiling( /* DPSContext ctxt; */ );
+
+extern void DPScharpath( /* DPSContext ctxt; char *s; int b; */ );
+
+extern void DPSclear( /* DPSContext ctxt; */ );
+
+extern void DPScleardictstack( /* DPSContext ctxt; */ );
+
+extern void DPScleartomark( /* DPSContext ctxt; */ );
+
+extern void DPSclientXready( /* DPSContext ctxt; int i0, i1, i2, i3; */ );
+
+extern void DPSclientsync( /* DPSContext ctxt; */ );
+
+extern void DPSclip( /* DPSContext ctxt; */ );
+
+extern void DPSclippath( /* DPSContext ctxt; */ );
+
+extern void DPSclosefile( /* DPSContext ctxt; */ );
+
+extern void DPSclosepath( /* DPSContext ctxt; */ );
+
+extern void DPScolorimage( /* DPSContext ctxt; */ );
+
+extern void DPSconcat( /* DPSContext ctxt; float m[]; */ );
+
+extern void DPSconcatmatrix( /* DPSContext ctxt; */ );
+
+extern void DPScondition( /* DPSContext ctxt; */ );
+
+extern void DPScopy( /* DPSContext ctxt; int n; */ );
+
+extern void DPScopypage( /* DPSContext ctxt; */ );
+
+extern void DPScos( /* DPSContext ctxt; */ );
+
+extern void DPScount( /* DPSContext ctxt; int *n; */ );
+
+extern void DPScountdictstack( /* DPSContext ctxt; int *n; */ );
+
+extern void DPScountexecstack( /* DPSContext ctxt; int *n; */ );
+
+extern void DPScounttomark( /* DPSContext ctxt; int *n; */ );
+
+extern void DPScshow( /* DPSContext ctxt; char *s; */ );
+
+extern void DPScurrentXdrawingfunction( /* DPSContext ctxt; int *function; */ );
+
+extern void DPScurrentXgcdrawable( /* DPSContext ctxt; int *gc, *draw, *x, *y; */ );
+
+extern void DPScurrentXgcdrawablecolor( /* DPSContext ctxt; int *gc, *draw, *x, *y, colorInfo[]; */ );
+
+extern void DPScurrentXoffset( /* DPSContext ctxt; int *x, *y; */ );
+
+extern void DPScurrentblackgeneration( /* DPSContext ctxt; */ );
+
+extern void DPScurrentcacheparams( /* DPSContext ctxt; */ );
+
+extern void DPScurrentcmykcolor( /* DPSContext ctxt; float *c, *m, *y, *k; */ );
+
+extern void DPScurrentcolor( /* DPSContext ctxt; */ );
+
+extern void DPScurrentcolorrendering( /* DPSContext ctxt; */ );
+
+extern void DPScurrentcolorscreen( /* DPSContext ctxt; */ );
+
+extern void DPScurrentcolorspace( /* DPSContext ctxt; */ );
+
+extern void DPScurrentcolortransfer( /* DPSContext ctxt; */ );
+
+extern void DPScurrentcontext( /* DPSContext ctxt; int *cid; */ );
+
+extern void DPScurrentdash( /* DPSContext ctxt; */ );
+
+extern void DPScurrentdevparams( /* DPSContext ctxt; char *dev; */ );
+
+extern void DPScurrentdict( /* DPSContext ctxt; */ );
+
+extern void DPScurrentfile( /* DPSContext ctxt; */ );
+
+extern void DPScurrentflat( /* DPSContext ctxt; float *flatness; */ );
+
+extern void DPScurrentfont( /* DPSContext ctxt; */ );
+
+extern void DPScurrentglobal( /* DPSContext ctxt; int *b; */ );
+
+extern void DPScurrentgray( /* DPSContext ctxt; float *gray; */ );
+
+extern void DPScurrentgstate( /* DPSContext ctxt; int gst; */ );
+
+extern void DPScurrenthalftone( /* DPSContext ctxt; */ );
+
+extern void DPScurrenthalftonephase( /* DPSContext ctxt; float *x, *y; */ );
+
+extern void DPScurrenthsbcolor( /* DPSContext ctxt; float *h, *s, *b; */ );
+
+extern void DPScurrentlinecap( /* DPSContext ctxt; int *linecap; */ );
+
+extern void DPScurrentlinejoin( /* DPSContext ctxt; int *linejoin; */ );
+
+extern void DPScurrentlinewidth( /* DPSContext ctxt; float *width; */ );
+
+extern void DPScurrentmatrix( /* DPSContext ctxt; */ );
+
+extern void DPScurrentmiterlimit( /* DPSContext ctxt; float *limit; */ );
+
+extern void DPScurrentobjectformat( /* DPSContext ctxt; int *code; */ );
+
+extern void DPScurrentoverprint( /* DPSContext ctxt; int *b; */ );
+
+extern void DPScurrentpacking( /* DPSContext ctxt; int *b; */ );
+
+extern void DPScurrentpagedevice( /* DPSContext ctxt; */ );
+
+extern void DPScurrentpoint( /* DPSContext ctxt; float *x, *y; */ );
+
+extern void DPScurrentrgbcolor( /* DPSContext ctxt; float *r, *g, *b; */ );
+
+extern void DPScurrentscreen( /* DPSContext ctxt; */ );
+
+extern void DPScurrentshared( /* DPSContext ctxt; int *b; */ );
+
+extern void DPScurrentstrokeadjust( /* DPSContext ctxt; int *b; */ );
+
+extern void DPScurrentsystemparams( /* DPSContext ctxt; */ );
+
+extern void DPScurrenttransfer( /* DPSContext ctxt; */ );
+
+extern void DPScurrentundercolorremoval( /* DPSContext ctxt; */ );
+
+extern void DPScurrentuserparams( /* DPSContext ctxt; */ );
+
+extern void DPScurveto( /* DPSContext ctxt; float x1, y1, x2, y2, x3, y3; */ );
+
+extern void DPScvi( /* DPSContext ctxt; */ );
+
+extern void DPScvlit( /* DPSContext ctxt; */ );
+
+extern void DPScvn( /* DPSContext ctxt; */ );
+
+extern void DPScvr( /* DPSContext ctxt; */ );
+
+extern void DPScvrs( /* DPSContext ctxt; */ );
+
+extern void DPScvs( /* DPSContext ctxt; */ );
+
+extern void DPScvx( /* DPSContext ctxt; */ );
+
+extern void DPSdef( /* DPSContext ctxt; */ );
+
+extern void DPSdefaultmatrix( /* DPSContext ctxt; */ );
+
+extern void DPSdefinefont( /* DPSContext ctxt; */ );
+
+extern void DPSdefineresource( /* DPSContext ctxt; char *category; */ );
+
+extern void DPSdefineusername( /* DPSContext ctxt; int i; char *username; */ );
+
+extern void DPSdefineuserobject( /* DPSContext ctxt; */ );
+
+extern void DPSdeletefile( /* DPSContext ctxt; char *filename; */ );
+
+extern void DPSdetach( /* DPSContext ctxt; */ );
+
+extern void DPSdeviceinfo( /* DPSContext ctxt; */ );
+
+extern void DPSdict( /* DPSContext ctxt; int len; */ );
+
+extern void DPSdictstack( /* DPSContext ctxt; */ );
+
+extern void DPSdiv( /* DPSContext ctxt; */ );
+
+extern void DPSdtransform( /* DPSContext ctxt; float x1, y1; float *x2, *y2; */ );
+
+extern void DPSdup( /* DPSContext ctxt; */ );
+
+extern void DPSecho( /* DPSContext ctxt; int b; */ );
+
+extern void DPSend( /* DPSContext ctxt; */ );
+
+extern void DPSeoclip( /* DPSContext ctxt; */ );
+
+extern void DPSeofill( /* DPSContext ctxt; */ );
+
+extern void DPSeoviewclip( /* DPSContext ctxt; */ );
+
+extern void DPSeq( /* DPSContext ctxt; */ );
+
+extern void DPSequals( /* DPSContext ctxt; */ );
+
+extern void DPSequalsequals( /* DPSContext ctxt; */ );
+
+extern void DPSerasepage( /* DPSContext ctxt; */ );
+
+extern void DPSerrordict( /* DPSContext ctxt; */ );
+
+extern void DPSexch( /* DPSContext ctxt; */ );
+
+extern void DPSexec( /* DPSContext ctxt; */ );
+
+extern void DPSexecform( /* DPSContext ctxt; */ );
+
+extern void DPSexecstack( /* DPSContext ctxt; */ );
+
+extern void DPSexecuserobject( /* DPSContext ctxt; int userObjIndex; */ );
+
+extern void DPSexecuteonly( /* DPSContext ctxt; */ );
+
+extern void DPSexit( /* DPSContext ctxt; */ );
+
+extern void DPSexp( /* DPSContext ctxt; */ );
+
+extern void DPSfalse( /* DPSContext ctxt; */ );
+
+extern void DPSfile( /* DPSContext ctxt; char *name, *access; */ );
+
+extern void DPSfilenameforall( /* DPSContext ctxt; */ );
+
+extern void DPSfileposition( /* DPSContext ctxt; int *pos; */ );
+
+extern void DPSfill( /* DPSContext ctxt; */ );
+
+extern void DPSfilter( /* DPSContext ctxt; */ );
+
+extern void DPSfindencoding( /* DPSContext ctxt; char *key; */ );
+
+extern void DPSfindfont( /* DPSContext ctxt; char *name; */ );
+
+extern void DPSfindresource( /* DPSContext ctxt; char *key, *category; */ );
+
+extern void DPSflattenpath( /* DPSContext ctxt; */ );
+
+extern void DPSfloor( /* DPSContext ctxt; */ );
+
+extern void DPSflush( /* DPSContext ctxt; */ );
+
+extern void DPSflushfile( /* DPSContext ctxt; */ );
+
+extern void DPSfor( /* DPSContext ctxt; */ );
+
+extern void DPSforall( /* DPSContext ctxt; */ );
+
+extern void DPSfork( /* DPSContext ctxt; */ );
+
+extern void DPSframedevice( /* DPSContext ctxt; */ );
+
+extern void DPSgcheck( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSge( /* DPSContext ctxt; */ );
+
+extern void DPSget( /* DPSContext ctxt; */ );
+
+extern void DPSgetboolean( /* DPSContext ctxt; int *it; */ );
+
+extern void DPSgetchararray( /* DPSContext ctxt; int size; char s[]; */ );
+
+extern void DPSgetfloat( /* DPSContext ctxt; float *it; */ );
+
+extern void DPSgetfloatarray( /* DPSContext ctxt; int size; float a[]; */ );
+
+extern void DPSgetint( /* DPSContext ctxt; int *it; */ );
+
+extern void DPSgetintarray( /* DPSContext ctxt; int size; int a[]; */ );
+
+extern void DPSgetinterval( /* DPSContext ctxt; */ );
+
+extern void DPSgetstring( /* DPSContext ctxt; char *s; */ );
+
+extern void DPSglobaldict( /* DPSContext ctxt; */ );
+
+extern void DPSglyphshow( /* DPSContext ctxt; char *name; */ );
+
+extern void DPSgrestore( /* DPSContext ctxt; */ );
+
+extern void DPSgrestoreall( /* DPSContext ctxt; */ );
+
+extern void DPSgsave( /* DPSContext ctxt; */ );
+
+extern void DPSgstate( /* DPSContext ctxt; */ );
+
+extern void DPSgt( /* DPSContext ctxt; */ );
+
+extern void DPSidentmatrix( /* DPSContext ctxt; */ );
+
+extern void DPSidiv( /* DPSContext ctxt; */ );
+
+extern void DPSidtransform( /* DPSContext ctxt; float x1, y1; float *x2, *y2; */ );
+
+extern void DPSif( /* DPSContext ctxt; */ );
+
+extern void DPSifelse( /* DPSContext ctxt; */ );
+
+extern void DPSimage( /* DPSContext ctxt; */ );
+
+extern void DPSimagemask( /* DPSContext ctxt; */ );
+
+extern void DPSindex( /* DPSContext ctxt; int i; */ );
+
+extern void DPSineofill( /* DPSContext ctxt; float x, y; int *b; */ );
+
+extern void DPSinfill( /* DPSContext ctxt; float x, y; int *b; */ );
+
+extern void DPSinitclip( /* DPSContext ctxt; */ );
+
+extern void DPSinitgraphics( /* DPSContext ctxt; */ );
+
+extern void DPSinitmatrix( /* DPSContext ctxt; */ );
+
+extern void DPSinitviewclip( /* DPSContext ctxt; */ );
+
+extern void DPSinstroke( /* DPSContext ctxt; float x, y; int *b; */ );
+
+extern void DPSinueofill( /* DPSContext ctxt; float x, y; char nums[]; int n; char ops[]; int l; int *b; */ );
+
+extern void DPSinufill( /* DPSContext ctxt; float x, y; char nums[]; int n; char ops[]; int l; int *b; */ );
+
+extern void DPSinustroke( /* DPSContext ctxt; float x, y; char nums[]; int n; char ops[]; int l; int *b; */ );
+
+extern void DPSinvertmatrix( /* DPSContext ctxt; */ );
+
+extern void DPSitransform( /* DPSContext ctxt; float x1, y1; float *x2, *y2; */ );
+
+extern void DPSjoin( /* DPSContext ctxt; */ );
+
+extern void DPSknown( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSkshow( /* DPSContext ctxt; char *s; */ );
+
+extern void DPSlanguagelevel( /* DPSContext ctxt; int *n; */ );
+
+extern void DPSle( /* DPSContext ctxt; */ );
+
+extern void DPSleftbracket( /* DPSContext ctxt; */ );
+
+extern void DPSleftleft( /* DPSContext ctxt; */ );
+
+extern void DPSlength( /* DPSContext ctxt; int *len; */ );
+
+extern void DPSlineto( /* DPSContext ctxt; float x, y; */ );
+
+extern void DPSln( /* DPSContext ctxt; */ );
+
+extern void DPSload( /* DPSContext ctxt; */ );
+
+extern void DPSlock( /* DPSContext ctxt; */ );
+
+extern void DPSlog( /* DPSContext ctxt; */ );
+
+extern void DPSloop( /* DPSContext ctxt; */ );
+
+extern void DPSlt( /* DPSContext ctxt; */ );
+
+extern void DPSmakefont( /* DPSContext ctxt; */ );
+
+extern void DPSmakepattern( /* DPSContext ctxt; */ );
+
+extern void DPSmark( /* DPSContext ctxt; */ );
+
+extern void DPSmatrix( /* DPSContext ctxt; */ );
+
+extern void DPSmaxlength( /* DPSContext ctxt; int *len; */ );
+
+extern void DPSmod( /* DPSContext ctxt; */ );
+
+extern void DPSmonitor( /* DPSContext ctxt; */ );
+
+extern void DPSmoveto( /* DPSContext ctxt; float x, y; */ );
+
+extern void DPSmul( /* DPSContext ctxt; */ );
+
+extern void DPSne( /* DPSContext ctxt; */ );
+
+extern void DPSneg( /* DPSContext ctxt; */ );
+
+extern void DPSnewpath( /* DPSContext ctxt; */ );
+
+extern void DPSnoaccess( /* DPSContext ctxt; */ );
+
+extern void DPSnot( /* DPSContext ctxt; */ );
+
+extern void DPSnotify( /* DPSContext ctxt; */ );
+
+extern void DPSnull( /* DPSContext ctxt; */ );
+
+extern void DPSnulldevice( /* DPSContext ctxt; */ );
+
+extern void DPSor( /* DPSContext ctxt; */ );
+
+extern void DPSpackedarray( /* DPSContext ctxt; */ );
+
+extern void DPSpathbbox( /* DPSContext ctxt; float *llx, *lly, *urx, *ury; */ );
+
+extern void DPSpathforall( /* DPSContext ctxt; */ );
+
+extern void DPSpop( /* DPSContext ctxt; */ );
+
+extern void DPSprint( /* DPSContext ctxt; */ );
+
+extern void DPSprintobject( /* DPSContext ctxt; int tag; */ );
+
+extern void DPSproduct( /* DPSContext ctxt; */ );
+
+extern void DPSprompt( /* DPSContext ctxt; */ );
+
+extern void DPSpstack( /* DPSContext ctxt; */ );
+
+extern void DPSput( /* DPSContext ctxt; */ );
+
+extern void DPSputinterval( /* DPSContext ctxt; */ );
+
+extern void DPSquit( /* DPSContext ctxt; */ );
+
+extern void DPSrand( /* DPSContext ctxt; */ );
+
+extern void DPSrcheck( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSrcurveto( /* DPSContext ctxt; float x1, y1, x2, y2, x3, y3; */ );
+
+extern void DPSread( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSreadhexstring( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSreadline( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSreadonly( /* DPSContext ctxt; */ );
+
+extern void DPSreadstring( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSrealtime( /* DPSContext ctxt; int *i; */ );
+
+extern void DPSrectclip( /* DPSContext ctxt; float x, y, w, h; */ );
+
+extern void DPSrectfill( /* DPSContext ctxt; float x, y, w, h; */ );
+
+extern void DPSrectstroke( /* DPSContext ctxt; float x, y, w, h; */ );
+
+extern void DPSrectviewclip( /* DPSContext ctxt; float x, y, w, h; */ );
+
+extern void DPSrenamefile( /* DPSContext ctxt; char *oldname, *newname; */ );
+
+extern void DPSrenderbands( /* DPSContext ctxt; */ );
+
+extern void DPSrepeat( /* DPSContext ctxt; */ );
+
+extern void DPSresetfile( /* DPSContext ctxt; */ );
+
+extern void DPSresourceforall( /* DPSContext ctxt; char *category; */ );
+
+extern void DPSresourcestatus( /* DPSContext ctxt; char *key, *category; int *b; */ );
+
+extern void DPSrestore( /* DPSContext ctxt; */ );
+
+extern void DPSreversepath( /* DPSContext ctxt; */ );
+
+extern void DPSrevision( /* DPSContext ctxt; int *n; */ );
+
+extern void DPSrightbracket( /* DPSContext ctxt; */ );
+
+extern void DPSrightright( /* DPSContext ctxt; */ );
+
+extern void DPSrlineto( /* DPSContext ctxt; float x, y; */ );
+
+extern void DPSrmoveto( /* DPSContext ctxt; float x, y; */ );
+
+extern void DPSroll( /* DPSContext ctxt; int n, j; */ );
+
+extern void DPSrootfont( /* DPSContext ctxt; */ );
+
+extern void DPSrotate( /* DPSContext ctxt; float angle; */ );
+
+extern void DPSround( /* DPSContext ctxt; */ );
+
+extern void DPSrrand( /* DPSContext ctxt; */ );
+
+extern void DPSrun( /* DPSContext ctxt; char *filename; */ );
+
+extern void DPSsave( /* DPSContext ctxt; */ );
+
+extern void DPSscale( /* DPSContext ctxt; float x, y; */ );
+
+extern void DPSscalefont( /* DPSContext ctxt; float size; */ );
+
+extern void DPSscheck( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSsearch( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSselectfont( /* DPSContext ctxt; char *name; float scale; */ );
+
+extern void DPSsendboolean( /* DPSContext ctxt; int it; */ );
+
+extern void DPSsendchararray( /* DPSContext ctxt; char s[]; int size; */ );
+
+extern void DPSsendfloat( /* DPSContext ctxt; float it; */ );
+
+extern void DPSsendfloatarray( /* DPSContext ctxt; float a[]; int size; */ );
+
+extern void DPSsendint( /* DPSContext ctxt; int it; */ );
+
+extern void DPSsendintarray( /* DPSContext ctxt; int a[]; int size; */ );
+
+extern void DPSsendstring( /* DPSContext ctxt; char *s; */ );
+
+extern void DPSserialnumber( /* DPSContext ctxt; int *n; */ );
+
+extern void DPSsetXdrawingfunction( /* DPSContext ctxt; int function; */ );
+
+extern void DPSsetXgcdrawable( /* DPSContext ctxt; int gc, draw, x, y; */ );
+
+extern void DPSsetXgcdrawablecolor( /* DPSContext ctxt; int gc, draw, x, y, colorInfo[]; */ );
+
+extern void DPSsetXoffset( /* DPSContext ctxt; int x, y; */ );
+
+extern void DPSsetXrgbactual( /* DPSContext ctxt; float r, g, b; int *success; */ );
+
+extern void DPSsetbbox( /* DPSContext ctxt; float llx, lly, urx, ury; */ );
+
+extern void DPSsetblackgeneration( /* DPSContext ctxt; */ );
+
+extern void DPSsetcachedevice( /* DPSContext ctxt; float wx, wy, llx, lly, urx, ury; */ );
+
+extern void DPSsetcachelimit( /* DPSContext ctxt; int n; */ );
+
+extern void DPSsetcacheparams( /* DPSContext ctxt; */ );
+
+extern void DPSsetcharwidth( /* DPSContext ctxt; float wx, wy; */ );
+
+extern void DPSsetcmykcolor( /* DPSContext ctxt; float c, m, y, k; */ );
+
+extern void DPSsetcolor( /* DPSContext ctxt; */ );
+
+extern void DPSsetcolorrendering( /* DPSContext ctxt; */ );
+
+extern void DPSsetcolorscreen( /* DPSContext ctxt; */ );
+
+extern void DPSsetcolorspace( /* DPSContext ctxt; */ );
+
+extern void DPSsetcolortransfer( /* DPSContext ctxt; */ );
+
+extern void DPSsetdash( /* DPSContext ctxt; float pat[]; int size; float offset; */ );
+
+extern void DPSsetdevparams( /* DPSContext ctxt; */ );
+
+extern void DPSsetfileposition( /* DPSContext ctxt; int pos; */ );
+
+extern void DPSsetflat( /* DPSContext ctxt; float flatness; */ );
+
+extern void DPSsetfont( /* DPSContext ctxt; int f; */ );
+
+extern void DPSsetglobal( /* DPSContext ctxt; int b; */ );
+
+extern void DPSsetgray( /* DPSContext ctxt; float gray; */ );
+
+extern void DPSsetgstate( /* DPSContext ctxt; int gst; */ );
+
+extern void DPSsethalftone( /* DPSContext ctxt; */ );
+
+extern void DPSsethalftonephase( /* DPSContext ctxt; float x, y; */ );
+
+extern void DPSsethsbcolor( /* DPSContext ctxt; float h, s, b; */ );
+
+extern void DPSsetlinecap( /* DPSContext ctxt; int linecap; */ );
+
+extern void DPSsetlinejoin( /* DPSContext ctxt; int linejoin; */ );
+
+extern void DPSsetlinewidth( /* DPSContext ctxt; float width; */ );
+
+extern void DPSsetmatrix( /* DPSContext ctxt; */ );
+
+extern void DPSsetmiterlimit( /* DPSContext ctxt; float limit; */ );
+
+extern void DPSsetobjectformat( /* DPSContext ctxt; int code; */ );
+
+extern void DPSsetoverprint( /* DPSContext ctxt; int b; */ );
+
+extern void DPSsetpacking( /* DPSContext ctxt; int b; */ );
+
+extern void DPSsetpagedevice( /* DPSContext ctxt; */ );
+
+extern void DPSsetpattern( /* DPSContext ctxt; */ );
+
+extern void DPSsetrgbcolor( /* DPSContext ctxt; float r, g, b; */ );
+
+extern void DPSsetscreen( /* DPSContext ctxt; */ );
+
+extern void DPSsetshared( /* DPSContext ctxt; int b; */ );
+
+extern void DPSsetstrokeadjust( /* DPSContext ctxt; int b; */ );
+
+extern void DPSsetsystemparams( /* DPSContext ctxt; */ );
+
+extern void DPSsettransfer( /* DPSContext ctxt; */ );
+
+extern void DPSsetucacheparams( /* DPSContext ctxt; */ );
+
+extern void DPSsetundercolorremoval( /* DPSContext ctxt; */ );
+
+extern void DPSsetuserparams( /* DPSContext ctxt; */ );
+
+extern void DPSsetvmthreshold( /* DPSContext ctxt; int i; */ );
+
+extern void DPSshareddict( /* DPSContext ctxt; */ );
+
+extern void DPSshow( /* DPSContext ctxt; char *s; */ );
+
+extern void DPSshowpage( /* DPSContext ctxt; */ );
+
+extern void DPSsin( /* DPSContext ctxt; */ );
+
+extern void DPSsqrt( /* DPSContext ctxt; */ );
+
+extern void DPSsrand( /* DPSContext ctxt; */ );
+
+extern void DPSstack( /* DPSContext ctxt; */ );
+
+extern void DPSstart( /* DPSContext ctxt; */ );
+
+extern void DPSstartjob( /* DPSContext ctxt; int b; char *password; */ );
+
+extern void DPSstatus( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSstatusdict( /* DPSContext ctxt; */ );
+
+extern void DPSstop( /* DPSContext ctxt; */ );
+
+extern void DPSstopped( /* DPSContext ctxt; */ );
+
+extern void DPSstore( /* DPSContext ctxt; */ );
+
+extern void DPSstring( /* DPSContext ctxt; int len; */ );
+
+extern void DPSstringwidth( /* DPSContext ctxt; char *s; float *xp, *yp; */ );
+
+extern void DPSstroke( /* DPSContext ctxt; */ );
+
+extern void DPSstrokepath( /* DPSContext ctxt; */ );
+
+extern void DPSsub( /* DPSContext ctxt; */ );
+
+extern void DPSsystemdict( /* DPSContext ctxt; */ );
+
+extern void DPStoken( /* DPSContext ctxt; int *b; */ );
+
+extern void DPStransform( /* DPSContext ctxt; float x1, y1; float *x2, *y2; */ );
+
+extern void DPStranslate( /* DPSContext ctxt; float x, y; */ );
+
+extern void DPStrue( /* DPSContext ctxt; */ );
+
+extern void DPStruncate( /* DPSContext ctxt; */ );
+
+extern void DPStype( /* DPSContext ctxt; */ );
+
+extern void DPSuappend( /* DPSContext ctxt; char nums[]; int n; char ops[]; int l; */ );
+
+extern void DPSucache( /* DPSContext ctxt; */ );
+
+extern void DPSucachestatus( /* DPSContext ctxt; */ );
+
+extern void DPSueofill( /* DPSContext ctxt; char nums[]; int n; char ops[]; int l; */ );
+
+extern void DPSufill( /* DPSContext ctxt; char nums[]; int n; char ops[]; int l; */ );
+
+extern void DPSundef( /* DPSContext ctxt; char *name; */ );
+
+extern void DPSundefinefont( /* DPSContext ctxt; char *name; */ );
+
+extern void DPSundefineresource( /* DPSContext ctxt; char *key, *category; */ );
+
+extern void DPSundefineuserobject( /* DPSContext ctxt; int userObjIndex; */ );
+
+extern void DPSupath( /* DPSContext ctxt; int b; */ );
+
+extern void DPSuserdict( /* DPSContext ctxt; */ );
+
+extern void DPSusertime( /* DPSContext ctxt; int *milliseconds; */ );
+
+extern void DPSustroke( /* DPSContext ctxt; char nums[]; int n; char ops[]; int l; */ );
+
+extern void DPSustrokepath( /* DPSContext ctxt; char nums[]; int n; char ops[]; int l; */ );
+
+extern void DPSversion( /* DPSContext ctxt; int bufsize; char buf[]; */ );
+
+extern void DPSviewclip( /* DPSContext ctxt; */ );
+
+extern void DPSviewclippath( /* DPSContext ctxt; */ );
+
+extern void DPSvmreclaim( /* DPSContext ctxt; int code; */ );
+
+extern void DPSvmstatus( /* DPSContext ctxt; int *level, *used, *maximum; */ );
+
+extern void DPSwait( /* DPSContext ctxt; */ );
+
+extern void DPSwcheck( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSwhere( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSwidthshow( /* DPSContext ctxt; float x, y; int c; char *s; */ );
+
+extern void DPSwrite( /* DPSContext ctxt; */ );
+
+extern void DPSwritehexstring( /* DPSContext ctxt; */ );
+
+extern void DPSwriteobject( /* DPSContext ctxt; int tag; */ );
+
+extern void DPSwritestring( /* DPSContext ctxt; */ );
+
+extern void DPSwtranslation( /* DPSContext ctxt; float *x, *y; */ );
+
+extern void DPSxcheck( /* DPSContext ctxt; int *b; */ );
+
+extern void DPSxor( /* DPSContext ctxt; */ );
+
+extern void DPSxshow( /* DPSContext ctxt; char *s; float numarray[]; int size; */ );
+
+extern void DPSxyshow( /* DPSContext ctxt; char *s; float numarray[]; int size; */ );
+
+extern void DPSyield( /* DPSContext ctxt; */ );
+
+extern void DPSyshow( /* DPSContext ctxt; char *s; float numarray[]; int size; */ );
+
+#else /* _NO_PROTO */
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+extern void DPSFontDirectory(DPSContext ctxt);
+
+extern void DPSGlobalFontDirectory(DPSContext ctxt);
+
+extern void DPSISOLatin1Encoding(DPSContext ctxt);
+
+extern void DPSSharedFontDirectory(DPSContext ctxt);
+
+extern void DPSStandardEncoding(DPSContext ctxt);
+
+extern void DPSUserObjects(DPSContext ctxt);
+
+extern void DPSabs(DPSContext ctxt);
+
+extern void DPSadd(DPSContext ctxt);
+
+extern void DPSaload(DPSContext ctxt);
+
+extern void DPSanchorsearch(DPSContext ctxt, int *truth);
+
+extern void DPSand(DPSContext ctxt);
+
+extern void DPSarc(DPSContext ctxt, float x, float y, float r, float angle1, float angle2);
+
+extern void DPSarcn(DPSContext ctxt, float x, float y, float r, float angle1, float angle2);
+
+extern void DPSarct(DPSContext ctxt, float x1, float y1, float x2, float y2, float r);
+
+extern void DPSarcto(DPSContext ctxt, float x1, float y1, float x2, float y2, float r, float *xt1, float *yt1, float *xt2, float *yt2);
+
+extern void DPSarray(DPSContext ctxt, int len);
+
+extern void DPSashow(DPSContext ctxt, float x, float y, const char *s);
+
+extern void DPSastore(DPSContext ctxt);
+
+extern void DPSatan(DPSContext ctxt);
+
+extern void DPSawidthshow(DPSContext ctxt, float cx, float cy, int c, float ax, float ay, const char *s);
+
+extern void DPSbanddevice(DPSContext ctxt);
+
+extern void DPSbegin(DPSContext ctxt);
+
+extern void DPSbind(DPSContext ctxt);
+
+extern void DPSbitshift(DPSContext ctxt, int shift);
+
+extern void DPSbytesavailable(DPSContext ctxt, int *n);
+
+extern void DPScachestatus(DPSContext ctxt);
+
+extern void DPSceiling(DPSContext ctxt);
+
+extern void DPScharpath(DPSContext ctxt, const char *s, int b);
+
+extern void DPSclear(DPSContext ctxt);
+
+extern void DPScleardictstack(DPSContext ctxt);
+
+extern void DPScleartomark(DPSContext ctxt);
+
+extern void DPSclientXready(DPSContext ctxt, int i0, int i1, int i2, int i3);
+
+extern void DPSclientsync(DPSContext ctxt);
+
+extern void DPSclip(DPSContext ctxt);
+
+extern void DPSclippath(DPSContext ctxt);
+
+extern void DPSclosefile(DPSContext ctxt);
+
+extern void DPSclosepath(DPSContext ctxt);
+
+extern void DPScolorimage(DPSContext ctxt);
+
+extern void DPSconcat(DPSContext ctxt, const float m[]);
+
+extern void DPSconcatmatrix(DPSContext ctxt);
+
+extern void DPScondition(DPSContext ctxt);
+
+extern void DPScopy(DPSContext ctxt, int n);
+
+extern void DPScopypage(DPSContext ctxt);
+
+extern void DPScos(DPSContext ctxt);
+
+extern void DPScount(DPSContext ctxt, int *n);
+
+extern void DPScountdictstack(DPSContext ctxt, int *n);
+
+extern void DPScountexecstack(DPSContext ctxt, int *n);
+
+extern void DPScounttomark(DPSContext ctxt, int *n);
+
+extern void DPScshow(DPSContext ctxt, const char *s);
+
+extern void DPScurrentXdrawingfunction(DPSContext ctxt, int *function);
+
+extern void DPScurrentXgcdrawable(DPSContext ctxt, int *gc, int *draw, int *x, int *y);
+
+extern void DPScurrentXgcdrawablecolor(DPSContext ctxt, int *gc, int *draw, int *x, int *y, int colorInfo[]);
+
+extern void DPScurrentXoffset(DPSContext ctxt, int *x, int *y);
+
+extern void DPScurrentblackgeneration(DPSContext ctxt);
+
+extern void DPScurrentcacheparams(DPSContext ctxt);
+
+extern void DPScurrentcmykcolor(DPSContext ctxt, float *c, float *m, float *y, float *k);
+
+extern void DPScurrentcolor(DPSContext ctxt);
+
+extern void DPScurrentcolorrendering(DPSContext ctxt);
+
+extern void DPScurrentcolorscreen(DPSContext ctxt);
+
+extern void DPScurrentcolorspace(DPSContext ctxt);
+
+extern void DPScurrentcolortransfer(DPSContext ctxt);
+
+extern void DPScurrentcontext(DPSContext ctxt, int *cid);
+
+extern void DPScurrentdash(DPSContext ctxt);
+
+extern void DPScurrentdevparams(DPSContext ctxt, const char *dev);
+
+extern void DPScurrentdict(DPSContext ctxt);
+
+extern void DPScurrentfile(DPSContext ctxt);
+
+extern void DPScurrentflat(DPSContext ctxt, float *flatness);
+
+extern void DPScurrentfont(DPSContext ctxt);
+
+extern void DPScurrentglobal(DPSContext ctxt, int *b);
+
+extern void DPScurrentgray(DPSContext ctxt, float *gray);
+
+extern void DPScurrentgstate(DPSContext ctxt, int gst);
+
+extern void DPScurrenthalftone(DPSContext ctxt);
+
+extern void DPScurrenthalftonephase(DPSContext ctxt, float *x, float *y);
+
+extern void DPScurrenthsbcolor(DPSContext ctxt, float *h, float *s, float *b);
+
+extern void DPScurrentlinecap(DPSContext ctxt, int *linecap);
+
+extern void DPScurrentlinejoin(DPSContext ctxt, int *linejoin);
+
+extern void DPScurrentlinewidth(DPSContext ctxt, float *width);
+
+extern void DPScurrentmatrix(DPSContext ctxt);
+
+extern void DPScurrentmiterlimit(DPSContext ctxt, float *limit);
+
+extern void DPScurrentobjectformat(DPSContext ctxt, int *code);
+
+extern void DPScurrentoverprint(DPSContext ctxt, int *b);
+
+extern void DPScurrentpacking(DPSContext ctxt, int *b);
+
+extern void DPScurrentpagedevice(DPSContext ctxt);
+
+extern void DPScurrentpoint(DPSContext ctxt, float *x, float *y);
+
+extern void DPScurrentrgbcolor(DPSContext ctxt, float *r, float *g, float *b);
+
+extern void DPScurrentscreen(DPSContext ctxt);
+
+extern void DPScurrentshared(DPSContext ctxt, int *b);
+
+extern void DPScurrentstrokeadjust(DPSContext ctxt, int *b);
+
+extern void DPScurrentsystemparams(DPSContext ctxt);
+
+extern void DPScurrenttransfer(DPSContext ctxt);
+
+extern void DPScurrentundercolorremoval(DPSContext ctxt);
+
+extern void DPScurrentuserparams(DPSContext ctxt);
+
+extern void DPScurveto(DPSContext ctxt, float x1, float y1, float x2, float y2, float x3, float y3);
+
+extern void DPScvi(DPSContext ctxt);
+
+extern void DPScvlit(DPSContext ctxt);
+
+extern void DPScvn(DPSContext ctxt);
+
+extern void DPScvr(DPSContext ctxt);
+
+extern void DPScvrs(DPSContext ctxt);
+
+extern void DPScvs(DPSContext ctxt);
+
+extern void DPScvx(DPSContext ctxt);
+
+extern void DPSdef(DPSContext ctxt);
+
+extern void DPSdefaultmatrix(DPSContext ctxt);
+
+extern void DPSdefinefont(DPSContext ctxt);
+
+extern void DPSdefineresource(DPSContext ctxt, const char *category);
+
+extern void DPSdefineusername(DPSContext ctxt, int i, const char *username);
+
+extern void DPSdefineuserobject(DPSContext ctxt);
+
+extern void DPSdeletefile(DPSContext ctxt, const char *filename);
+
+extern void DPSdetach(DPSContext ctxt);
+
+extern void DPSdeviceinfo(DPSContext ctxt);
+
+extern void DPSdict(DPSContext ctxt, int len);
+
+extern void DPSdictstack(DPSContext ctxt);
+
+extern void DPSdiv(DPSContext ctxt);
+
+extern void DPSdtransform(DPSContext ctxt, float x1, float y1, float *x2, float *y2);
+
+extern void DPSdup(DPSContext ctxt);
+
+extern void DPSecho(DPSContext ctxt, int b);
+
+extern void DPSend(DPSContext ctxt);
+
+extern void DPSeoclip(DPSContext ctxt);
+
+extern void DPSeofill(DPSContext ctxt);
+
+extern void DPSeoviewclip(DPSContext ctxt);
+
+extern void DPSeq(DPSContext ctxt);
+
+extern void DPSequals(DPSContext ctxt);
+
+extern void DPSequalsequals(DPSContext ctxt);
+
+extern void DPSerasepage(DPSContext ctxt);
+
+extern void DPSerrordict(DPSContext ctxt);
+
+extern void DPSexch(DPSContext ctxt);
+
+extern void DPSexec(DPSContext ctxt);
+
+extern void DPSexecform(DPSContext ctxt);
+
+extern void DPSexecstack(DPSContext ctxt);
+
+extern void DPSexecuserobject(DPSContext ctxt, int userObjIndex);
+
+extern void DPSexecuteonly(DPSContext ctxt);
+
+extern void DPSexit(DPSContext ctxt);
+
+extern void DPSexp(DPSContext ctxt);
+
+extern void DPSfalse(DPSContext ctxt);
+
+extern void DPSfile(DPSContext ctxt, const char *name, const char *access);
+
+extern void DPSfilenameforall(DPSContext ctxt);
+
+extern void DPSfileposition(DPSContext ctxt, int *pos);
+
+extern void DPSfill(DPSContext ctxt);
+
+extern void DPSfilter(DPSContext ctxt);
+
+extern void DPSfindencoding(DPSContext ctxt, const char *key);
+
+extern void DPSfindfont(DPSContext ctxt, const char *name);
+
+extern void DPSfindresource(DPSContext ctxt, const char *key, const char *category);
+
+extern void DPSflattenpath(DPSContext ctxt);
+
+extern void DPSfloor(DPSContext ctxt);
+
+extern void DPSflush(DPSContext ctxt);
+
+extern void DPSflushfile(DPSContext ctxt);
+
+extern void DPSfor(DPSContext ctxt);
+
+extern void DPSforall(DPSContext ctxt);
+
+extern void DPSfork(DPSContext ctxt);
+
+extern void DPSframedevice(DPSContext ctxt);
+
+extern void DPSgcheck(DPSContext ctxt, int *b);
+
+extern void DPSge(DPSContext ctxt);
+
+extern void DPSget(DPSContext ctxt);
+
+extern void DPSgetboolean(DPSContext ctxt, int *it);
+
+extern void DPSgetchararray(DPSContext ctxt, int size, char s[]);
+
+extern void DPSgetfloat(DPSContext ctxt, float *it);
+
+extern void DPSgetfloatarray(DPSContext ctxt, int size, float a[]);
+
+extern void DPSgetint(DPSContext ctxt, int *it);
+
+extern void DPSgetintarray(DPSContext ctxt, int size, int a[]);
+
+extern void DPSgetinterval(DPSContext ctxt);
+
+extern void DPSgetstring(DPSContext ctxt, char *s);
+
+extern void DPSglobaldict(DPSContext ctxt);
+
+extern void DPSglyphshow(DPSContext ctxt, const char *name);
+
+extern void DPSgrestore(DPSContext ctxt);
+
+extern void DPSgrestoreall(DPSContext ctxt);
+
+extern void DPSgsave(DPSContext ctxt);
+
+extern void DPSgstate(DPSContext ctxt);
+
+extern void DPSgt(DPSContext ctxt);
+
+extern void DPSidentmatrix(DPSContext ctxt);
+
+extern void DPSidiv(DPSContext ctxt);
+
+extern void DPSidtransform(DPSContext ctxt, float x1, float y1, float *x2, float *y2);
+
+extern void DPSif(DPSContext ctxt);
+
+extern void DPSifelse(DPSContext ctxt);
+
+extern void DPSimage(DPSContext ctxt);
+
+extern void DPSimagemask(DPSContext ctxt);
+
+extern void DPSindex(DPSContext ctxt, int i);
+
+extern void DPSineofill(DPSContext ctxt, float x, float y, int *b);
+
+extern void DPSinfill(DPSContext ctxt, float x, float y, int *b);
+
+extern void DPSinitclip(DPSContext ctxt);
+
+extern void DPSinitgraphics(DPSContext ctxt);
+
+extern void DPSinitmatrix(DPSContext ctxt);
+
+extern void DPSinitviewclip(DPSContext ctxt);
+
+extern void DPSinstroke(DPSContext ctxt, float x, float y, int *b);
+
+extern void DPSinueofill(DPSContext ctxt, float x, float y, const char nums[], int n, const char ops[], int l, int *b);
+
+extern void DPSinufill(DPSContext ctxt, float x, float y, const char nums[], int n, const char ops[], int l, int *b);
+
+extern void DPSinustroke(DPSContext ctxt, float x, float y, const char nums[], int n, const char ops[], int l, int *b);
+
+extern void DPSinvertmatrix(DPSContext ctxt);
+
+extern void DPSitransform(DPSContext ctxt, float x1, float y1, float *x2, float *y2);
+
+extern void DPSjoin(DPSContext ctxt);
+
+extern void DPSknown(DPSContext ctxt, int *b);
+
+extern void DPSkshow(DPSContext ctxt, const char *s);
+
+extern void DPSlanguagelevel(DPSContext ctxt, int *n);
+
+extern void DPSle(DPSContext ctxt);
+
+extern void DPSleftbracket(DPSContext ctxt);
+
+extern void DPSleftleft(DPSContext ctxt);
+
+extern void DPSlength(DPSContext ctxt, int *len);
+
+extern void DPSlineto(DPSContext ctxt, float x, float y);
+
+extern void DPSln(DPSContext ctxt);
+
+extern void DPSload(DPSContext ctxt);
+
+extern void DPSlock(DPSContext ctxt);
+
+extern void DPSlog(DPSContext ctxt);
+
+extern void DPSloop(DPSContext ctxt);
+
+extern void DPSlt(DPSContext ctxt);
+
+extern void DPSmakefont(DPSContext ctxt);
+
+extern void DPSmakepattern(DPSContext ctxt);
+
+extern void DPSmark(DPSContext ctxt);
+
+extern void DPSmatrix(DPSContext ctxt);
+
+extern void DPSmaxlength(DPSContext ctxt, int *len);
+
+extern void DPSmod(DPSContext ctxt);
+
+extern void DPSmonitor(DPSContext ctxt);
+
+extern void DPSmoveto(DPSContext ctxt, float x, float y);
+
+extern void DPSmul(DPSContext ctxt);
+
+extern void DPSne(DPSContext ctxt);
+
+extern void DPSneg(DPSContext ctxt);
+
+extern void DPSnewpath(DPSContext ctxt);
+
+extern void DPSnoaccess(DPSContext ctxt);
+
+extern void DPSnot(DPSContext ctxt);
+
+extern void DPSnotify(DPSContext ctxt);
+
+extern void DPSnull(DPSContext ctxt);
+
+extern void DPSnulldevice(DPSContext ctxt);
+
+extern void DPSor(DPSContext ctxt);
+
+extern void DPSpackedarray(DPSContext ctxt);
+
+extern void DPSpathbbox(DPSContext ctxt, float *llx, float *lly, float *urx, float *ury);
+
+extern void DPSpathforall(DPSContext ctxt);
+
+extern void DPSpop(DPSContext ctxt);
+
+extern void DPSprint(DPSContext ctxt);
+
+extern void DPSprintobject(DPSContext ctxt, int tag);
+
+extern void DPSproduct(DPSContext ctxt);
+
+extern void DPSprompt(DPSContext ctxt);
+
+extern void DPSpstack(DPSContext ctxt);
+
+extern void DPSput(DPSContext ctxt);
+
+extern void DPSputinterval(DPSContext ctxt);
+
+extern void DPSquit(DPSContext ctxt);
+
+extern void DPSrand(DPSContext ctxt);
+
+extern void DPSrcheck(DPSContext ctxt, int *b);
+
+extern void DPSrcurveto(DPSContext ctxt, float x1, float y1, float x2, float y2, float x3, float y3);
+
+extern void DPSread(DPSContext ctxt, int *b);
+
+extern void DPSreadhexstring(DPSContext ctxt, int *b);
+
+extern void DPSreadline(DPSContext ctxt, int *b);
+
+extern void DPSreadonly(DPSContext ctxt);
+
+extern void DPSreadstring(DPSContext ctxt, int *b);
+
+extern void DPSrealtime(DPSContext ctxt, int *i);
+
+extern void DPSrectclip(DPSContext ctxt, float x, float y, float w, float h);
+
+extern void DPSrectfill(DPSContext ctxt, float x, float y, float w, float h);
+
+extern void DPSrectstroke(DPSContext ctxt, float x, float y, float w, float h);
+
+extern void DPSrectviewclip(DPSContext ctxt, float x, float y, float w, float h);
+
+extern void DPSrenamefile(DPSContext ctxt, const char *oldname, const char *newname);
+
+extern void DPSrenderbands(DPSContext ctxt);
+
+extern void DPSrepeat(DPSContext ctxt);
+
+extern void DPSresetfile(DPSContext ctxt);
+
+extern void DPSresourceforall(DPSContext ctxt, const char *category);
+
+extern void DPSresourcestatus(DPSContext ctxt, const char *key, const char *category, int *b);
+
+extern void DPSrestore(DPSContext ctxt);
+
+extern void DPSreversepath(DPSContext ctxt);
+
+extern void DPSrevision(DPSContext ctxt, int *n);
+
+extern void DPSrightbracket(DPSContext ctxt);
+
+extern void DPSrightright(DPSContext ctxt);
+
+extern void DPSrlineto(DPSContext ctxt, float x, float y);
+
+extern void DPSrmoveto(DPSContext ctxt, float x, float y);
+
+extern void DPSroll(DPSContext ctxt, int n, int j);
+
+extern void DPSrootfont(DPSContext ctxt);
+
+extern void DPSrotate(DPSContext ctxt, float angle);
+
+extern void DPSround(DPSContext ctxt);
+
+extern void DPSrrand(DPSContext ctxt);
+
+extern void DPSrun(DPSContext ctxt, const char *filename);
+
+extern void DPSsave(DPSContext ctxt);
+
+extern void DPSscale(DPSContext ctxt, float x, float y);
+
+extern void DPSscalefont(DPSContext ctxt, float size);
+
+extern void DPSscheck(DPSContext ctxt, int *b);
+
+extern void DPSsearch(DPSContext ctxt, int *b);
+
+extern void DPSselectfont(DPSContext ctxt, const char *name, float scale);
+
+extern void DPSsendboolean(DPSContext ctxt, int it);
+
+extern void DPSsendchararray(DPSContext ctxt, const char s[], int size);
+
+extern void DPSsendfloat(DPSContext ctxt, float it);
+
+extern void DPSsendfloatarray(DPSContext ctxt, const float a[], int size);
+
+extern void DPSsendint(DPSContext ctxt, int it);
+
+extern void DPSsendintarray(DPSContext ctxt, const int a[], int size);
+
+extern void DPSsendstring(DPSContext ctxt, const char *s);
+
+extern void DPSserialnumber(DPSContext ctxt, int *n);
+
+extern void DPSsetXdrawingfunction(DPSContext ctxt, int function);
+
+extern void DPSsetXgcdrawable(DPSContext ctxt, int gc, int draw, int x, int y);
+
+extern void DPSsetXgcdrawablecolor(DPSContext ctxt, int gc, int draw, int x, int y, const int colorInfo[]);
+
+extern void DPSsetXoffset(DPSContext ctxt, int x, int y);
+
+extern void DPSsetXrgbactual(DPSContext ctxt, float r, float g, float b, int *success);
+
+extern void DPSsetbbox(DPSContext ctxt, float llx, float lly, float urx, float ury);
+
+extern void DPSsetblackgeneration(DPSContext ctxt);
+
+extern void DPSsetcachedevice(DPSContext ctxt, float wx, float wy, float llx, float lly, float urx, float ury);
+
+extern void DPSsetcachelimit(DPSContext ctxt, int n);
+
+extern void DPSsetcacheparams(DPSContext ctxt);
+
+extern void DPSsetcharwidth(DPSContext ctxt, float wx, float wy);
+
+extern void DPSsetcmykcolor(DPSContext ctxt, float c, float m, float y, float k);
+
+extern void DPSsetcolor(DPSContext ctxt);
+
+extern void DPSsetcolorrendering(DPSContext ctxt);
+
+extern void DPSsetcolorscreen(DPSContext ctxt);
+
+extern void DPSsetcolorspace(DPSContext ctxt);
+
+extern void DPSsetcolortransfer(DPSContext ctxt);
+
+extern void DPSsetdash(DPSContext ctxt, const float pat[], int size, float offset);
+
+extern void DPSsetdevparams(DPSContext ctxt);
+
+extern void DPSsetfileposition(DPSContext ctxt, int pos);
+
+extern void DPSsetflat(DPSContext ctxt, float flatness);
+
+extern void DPSsetfont(DPSContext ctxt, int f);
+
+extern void DPSsetglobal(DPSContext ctxt, int b);
+
+extern void DPSsetgray(DPSContext ctxt, float gray);
+
+extern void DPSsetgstate(DPSContext ctxt, int gst);
+
+extern void DPSsethalftone(DPSContext ctxt);
+
+extern void DPSsethalftonephase(DPSContext ctxt, float x, float y);
+
+extern void DPSsethsbcolor(DPSContext ctxt, float h, float s, float b);
+
+extern void DPSsetlinecap(DPSContext ctxt, int linecap);
+
+extern void DPSsetlinejoin(DPSContext ctxt, int linejoin);
+
+extern void DPSsetlinewidth(DPSContext ctxt, float width);
+
+extern void DPSsetmatrix(DPSContext ctxt);
+
+extern void DPSsetmiterlimit(DPSContext ctxt, float limit);
+
+extern void DPSsetobjectformat(DPSContext ctxt, int code);
+
+extern void DPSsetoverprint(DPSContext ctxt, int b);
+
+extern void DPSsetpacking(DPSContext ctxt, int b);
+
+extern void DPSsetpagedevice(DPSContext ctxt);
+
+extern void DPSsetpattern(DPSContext ctxt);
+
+extern void DPSsetrgbcolor(DPSContext ctxt, float r, float g, float b);
+
+extern void DPSsetscreen(DPSContext ctxt);
+
+extern void DPSsetshared(DPSContext ctxt, int b);
+
+extern void DPSsetstrokeadjust(DPSContext ctxt, int b);
+
+extern void DPSsetsystemparams(DPSContext ctxt);
+
+extern void DPSsettransfer(DPSContext ctxt);
+
+extern void DPSsetucacheparams(DPSContext ctxt);
+
+extern void DPSsetundercolorremoval(DPSContext ctxt);
+
+extern void DPSsetuserparams(DPSContext ctxt);
+
+extern void DPSsetvmthreshold(DPSContext ctxt, int i);
+
+extern void DPSshareddict(DPSContext ctxt);
+
+extern void DPSshow(DPSContext ctxt, const char *s);
+
+extern void DPSshowpage(DPSContext ctxt);
+
+extern void DPSsin(DPSContext ctxt);
+
+extern void DPSsqrt(DPSContext ctxt);
+
+extern void DPSsrand(DPSContext ctxt);
+
+extern void DPSstack(DPSContext ctxt);
+
+extern void DPSstart(DPSContext ctxt);
+
+extern void DPSstartjob(DPSContext ctxt, int b, const char *password);
+
+extern void DPSstatus(DPSContext ctxt, int *b);
+
+extern void DPSstatusdict(DPSContext ctxt);
+
+extern void DPSstop(DPSContext ctxt);
+
+extern void DPSstopped(DPSContext ctxt);
+
+extern void DPSstore(DPSContext ctxt);
+
+extern void DPSstring(DPSContext ctxt, int len);
+
+extern void DPSstringwidth(DPSContext ctxt, const char *s, float *xp, float *yp);
+
+extern void DPSstroke(DPSContext ctxt);
+
+extern void DPSstrokepath(DPSContext ctxt);
+
+extern void DPSsub(DPSContext ctxt);
+
+extern void DPSsystemdict(DPSContext ctxt);
+
+extern void DPStoken(DPSContext ctxt, int *b);
+
+extern void DPStransform(DPSContext ctxt, float x1, float y1, float *x2, float *y2);
+
+extern void DPStranslate(DPSContext ctxt, float x, float y);
+
+extern void DPStrue(DPSContext ctxt);
+
+extern void DPStruncate(DPSContext ctxt);
+
+extern void DPStype(DPSContext ctxt);
+
+extern void DPSuappend(DPSContext ctxt, const char nums[], int n, const char ops[], int l);
+
+extern void DPSucache(DPSContext ctxt);
+
+extern void DPSucachestatus(DPSContext ctxt);
+
+extern void DPSueofill(DPSContext ctxt, const char nums[], int n, const char ops[], int l);
+
+extern void DPSufill(DPSContext ctxt, const char nums[], int n, const char ops[], int l);
+
+extern void DPSundef(DPSContext ctxt, const char *name);
+
+extern void DPSundefinefont(DPSContext ctxt, const char *name);
+
+extern void DPSundefineresource(DPSContext ctxt, const char *key, const char *category);
+
+extern void DPSundefineuserobject(DPSContext ctxt, int userObjIndex);
+
+extern void DPSupath(DPSContext ctxt, int b);
+
+extern void DPSuserdict(DPSContext ctxt);
+
+extern void DPSusertime(DPSContext ctxt, int *milliseconds);
+
+extern void DPSustroke(DPSContext ctxt, const char nums[], int n, const char ops[], int l);
+
+extern void DPSustrokepath(DPSContext ctxt, const char nums[], int n, const char ops[], int l);
+
+extern void DPSversion(DPSContext ctxt, int bufsize, char buf[]);
+
+extern void DPSviewclip(DPSContext ctxt);
+
+extern void DPSviewclippath(DPSContext ctxt);
+
+extern void DPSvmreclaim(DPSContext ctxt, int code);
+
+extern void DPSvmstatus(DPSContext ctxt, int *level, int *used, int *maximum);
+
+extern void DPSwait(DPSContext ctxt);
+
+extern void DPSwcheck(DPSContext ctxt, int *b);
+
+extern void DPSwhere(DPSContext ctxt, int *b);
+
+extern void DPSwidthshow(DPSContext ctxt, float x, float y, int c, const char *s);
+
+extern void DPSwrite(DPSContext ctxt);
+
+extern void DPSwritehexstring(DPSContext ctxt);
+
+extern void DPSwriteobject(DPSContext ctxt, int tag);
+
+extern void DPSwritestring(DPSContext ctxt);
+
+extern void DPSwtranslation(DPSContext ctxt, float *x, float *y);
+
+extern void DPSxcheck(DPSContext ctxt, int *b);
+
+extern void DPSxor(DPSContext ctxt);
+
+extern void DPSxshow(DPSContext ctxt, const char *s, const float numarray[], int size);
+
+extern void DPSxyshow(DPSContext ctxt, const char *s, const float numarray[], int size);
+
+extern void DPSyield(DPSContext ctxt);
+
+extern void DPSyshow(DPSContext ctxt, const char *s, const float numarray[], int size);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _NO_PROTO */
+
+#endif /* DPSOPS_H */
diff --git a/xc/lib/dps/dpsos2.def b/xc/lib/dps/dpsos2.def
new file mode 100644
index 000000000..309481c16
--- /dev/null
+++ b/xc/lib/dps/dpsos2.def
@@ -0,0 +1,854 @@
+LIBRARY dps
+DESCRIPTION "@#XFREE86:4.0#@ $XFree86: xc/lib/dps/dpsos2.def,v 1.1 2000/04/05 18:13:21 dawes Exp $"
+CODE
+ PRELOAD
+DATA
+ MULTIPLE NONSHARED
+STACKSIZE 131072
+EXPORTS
+ CSDPSInit @ 1
+ CSDPSHeadOfDpyExt @ 2
+ DPSCAPChangeGC @ 3
+ DPSCAPCreate @ 4
+ DPSCAPDestroy @ 5
+ DPSCAPOpenAgent @ 6
+ DPSCAPStartUp @ 8
+ DPSCAPWrite @ 9
+ DPSCAPCloseDisplayProc @ 10
+ DPSCAPCloseAgent @ 13
+ DPSclientsync @ 14
+ DPScurrentXgcdrawable @ 15
+ DPScurrentXgcdrawablecolor @ 16
+ DPScurrentXoffset @ 17
+ DPSsetXgcdrawable @ 18
+ DPSsetXgcdrawablecolor @ 19
+ DPSsetXoffset @ 20
+ DPSsetXrgbactual @ 21
+ DPSclientXready @ 22
+ DPSsetXdrawingfunction @ 23
+ DPScurrentXdrawingfunction @ 24
+ DPSWarnProc @ 25
+ DPSFatalProc @ 26
+ DPSCantHappen @ 27
+ DPScolorimage @ 28
+ DPScurrentblackgeneration @ 29
+ DPScurrentcmykcolor @ 30
+ DPScurrentcolorscreen @ 31
+ DPScurrentcolortransfer @ 32
+ DPScurrentundercolorremoval @ 33
+ DPSsetblackgeneration @ 34
+ DPSsetcmykcolor @ 35
+ DPSsetcolorscreen @ 36
+ DPSsetcolortransfer @ 37
+ DPSsetundercolorremoval @ 38
+ DPSeq @ 39
+ DPSexit @ 40
+ DPSfalse @ 41
+ DPSfor @ 42
+ DPSforall @ 43
+ DPSge @ 44
+ DPSgt @ 45
+ DPSif @ 46
+ DPSifelse @ 47
+ DPSle @ 48
+ DPSloop @ 49
+ DPSlt @ 50
+ DPSne @ 51
+ DPSnot @ 52
+ DPSor @ 53
+ DPSrepeat @ 54
+ DPSstop @ 55
+ DPSstopped @ 56
+ DPStrue @ 57
+ DPSUserObjects @ 58
+ DPScondition @ 59
+ DPScurrentcontext @ 60
+ DPScurrentobjectformat @ 61
+ DPSdefineusername @ 62
+ DPSdefineuserobject @ 63
+ DPSdetach @ 64
+ DPSexecuserobject @ 65
+ DPSfork @ 66
+ DPSjoin @ 67
+ DPSlock @ 68
+ DPSmonitor @ 69
+ DPSnotify @ 70
+ DPSsetobjectformat @ 71
+ DPSsetvmthreshold @ 72
+ DPSundefineuserobject @ 73
+ DPSwait @ 74
+ DPSyield @ 75
+ DPSaload @ 76
+ DPSanchorsearch @ 77
+ DPSarray @ 78
+ DPSastore @ 79
+ DPSbegin @ 80
+ DPSclear @ 81
+ DPScleartomark @ 82
+ DPScopy @ 83
+ DPScount @ 84
+ DPScounttomark @ 85
+ DPScvi @ 86
+ DPScvlit @ 87
+ DPScvn @ 88
+ DPScvr @ 89
+ DPScvrs @ 90
+ DPScvs @ 91
+ DPScvx @ 92
+ DPSdef @ 93
+ DPSdict @ 94
+ DPSdictstack @ 95
+ DPSdup @ 96
+ DPSend @ 97
+ DPSexch @ 98
+ DPSexecstack @ 99
+ DPSexecuteonly @ 100
+ DPSget @ 101
+ DPSgetinterval @ 102
+ DPSindex @ 103
+ DPSknown @ 104
+ DPSlength @ 105
+ DPSload @ 106
+ DPSmark @ 107
+ DPSmatrix @ 108
+ DPSmaxlength @ 109
+ DPSnoaccess @ 110
+ DPSnull @ 111
+ DPSpackedarray @ 112
+ DPSpop @ 113
+ DPSput @ 114
+ DPSputinterval @ 115
+ DPSrcheck @ 116
+ DPSreadonly @ 117
+ DPSroll @ 118
+ DPSscheck @ 119
+ DPSsearch @ 120
+ DPSshareddict @ 121
+ DPSstatusdict @ 122
+ DPSstore @ 123
+ DPSstring @ 124
+ DPSstringwidth @ 125
+ DPSsystemdict @ 126
+ DPSuserdict @ 127
+ DPSwcheck @ 128
+ DPSwhere @ 129
+ DPSxcheck @ 130
+ DPSCreatePSWDict @ 131
+ DPSDestroyPSWDict @ 132
+ DPSWDictLookup @ 133
+ DPSWDictEnter @ 134
+ DPSWDictRemove @ 135
+ DPSMakeAtom @ 136
+ DPSFontDirectory @ 137
+ DPSISOLatin1Encoding @ 138
+ DPSSharedFontDirectory @ 139
+ DPSStandardEncoding @ 140
+ DPScachestatus @ 141
+ DPScurrentcacheparams @ 142
+ DPScurrentfont @ 143
+ DPSdefinefont @ 144
+ DPSfindfont @ 145
+ DPSmakefont @ 146
+ DPSscalefont @ 147
+ DPSselectfont @ 148
+ DPSsetcachedevice @ 149
+ DPSsetcachelimit @ 150
+ DPSsetcacheparams @ 151
+ DPSsetcharwidth @ 152
+ DPSsetfont @ 153
+ DPSundefinefont @ 154
+ DPSconcat @ 155
+ DPScurrentdash @ 156
+ DPScurrentflat @ 157
+ DPScurrentgray @ 158
+ DPScurrentgstate @ 159
+ DPScurrenthalftone @ 160
+ DPScurrenthalftonephase @ 161
+ DPScurrenthsbcolor @ 162
+ DPScurrentlinecap @ 163
+ DPScurrentlinejoin @ 164
+ DPScurrentlinewidth @ 165
+ DPScurrentmatrix @ 166
+ DPScurrentmiterlimit @ 167
+ DPScurrentpoint @ 168
+ DPScurrentrgbcolor @ 169
+ DPScurrentscreen @ 170
+ DPScurrentstrokeadjust @ 171
+ DPScurrenttransfer @ 172
+ DPSdefaultmatrix @ 173
+ DPSgrestore @ 174
+ DPSgrestoreall @ 175
+ DPSgsave @ 176
+ DPSgstate @ 177
+ DPSinitgraphics @ 178
+ DPSinitmatrix @ 179
+ DPSrotate @ 180
+ DPSscale @ 181
+ DPSsetdash @ 182
+ DPSsetflat @ 183
+ DPSsetgray @ 184
+ DPSsetgstate @ 185
+ DPSsethalftone @ 186
+ DPSsethalftonephase @ 187
+ DPSsethsbcolor @ 188
+ DPSsetlinecap @ 189
+ DPSsetlinejoin @ 190
+ DPSsetlinewidth @ 191
+ DPSsetmatrix @ 192
+ DPSsetmiterlimit @ 193
+ DPSsetrgbcolor @ 194
+ DPSsetscreen @ 195
+ DPSsetstrokeadjust @ 196
+ DPSsettransfer @ 197
+ DPStranslate @ 198
+ DPSclientPrintProc @ 199
+ DPSinnerProcWriteData @ 200
+ DPSSafeSetLastNameIndex @ 201
+ DPSCheckInitClientGlobals @ 202
+ DPSPrivateCheckWait @ 203
+ DPSPrivateDestroyContext @ 204
+ DPSPrivateDestroySpace @ 205
+ DPSCheckShared @ 206
+ DPSDefaultPrivateHandler @ 207
+ DPSCreateContext @ 208
+ DPSInitCommonTextContextProcs @ 209
+ DPSInitCommonContextProcs @ 210
+ DPSInitPrivateContextProcs @ 211
+ DPSInitPrivateContextFields @ 212
+ DPSInitPrivateTextContextFields @ 213
+ DPSInitCommonSpaceProcs @ 214
+ DPSInitPrivateSpaceFields @ 215
+ DPSequals @ 216
+ DPSequalsequals @ 217
+ DPSbytesavailable @ 218
+ DPSclosefile @ 219
+ DPScurrentfile @ 220
+ DPSdeletefile @ 221
+ DPSecho @ 222
+ DPSfile @ 223
+ DPSfilenameforall @ 224
+ DPSfileposition @ 225
+ DPSflush @ 226
+ DPSflushfile @ 227
+ DPSprint @ 228
+ DPSprintobject @ 229
+ DPSpstack @ 230
+ DPSread @ 231
+ DPSreadhexstring @ 232
+ DPSreadline @ 233
+ DPSreadstring @ 234
+ DPSrenamefile @ 235
+ DPSresetfile @ 236
+ DPSsetfileposition @ 237
+ DPSstack @ 238
+ DPSstatus @ 239
+ DPStoken @ 240
+ DPSwrite @ 241
+ DPSwritehexstring @ 242
+ DPSwriteobject @ 243
+ DPSwritestring @ 244
+ DPSleftbracket @ 245
+ DPSrightbracket @ 246
+ DPSleftleft @ 247
+ DPSrightright @ 248
+ DPScshow @ 249
+ DPScurrentcolor @ 250
+ DPScurrentcolorrendering @ 251
+ DPScurrentcolorspace @ 252
+ DPScurrentdevparams @ 253
+ DPScurrentglobal @ 254
+ DPScurrentoverprint @ 255
+ DPScurrentpagedevice @ 256
+ DPScurrentsystemparams @ 257
+ DPScurrentuserparams @ 258
+ DPSdefineresource @ 259
+ DPSexecform @ 260
+ DPSfilter @ 261
+ DPSfindencoding @ 262
+ DPSfindresource @ 263
+ DPSgcheck @ 264
+ DPSglobaldict @ 265
+ DPSGlobalFontDirectory @ 266
+ DPSglyphshow @ 267
+ DPSlanguagelevel @ 268
+ DPSmakepattern @ 269
+ DPSproduct @ 270
+ DPSresourceforall @ 271
+ DPSresourcestatus @ 272
+ DPSrevision @ 273
+ DPSrootfont @ 274
+ DPSserialnumber @ 275
+ DPSsetcolor @ 276
+ DPSsetcolorrendering @ 277
+ DPSsetcolorspace @ 278
+ DPSsetdevparams @ 279
+ DPSsetglobal @ 280
+ DPSsetoverprint @ 281
+ DPSsetpagedevice @ 282
+ DPSsetpattern @ 283
+ DPSsetsystemparams @ 284
+ DPSsetuserparams @ 285
+ DPSstartjob @ 286
+ DPSundefineresource @ 287
+ DPSabs @ 288
+ DPSadd @ 289
+ DPSand @ 290
+ DPSatan @ 291
+ DPSbitshift @ 292
+ DPSceiling @ 293
+ DPScos @ 294
+ DPSdiv @ 295
+ DPSexp @ 296
+ DPSfloor @ 297
+ DPSidiv @ 298
+ DPSln @ 299
+ DPSlog @ 300
+ DPSmod @ 301
+ DPSmul @ 302
+ DPSneg @ 303
+ DPSround @ 304
+ DPSsin @ 305
+ DPSsqrt @ 306
+ DPSsub @ 307
+ DPStruncate @ 308
+ DPSxor @ 309
+ DPSbanddevice @ 310
+ DPSframedevice @ 311
+ DPSnulldevice @ 312
+ DPSrenderbands @ 313
+ DPSconcatmatrix @ 314
+ DPSdtransform @ 315
+ DPSidentmatrix @ 316
+ DPSidtransform @ 317
+ DPSinvertmatrix @ 318
+ DPSitransform @ 319
+ DPStransform @ 320
+ DPSgetboolean @ 321
+ DPSgetchararray @ 322
+ DPSgetfloat @ 323
+ DPSgetfloatarray @ 324
+ DPSgetint @ 325
+ DPSgetintarray @ 326
+ DPSgetstring @ 327
+ DPSsendboolean @ 328
+ DPSsendchararray @ 329
+ DPSsendfloat @ 330
+ DPSsendfloatarray @ 331
+ DPSsendint @ 332
+ DPSsendintarray @ 333
+ DPSsendstring @ 334
+ DPSarc @ 335
+ DPSarcn @ 336
+ DPSarct @ 337
+ DPSarcto @ 338
+ DPScharpath @ 339
+ DPSclip @ 340
+ DPSclippath @ 341
+ DPSclosepath @ 342
+ DPScurveto @ 343
+ DPSeoclip @ 344
+ DPSeoviewclip @ 345
+ DPSflattenpath @ 346
+ DPSinitclip @ 347
+ DPSinitviewclip @ 348
+ DPSlineto @ 349
+ DPSmoveto @ 350
+ DPSnewpath @ 351
+ DPSpathbbox @ 352
+ DPSpathforall @ 353
+ DPSrcurveto @ 354
+ DPSrectclip @ 355
+ DPSrectviewclip @ 356
+ DPSreversepath @ 357
+ DPSrlineto @ 358
+ DPSrmoveto @ 359
+ DPSsetbbox @ 360
+ DPSsetucacheparams @ 361
+ DPSuappend @ 362
+ DPSucache @ 363
+ DPSucachestatus @ 364
+ DPSupath @ 365
+ DPSviewclip @ 366
+ DPSviewclippath @ 367
+ DPSashow @ 368
+ DPSawidthshow @ 369
+ DPScopypage @ 370
+ DPSeofill @ 371
+ DPSerasepage @ 372
+ DPSfill @ 373
+ DPSimage @ 374
+ DPSimagemask @ 375
+ DPSkshow @ 376
+ DPSrectfill @ 377
+ DPSrectstroke @ 378
+ DPSshow @ 379
+ DPSshowpage @ 380
+ DPSstroke @ 381
+ DPSstrokepath @ 382
+ DPSueofill @ 383
+ DPSufill @ 384
+ DPSustroke @ 385
+ DPSustrokepath @ 386
+ DPSwidthshow @ 387
+ DPSxshow @ 388
+ DPSxyshow @ 389
+ DPSyshow @ 390
+ DPSInitClient @ 391
+ DPSIncludePrivContext @ 392
+ DPSSendPostScript @ 393
+ DPSSendInterrupt @ 394
+ DPSSendEOF @ 395
+ DPSSendTerminate @ 396
+ DPSSendDestroySpace @ 397
+ DPSCheckRaiseError @ 399
+ DPSInitSysNames @ 400
+ DPSSetWh @ 401
+ DPSOutOfMemory @ 402
+ DPSbind @ 403
+ DPScleardictstack @ 404
+ DPScountdictstack @ 405
+ DPScountexecstack @ 406
+ DPScurrentdict @ 407
+ DPScurrentpacking @ 408
+ DPScurrentshared @ 409
+ DPSdeviceinfo @ 410
+ DPSerrordict @ 411
+ DPSexec @ 412
+ DPSprompt @ 413
+ DPSquit @ 414
+ DPSrand @ 415
+ DPSrealtime @ 416
+ DPSrestore @ 417
+ DPSrrand @ 418
+ DPSrun @ 419
+ DPSsave @ 420
+ DPSsetpacking @ 421
+ DPSsetshared @ 422
+ DPSsrand @ 423
+ DPSstart @ 424
+ DPStype @ 425
+ DPSundef @ 426
+ DPSusertime @ 427
+ DPSversion @ 428
+ DPSvmreclaim @ 429
+ DPSvmstatus @ 430
+ DPSineofill @ 431
+ DPSinfill @ 432
+ DPSinstroke @ 433
+ DPSinueofill @ 434
+ DPSinufill @ 435
+ DPSinustroke @ 436
+ DPSwtranslation @ 437
+ PSclientsync @ 438
+ PScurrentXgcdrawable @ 439
+ PScurrentXgcdrawablecolor @ 440
+ PScurrentXoffset @ 441
+ PSsetXgcdrawable @ 442
+ PSsetXgcdrawablecolor @ 443
+ PSsetXoffset @ 444
+ PSsetXrgbactual @ 445
+ PSclientXready @ 446
+ PSsetXdrawingfunction @ 447
+ PScurrentXdrawingfunction @ 448
+ PScolorimage @ 449
+ PScurrentblackgeneration @ 450
+ PScurrentcmykcolor @ 451
+ PScurrentcolorscreen @ 452
+ PScurrentcolortransfer @ 453
+ PScurrentundercolorremoval @ 454
+ PSsetblackgeneration @ 455
+ PSsetcmykcolor @ 456
+ PSsetcolorscreen @ 457
+ PSsetcolortransfer @ 458
+ PSsetundercolorremoval @ 459
+ PSeq @ 460
+ PSexit @ 461
+ PSfalse @ 462
+ PSfor @ 463
+ PSforall @ 464
+ PSge @ 465
+ PSgt @ 466
+ PSif @ 467
+ PSifelse @ 468
+ PSle @ 469
+ PSloop @ 470
+ PSlt @ 471
+ PSne @ 472
+ PSnot @ 473
+ PSor @ 474
+ PSrepeat @ 475
+ PSstop @ 476
+ PSstopped @ 477
+ PStrue @ 478
+ PSUserObjects @ 479
+ PScondition @ 480
+ PScurrentcontext @ 481
+ PScurrentobjectformat @ 482
+ PSdefineusername @ 483
+ PSdefineuserobject @ 484
+ PSdetach @ 485
+ PSexecuserobject @ 486
+ PSfork @ 487
+ PSjoin @ 488
+ PSlock @ 489
+ PSmonitor @ 490
+ PSnotify @ 491
+ PSsetobjectformat @ 492
+ PSsetvmthreshold @ 493
+ PSundefineuserobject @ 494
+ PSwait @ 495
+ PSyield @ 496
+ PSaload @ 497
+ PSanchorsearch @ 498
+ PSarray @ 499
+ PSastore @ 500
+ PSbegin @ 501
+ PSclear @ 502
+ PScleartomark @ 503
+ PScopy @ 504
+ PScount @ 505
+ PScounttomark @ 506
+ PScvi @ 507
+ PScvlit @ 508
+ PScvn @ 509
+ PScvr @ 510
+ PScvrs @ 511
+ PScvs @ 512
+ PScvx @ 513
+ PSdef @ 514
+ PSdict @ 515
+ PSdictstack @ 516
+ PSdup @ 517
+ PSend @ 518
+ PSexch @ 519
+ PSexecstack @ 520
+ PSexecuteonly @ 521
+ PSget @ 522
+ PSgetinterval @ 523
+ PSindex @ 524
+ PSknown @ 525
+ PSlength @ 526
+ PSload @ 527
+ PSmark @ 528
+ PSmatrix @ 529
+ PSmaxlength @ 530
+ PSnoaccess @ 531
+ PSnull @ 532
+ PSpackedarray @ 533
+ PSpop @ 534
+ PSput @ 535
+ PSputinterval @ 536
+ PSrcheck @ 537
+ PSreadonly @ 538
+ PSroll @ 539
+ PSscheck @ 540
+ PSsearch @ 541
+ PSshareddict @ 542
+ PSstatusdict @ 543
+ PSstore @ 544
+ PSstring @ 545
+ PSstringwidth @ 546
+ PSsystemdict @ 547
+ PSuserdict @ 548
+ PSwcheck @ 549
+ PSwhere @ 550
+ PSxcheck @ 551
+ PSFontDirectory @ 552
+ PSISOLatin1Encoding @ 553
+ PSSharedFontDirectory @ 554
+ PSStandardEncoding @ 555
+ PScachestatus @ 556
+ PScurrentcacheparams @ 557
+ PScurrentfont @ 558
+ PSdefinefont @ 559
+ PSfindfont @ 560
+ PSmakefont @ 561
+ PSscalefont @ 562
+ PSselectfont @ 563
+ PSsetcachedevice @ 564
+ PSsetcachelimit @ 565
+ PSsetcacheparams @ 566
+ PSsetcharwidth @ 567
+ PSsetfont @ 568
+ PSundefinefont @ 569
+ PSconcat @ 570
+ PScurrentdash @ 571
+ PScurrentflat @ 572
+ PScurrentgray @ 573
+ PScurrentgstate @ 574
+ PScurrenthalftone @ 575
+ PScurrenthalftonephase @ 576
+ PScurrenthsbcolor @ 577
+ PScurrentlinecap @ 578
+ PScurrentlinejoin @ 579
+ PScurrentlinewidth @ 580
+ PScurrentmatrix @ 581
+ PScurrentmiterlimit @ 582
+ PScurrentpoint @ 583
+ PScurrentrgbcolor @ 584
+ PScurrentscreen @ 585
+ PScurrentstrokeadjust @ 586
+ PScurrenttransfer @ 587
+ PSdefaultmatrix @ 588
+ PSgrestore @ 589
+ PSgrestoreall @ 590
+ PSgsave @ 591
+ PSgstate @ 592
+ PSinitgraphics @ 593
+ PSinitmatrix @ 594
+ PSrotate @ 595
+ PSscale @ 596
+ PSsetdash @ 597
+ PSsetflat @ 598
+ PSsetgray @ 599
+ PSsetgstate @ 600
+ PSsethalftone @ 601
+ PSsethalftonephase @ 602
+ PSsethsbcolor @ 603
+ PSsetlinecap @ 604
+ PSsetlinejoin @ 605
+ PSsetlinewidth @ 606
+ PSsetmatrix @ 607
+ PSsetmiterlimit @ 608
+ PSsetrgbcolor @ 609
+ PSsetscreen @ 610
+ PSsetstrokeadjust @ 611
+ PSsettransfer @ 612
+ PStranslate @ 613
+ PSequals @ 614
+ PSequalsequals @ 615
+ PSbytesavailable @ 616
+ PSclosefile @ 617
+ PScurrentfile @ 618
+ PSdeletefile @ 619
+ PSecho @ 620
+ PSfile @ 621
+ PSfilenameforall @ 622
+ PSfileposition @ 623
+ PSflush @ 624
+ PSflushfile @ 625
+ PSprint @ 626
+ PSprintobject @ 627
+ PSpstack @ 628
+ PSread @ 629
+ PSreadhexstring @ 630
+ PSreadline @ 631
+ PSreadstring @ 632
+ PSrenamefile @ 633
+ PSresetfile @ 634
+ PSsetfileposition @ 635
+ PSstack @ 636
+ PSstatus @ 637
+ PStoken @ 638
+ PSwrite @ 639
+ PSwritehexstring @ 640
+ PSwriteobject @ 641
+ PSwritestring @ 642
+ PSleftbracket @ 643
+ PSrightbracket @ 644
+ PSleftleft @ 645
+ PSrightright @ 646
+ PScshow @ 647
+ PScurrentcolor @ 648
+ PScurrentcolorrendering @ 649
+ PScurrentcolorspace @ 650
+ PScurrentdevparams @ 651
+ PScurrentglobal @ 652
+ PScurrentoverprint @ 653
+ PScurrentpagedevice @ 654
+ PScurrentsystemparams @ 655
+ PScurrentuserparams @ 656
+ PSdefineresource @ 657
+ PSexecform @ 658
+ PSfilter @ 659
+ PSfindencoding @ 660
+ PSfindresource @ 661
+ PSgcheck @ 662
+ PSglobaldict @ 663
+ PSGlobalFontDirectory @ 664
+ PSglyphshow @ 665
+ PSlanguagelevel @ 666
+ PSmakepattern @ 667
+ PSproduct @ 668
+ PSresourceforall @ 669
+ PSresourcestatus @ 670
+ PSrevision @ 671
+ PSrootfont @ 672
+ PSserialnumber @ 673
+ PSsetcolor @ 674
+ PSsetcolorrendering @ 675
+ PSsetcolorspace @ 676
+ PSsetdevparams @ 677
+ PSsetglobal @ 678
+ PSsetoverprint @ 679
+ PSsetpagedevice @ 680
+ PSsetpattern @ 681
+ PSsetsystemparams @ 682
+ PSsetuserparams @ 683
+ PSstartjob @ 684
+ PSundefineresource @ 685
+ PSabs @ 686
+ PSadd @ 687
+ PSand @ 688
+ PSatan @ 689
+ PSbitshift @ 690
+ PSceiling @ 691
+ PScos @ 692
+ PSdiv @ 693
+ PSexp @ 694
+ PSfloor @ 695
+ PSidiv @ 696
+ PSln @ 697
+ PSlog @ 698
+ PSmod @ 699
+ PSmul @ 700
+ PSneg @ 701
+ PSround @ 702
+ PSsin @ 703
+ PSsqrt @ 704
+ PSsub @ 705
+ PStruncate @ 706
+ PSxor @ 707
+ PSbanddevice @ 708
+ PSframedevice @ 709
+ PSnulldevice @ 710
+ PSrenderbands @ 711
+ PSconcatmatrix @ 712
+ PSdtransform @ 713
+ PSidentmatrix @ 714
+ PSidtransform @ 715
+ PSinvertmatrix @ 716
+ PSitransform @ 717
+ PStransform @ 718
+ PSgetboolean @ 719
+ PSgetchararray @ 720
+ PSgetfloat @ 721
+ PSgetfloatarray @ 722
+ PSgetint @ 723
+ PSgetintarray @ 724
+ PSgetstring @ 725
+ PSsendboolean @ 726
+ PSsendchararray @ 727
+ PSsendfloat @ 728
+ PSsendfloatarray @ 729
+ PSsendint @ 730
+ PSsendintarray @ 731
+ PSsendstring @ 732
+ PSarc @ 733
+ PSarcn @ 734
+ PSarct @ 735
+ PSarcto @ 736
+ PScharpath @ 737
+ PSclip @ 738
+ PSclippath @ 739
+ PSclosepath @ 740
+ PScurveto @ 741
+ PSeoclip @ 742
+ PSeoviewclip @ 743
+ PSflattenpath @ 744
+ PSinitclip @ 745
+ PSinitviewclip @ 746
+ PSlineto @ 747
+ PSmoveto @ 748
+ PSnewpath @ 749
+ PSpathbbox @ 750
+ PSpathforall @ 751
+ PSrcurveto @ 752
+ PSrectclip @ 753
+ PSrectviewclip @ 754
+ PSreversepath @ 755
+ PSrlineto @ 756
+ PSrmoveto @ 757
+ PSsetbbox @ 758
+ PSsetucacheparams @ 759
+ PSuappend @ 760
+ PSucache @ 761
+ PSucachestatus @ 762
+ PSupath @ 763
+ PSviewclip @ 764
+ PSviewclippath @ 765
+ PSashow @ 766
+ PSawidthshow @ 767
+ PScopypage @ 768
+ PSeofill @ 769
+ PSerasepage @ 770
+ PSfill @ 771
+ PSimage @ 772
+ PSimagemask @ 773
+ PSkshow @ 774
+ PSrectfill @ 775
+ PSrectstroke @ 776
+ PSshow @ 777
+ PSshowpage @ 778
+ PSstroke @ 779
+ PSstrokepath @ 780
+ PSueofill @ 781
+ PSufill @ 782
+ PSustroke @ 783
+ PSustrokepath @ 784
+ PSwidthshow @ 785
+ PSxshow @ 786
+ PSxyshow @ 787
+ PSyshow @ 788
+ PSbind @ 789
+ PScleardictstack @ 790
+ PScountdictstack @ 791
+ PScountexecstack @ 792
+ PScurrentdict @ 793
+ PScurrentpacking @ 794
+ PScurrentshared @ 795
+ PSdeviceinfo @ 796
+ PSerrordict @ 797
+ PSexec @ 798
+ PSprompt @ 799
+ PSquit @ 800
+ PSrand @ 801
+ PSrealtime @ 802
+ PSrestore @ 803
+ PSrrand @ 804
+ PSrun @ 805
+ PSsave @ 806
+ PSsetpacking @ 807
+ PSsetshared @ 808
+ PSsrand @ 809
+ PSstart @ 810
+ PStype @ 811
+ PSundef @ 812
+ PSusertime @ 813
+ PSversion @ 814
+ PSvmreclaim @ 815
+ PSvmstatus @ 816
+ PSineofill @ 817
+ PSinfill @ 818
+ PSinstroke @ 819
+ PSinueofill @ 820
+ PSinufill @ 821
+ PSinustroke @ 822
+ PSwtranslation @ 823
+ XDPSLInit @824
+ DPSWriteStringChars @ 825
+ XDPSUnfreezeContext @ 826
+ DPSGetCurrentContext @ 827
+ DPSAwaitReturnValues @ 828
+ DPSNewUserObjectIndex @ 829
+ XDPSGetContextStatus @ 830
+ XDPSRegisterStatusProc @ 831
+ DPSDefaultTextBackstop @ 832
+ DPSMapNames @ 833
+ XDPSGetDefaultColorMaps @ 834
+ XDPSCreateSimpleContext @ 835
+ DPSGenerateExtensionRecID @ 836
+ DPSWaitContext @ 837
+ DPSAddContextExtensionRec @ 838
+ DPSGetContextExtensionRec @ 839
+ DPSChainContext @ 840
+ DPSDestroySpace @ 841
+ DPSUnchainContext @ 842
+ DPSBinObjSeqWrite @ 843
+ DPSSetResultTable @ 844
+ XDPSSetStatusMask @ 845
+ XDPSXIDFromContext @ 846
+ DPSWritePostScript @ 847
+ DPSRemoveContextExtensionRec @ 848
+ DPSDefaultErrorProc @ 849
+ DPSCreateTextContext @ 850
diff --git a/xc/lib/dps/dpsos2.rsp b/xc/lib/dps/dpsos2.rsp
new file mode 100644
index 000000000..f920c7f81
--- /dev/null
+++ b/xc/lib/dps/dpsos2.rsp
@@ -0,0 +1,13 @@
+XDPS.obj csconndi.obj csfindNX.obj cslibext.obj cslibint.obj csopendi.obj+
+csstartNX.obj dpsXclient.obj dpsXcmu.obj dpsXops.obj dpsXpriv.obj+
+dpsXtdisp.obj dpsabbrev.obj dpsclient.obj dpsclrops.obj dpsctrlops.obj+
+dpsctxtops.obj dpsdataops.obj dpsdict.obj dpsexcept.obj dpsfontops.obj+
+dpsgsttops.obj dpsioops.obj dpsl2ops.obj dpsmathops.obj dpsmiscops.obj+
+dpsmtrxops.obj dpsopstack.obj dpspathops.obj dpspntops.obj dpsprintf.obj+
+dpssysnames.obj dpssysops.obj dpswinops.obj psXops.obj psclrops.obj+
+psctrlops.obj psctxtops.obj psdataops.obj psfontops.obj psgsttops.obj+
+psioops.obj psl2ops.obj psmathops.obj psmiscops.obj psmtrxops.obj+
+psopstack.obj pspathops.obj pspntops.obj pssysops.obj pswinops.obj+
+/NOI /NOL /NOD /BAT
+dps.dll
+dps.map
diff --git a/xc/lib/dps/genheader.cmd b/xc/lib/dps/genheader.cmd
new file mode 100644
index 000000000..9bcc394ff
--- /dev/null
+++ b/xc/lib/dps/genheader.cmd
@@ -0,0 +1,14 @@
+REM
+/* OS/2 generate header files */
+/* $XFree86: xc/lib/dps/genheader.cmd,v 1.2 2000/05/18 23:46:14 dawes Exp $ */
+cat psclrops.h psctrlops.h psctxtops.h psdataops.h psfontops.h psgsttops.h psioops.h psmathops.h psmtrxops.h psmiscops.h pspntops.h pspathops.h pssysops.h pswinops.h psopstack.h psXops.h psl2ops.h >.ph
+sed -e "/^$$/D" -e "/#/D" -e "/^\//D" -e "/^ gener/D" -e "/^.\//D" .ph | sort >.sort
+awk "/;/ {print;printf(\"\n\");}" .sort >.ttt
+cat psname.txt header.txt psifdef.txt .ttt psendif.txt > psops.h.os2
+rm .ph .sort .ttt
+
+cat dpsclrops.h dpsctrlops.h dpsctxtops.h dpsdataops.h dpsfontops.h dpsgsttops.h dpsioops.h dpsmathops.h dpsmtrxops.h dpsmiscops.h dpspntops.h dpspathops.h dpssysops.h dpswinops.h dpsopstack.h dpsXops.h dpsl2ops.h >.ph
+sed -e "/^$$/D" -e "/#/D" -e "/^\//D" -e "/^ gener/D" -e "/^.\//D" .ph | sort >.sort
+awk "/;/ {print;printf(\"\n\");}" .sort >.ttt
+cat dpsname.txt header.txt dpsifdef.txt .ttt dpsendif.txt > dpsops.h.os2
+rm .ph .sort .ttt
diff --git a/xc/lib/dps/psops.h.os2 b/xc/lib/dps/psops.h.os2
new file mode 100644
index 000000000..20ff44844
--- /dev/null
+++ b/xc/lib/dps/psops.h.os2
@@ -0,0 +1,1602 @@
+/*
+ * psops.h
+ */
+/*
+ * (c) Copyright 1988-1994 Adobe Systems Incorporated.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sublicense this software
+ * and its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notices appear in all copies and that
+ * both those copyright notices and this permission notice appear in
+ * supporting documentation and that the name of Adobe Systems Incorporated
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. No trademark license
+ * to use the Adobe trademarks is hereby granted. If the Adobe trademark
+ * "Display PostScript"(tm) is used to describe this software, its
+ * functionality or for any other purpose, such use shall be limited to a
+ * statement that this software works in conjunction with the Display
+ * PostScript system. Proper trademark attribution to reflect Adobe's
+ * ownership of the trademark shall be given whenever any such reference to
+ * the Display PostScript system is made.
+ *
+ * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
+ * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
+ * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
+ * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
+ * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
+ *
+ * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+ * Incorporated which may be registered in certain jurisdictions
+ *
+ * Author: Adobe Systems Incorporated
+ */
+/* $XFree86: xc/lib/dps/psops.h.os2,v 1.2 2000/06/07 22:02:57 tsi Exp $ */
+
+#ifndef PSOPS_H
+#define PSOPS_H
+
+#ifdef _NO_PROTO
+
+extern void PSFontDirectory();
+
+extern void PSGlobalFontDirectory();
+
+extern void PSISOLatin1Encoding();
+
+extern void PSSharedFontDirectory();
+
+extern void PSStandardEncoding();
+
+extern void PSUserObjects();
+
+extern void PSabs();
+
+extern void PSadd();
+
+extern void PSaload();
+
+extern void PSanchorsearch( /* int *truth; */ );
+
+extern void PSand();
+
+extern void PSarc( /* float x, y, r, angle1, angle2; */ );
+
+extern void PSarcn( /* float x, y, r, angle1, angle2; */ );
+
+extern void PSarct( /* float x1, y1, x2, y2, r; */ );
+
+extern void PSarcto( /* float x1, y1, x2, y2, r; float *xt1, *yt1, *xt2, *yt2; */ );
+
+extern void PSarray( /* int len; */ );
+
+extern void PSashow( /* float x, y; char *s; */ );
+
+extern void PSastore();
+
+extern void PSatan();
+
+extern void PSawidthshow( /* float cx, cy; int c; float ax, ay; char *s; */ );
+
+extern void PSbanddevice();
+
+extern void PSbegin();
+
+extern void PSbind();
+
+extern void PSbitshift( /* int shift; */ );
+
+extern void PSbytesavailable( /* int *n; */ );
+
+extern void PScachestatus();
+
+extern void PSceiling();
+
+extern void PScharpath( /* char *s; int b; */ );
+
+extern void PSclear();
+
+extern void PScleardictstack();
+
+extern void PScleartomark();
+
+extern void PSclientXready( /* int i0, i1, i2, i3; */ );
+
+extern void PSclientsync();
+
+extern void PSclip();
+
+extern void PSclippath();
+
+extern void PSclosefile();
+
+extern void PSclosepath();
+
+extern void PScolorimage();
+
+extern void PSconcat( /* float m[]; */ );
+
+extern void PSconcatmatrix();
+
+extern void PScondition();
+
+extern void PScopy( /* int n; */ );
+
+extern void PScopypage();
+
+extern void PScos();
+
+extern void PScount( /* int *n; */ );
+
+extern void PScountdictstack( /* int *n; */ );
+
+extern void PScountexecstack( /* int *n; */ );
+
+extern void PScounttomark( /* int *n; */ );
+
+extern void PScshow( /* char *s; */ );
+
+extern void PScurrentXdrawingfunction( /* int *function; */ );
+
+extern void PScurrentXgcdrawable( /* int *gc, *draw, *x, *y; */ );
+
+extern void PScurrentXgcdrawablecolor( /* int *gc, *draw, *x, *y, colorInfo[]; */ );
+
+extern void PScurrentXoffset( /* int *x, *y; */ );
+
+extern void PScurrentblackgeneration();
+
+extern void PScurrentcacheparams();
+
+extern void PScurrentcmykcolor( /* float *c, *m, *y, *k; */ );
+
+extern void PScurrentcolor();
+
+extern void PScurrentcolorrendering();
+
+extern void PScurrentcolorscreen();
+
+extern void PScurrentcolorspace();
+
+extern void PScurrentcolortransfer();
+
+extern void PScurrentcontext( /* int *cid; */ );
+
+extern void PScurrentdash();
+
+extern void PScurrentdevparams( /* char *dev; */ );
+
+extern void PScurrentdict();
+
+extern void PScurrentfile();
+
+extern void PScurrentflat( /* float *flatness; */ );
+
+extern void PScurrentfont();
+
+extern void PScurrentglobal( /* int *b; */ );
+
+extern void PScurrentgray( /* float *gray; */ );
+
+extern void PScurrentgstate( /* int gst; */ );
+
+extern void PScurrenthalftone();
+
+extern void PScurrenthalftonephase( /* float *x, *y; */ );
+
+extern void PScurrenthsbcolor( /* float *h, *s, *b; */ );
+
+extern void PScurrentlinecap( /* int *linecap; */ );
+
+extern void PScurrentlinejoin( /* int *linejoin; */ );
+
+extern void PScurrentlinewidth( /* float *width; */ );
+
+extern void PScurrentmatrix();
+
+extern void PScurrentmiterlimit( /* float *limit; */ );
+
+extern void PScurrentobjectformat( /* int *code; */ );
+
+extern void PScurrentoverprint( /* int *b; */ );
+
+extern void PScurrentpacking( /* int *b; */ );
+
+extern void PScurrentpagedevice();
+
+extern void PScurrentpoint( /* float *x, *y; */ );
+
+extern void PScurrentrgbcolor( /* float *r, *g, *b; */ );
+
+extern void PScurrentscreen();
+
+extern void PScurrentshared( /* int *b; */ );
+
+extern void PScurrentstrokeadjust( /* int *b; */ );
+
+extern void PScurrentsystemparams();
+
+extern void PScurrenttransfer();
+
+extern void PScurrentundercolorremoval();
+
+extern void PScurrentuserparams();
+
+extern void PScurveto( /* float x1, y1, x2, y2, x3, y3; */ );
+
+extern void PScvi();
+
+extern void PScvlit();
+
+extern void PScvn();
+
+extern void PScvr();
+
+extern void PScvrs();
+
+extern void PScvs();
+
+extern void PScvx();
+
+extern void PSdef();
+
+extern void PSdefaultmatrix();
+
+extern void PSdefinefont();
+
+extern void PSdefineresource( /* char *category; */ );
+
+extern void PSdefineusername( /* int i; char *username; */ );
+
+extern void PSdefineuserobject();
+
+extern void PSdeletefile( /* char *filename; */ );
+
+extern void PSdetach();
+
+extern void PSdeviceinfo();
+
+extern void PSdict( /* int len; */ );
+
+extern void PSdictstack();
+
+extern void PSdiv();
+
+extern void PSdtransform( /* float x1, y1; float *x2, *y2; */ );
+
+extern void PSdup();
+
+extern void PSecho( /* int b; */ );
+
+extern void PSend();
+
+extern void PSeoclip();
+
+extern void PSeofill();
+
+extern void PSeoviewclip();
+
+extern void PSeq();
+
+extern void PSequals();
+
+extern void PSequalsequals();
+
+extern void PSerasepage();
+
+extern void PSerrordict();
+
+extern void PSexch();
+
+extern void PSexec();
+
+extern void PSexecform();
+
+extern void PSexecstack();
+
+extern void PSexecuserobject( /* int userObjIndex; */ );
+
+extern void PSexecuteonly();
+
+extern void PSexit();
+
+extern void PSexp();
+
+extern void PSfalse();
+
+extern void PSfile( /* char *name, *access; */ );
+
+extern void PSfilenameforall();
+
+extern void PSfileposition( /* int *pos; */ );
+
+extern void PSfill();
+
+extern void PSfilter();
+
+extern void PSfindencoding( /* char *key; */ );
+
+extern void PSfindfont( /* char *name; */ );
+
+extern void PSfindresource( /* char *key, *category; */ );
+
+extern void PSflattenpath();
+
+extern void PSfloor();
+
+extern void PSflush();
+
+extern void PSflushfile();
+
+extern void PSfor();
+
+extern void PSforall();
+
+extern void PSfork();
+
+extern void PSframedevice();
+
+extern void PSgcheck( /* int *b; */ );
+
+extern void PSge();
+
+extern void PSget();
+
+extern void PSgetboolean( /* int *it; */ );
+
+extern void PSgetchararray( /* int size; char s[]; */ );
+
+extern void PSgetfloat( /* float *it; */ );
+
+extern void PSgetfloatarray( /* int size; float a[]; */ );
+
+extern void PSgetint( /* int *it; */ );
+
+extern void PSgetintarray( /* int size; int a[]; */ );
+
+extern void PSgetinterval();
+
+extern void PSgetstring( /* char *s; */ );
+
+extern void PSglobaldict();
+
+extern void PSglyphshow( /* char *name; */ );
+
+extern void PSgrestore();
+
+extern void PSgrestoreall();
+
+extern void PSgsave();
+
+extern void PSgstate();
+
+extern void PSgt();
+
+extern void PSidentmatrix();
+
+extern void PSidiv();
+
+extern void PSidtransform( /* float x1, y1; float *x2, *y2; */ );
+
+extern void PSif();
+
+extern void PSifelse();
+
+extern void PSimage();
+
+extern void PSimagemask();
+
+extern void PSindex( /* int i; */ );
+
+extern void PSineofill( /* float x, y; int *b; */ );
+
+extern void PSinfill( /* float x, y; int *b; */ );
+
+extern void PSinitclip();
+
+extern void PSinitgraphics();
+
+extern void PSinitmatrix();
+
+extern void PSinitviewclip();
+
+extern void PSinstroke( /* float x, y; int *b; */ );
+
+extern void PSinueofill( /* float x, y; char nums[]; int n; char ops[]; int l; int *b; */ );
+
+extern void PSinufill( /* float x, y; char nums[]; int n; char ops[]; int l; int *b; */ );
+
+extern void PSinustroke( /* float x, y; char nums[]; int n; char ops[]; int l; int *b; */ );
+
+extern void PSinvertmatrix();
+
+extern void PSitransform( /* float x1, y1; float *x2, *y2; */ );
+
+extern void PSjoin();
+
+extern void PSknown( /* int *b; */ );
+
+extern void PSkshow( /* char *s; */ );
+
+extern void PSlanguagelevel( /* int *n; */ );
+
+extern void PSle();
+
+extern void PSleftbracket();
+
+extern void PSleftleft();
+
+extern void PSlength( /* int *len; */ );
+
+extern void PSlineto( /* float x, y; */ );
+
+extern void PSln();
+
+extern void PSload();
+
+extern void PSlock();
+
+extern void PSlog();
+
+extern void PSloop();
+
+extern void PSlt();
+
+extern void PSmakefont();
+
+extern void PSmakepattern();
+
+extern void PSmark();
+
+extern void PSmatrix();
+
+extern void PSmaxlength( /* int *len; */ );
+
+extern void PSmod();
+
+extern void PSmonitor();
+
+extern void PSmoveto( /* float x, y; */ );
+
+extern void PSmul();
+
+extern void PSne();
+
+extern void PSneg();
+
+extern void PSnewpath();
+
+extern void PSnoaccess();
+
+extern void PSnot();
+
+extern void PSnotify();
+
+extern void PSnull();
+
+extern void PSnulldevice();
+
+extern void PSor();
+
+extern void PSpackedarray();
+
+extern void PSpathbbox( /* float *llx, *lly, *urx, *ury; */ );
+
+extern void PSpathforall();
+
+extern void PSpop();
+
+extern void PSprint();
+
+extern void PSprintobject( /* int tag; */ );
+
+extern void PSproduct();
+
+extern void PSprompt();
+
+extern void PSpstack();
+
+extern void PSput();
+
+extern void PSputinterval();
+
+extern void PSquit();
+
+extern void PSrand();
+
+extern void PSrcheck( /* int *b; */ );
+
+extern void PSrcurveto( /* float x1, y1, x2, y2, x3, y3; */ );
+
+extern void PSread( /* int *b; */ );
+
+extern void PSreadhexstring( /* int *b; */ );
+
+extern void PSreadline( /* int *b; */ );
+
+extern void PSreadonly();
+
+extern void PSreadstring( /* int *b; */ );
+
+extern void PSrealtime( /* int *i; */ );
+
+extern void PSrectclip( /* float x, y, w, h; */ );
+
+extern void PSrectfill( /* float x, y, w, h; */ );
+
+extern void PSrectstroke( /* float x, y, w, h; */ );
+
+extern void PSrectviewclip( /* float x, y, w, h; */ );
+
+extern void PSrenamefile( /* char *oldname, *newname; */ );
+
+extern void PSrenderbands();
+
+extern void PSrepeat();
+
+extern void PSresetfile();
+
+extern void PSresourceforall( /* char *category; */ );
+
+extern void PSresourcestatus( /* char *key, *category; int *b; */ );
+
+extern void PSrestore();
+
+extern void PSreversepath();
+
+extern void PSrevision( /* int *n; */ );
+
+extern void PSrightbracket();
+
+extern void PSrightright();
+
+extern void PSrlineto( /* float x, y; */ );
+
+extern void PSrmoveto( /* float x, y; */ );
+
+extern void PSroll( /* int n, j; */ );
+
+extern void PSrootfont();
+
+extern void PSrotate( /* float angle; */ );
+
+extern void PSround();
+
+extern void PSrrand();
+
+extern void PSrun( /* char *filename; */ );
+
+extern void PSsave();
+
+extern void PSscale( /* float x, y; */ );
+
+extern void PSscalefont( /* float size; */ );
+
+extern void PSscheck( /* int *b; */ );
+
+extern void PSsearch( /* int *b; */ );
+
+extern void PSselectfont( /* char *name; float scale; */ );
+
+extern void PSsendboolean( /* int it; */ );
+
+extern void PSsendchararray( /* char s[]; int size; */ );
+
+extern void PSsendfloat( /* float it; */ );
+
+extern void PSsendfloatarray( /* float a[]; int size; */ );
+
+extern void PSsendint( /* int it; */ );
+
+extern void PSsendintarray( /* int a[]; int size; */ );
+
+extern void PSsendstring( /* char *s; */ );
+
+extern void PSserialnumber( /* int *n; */ );
+
+extern void PSsetXdrawingfunction( /* int function; */ );
+
+extern void PSsetXgcdrawable( /* int gc, draw, x, y; */ );
+
+extern void PSsetXgcdrawablecolor( /* int gc, draw, x, y, colorInfo[]; */ );
+
+extern void PSsetXoffset( /* int x, y; */ );
+
+extern void PSsetXrgbactual( /* float r, g, b; int *success; */ );
+
+extern void PSsetbbox( /* float llx, lly, urx, ury; */ );
+
+extern void PSsetblackgeneration();
+
+extern void PSsetcachedevice( /* float wx, wy, llx, lly, urx, ury; */ );
+
+extern void PSsetcachelimit( /* int n; */ );
+
+extern void PSsetcacheparams();
+
+extern void PSsetcharwidth( /* float wx, wy; */ );
+
+extern void PSsetcmykcolor( /* float c, m, y, k; */ );
+
+extern void PSsetcolor();
+
+extern void PSsetcolorrendering();
+
+extern void PSsetcolorscreen();
+
+extern void PSsetcolorspace();
+
+extern void PSsetcolortransfer();
+
+extern void PSsetdash( /* float pat[]; int size; float offset; */ );
+
+extern void PSsetdevparams();
+
+extern void PSsetfileposition( /* int pos; */ );
+
+extern void PSsetflat( /* float flatness; */ );
+
+extern void PSsetfont( /* int f; */ );
+
+extern void PSsetglobal( /* int b; */ );
+
+extern void PSsetgray( /* float gray; */ );
+
+extern void PSsetgstate( /* int gst; */ );
+
+extern void PSsethalftone();
+
+extern void PSsethalftonephase( /* float x, y; */ );
+
+extern void PSsethsbcolor( /* float h, s, b; */ );
+
+extern void PSsetlinecap( /* int linecap; */ );
+
+extern void PSsetlinejoin( /* int linejoin; */ );
+
+extern void PSsetlinewidth( /* float width; */ );
+
+extern void PSsetmatrix();
+
+extern void PSsetmiterlimit( /* float limit; */ );
+
+extern void PSsetobjectformat( /* int code; */ );
+
+extern void PSsetoverprint( /* int b; */ );
+
+extern void PSsetpacking( /* int b; */ );
+
+extern void PSsetpagedevice();
+
+extern void PSsetpattern();
+
+extern void PSsetrgbcolor( /* float r, g, b; */ );
+
+extern void PSsetscreen();
+
+extern void PSsetshared( /* int b; */ );
+
+extern void PSsetstrokeadjust( /* int b; */ );
+
+extern void PSsetsystemparams();
+
+extern void PSsettransfer();
+
+extern void PSsetucacheparams();
+
+extern void PSsetundercolorremoval();
+
+extern void PSsetuserparams();
+
+extern void PSsetvmthreshold( /* int i; */ );
+
+extern void PSshareddict();
+
+extern void PSshow( /* char *s; */ );
+
+extern void PSshowpage();
+
+extern void PSsin();
+
+extern void PSsqrt();
+
+extern void PSsrand();
+
+extern void PSstack();
+
+extern void PSstart();
+
+extern void PSstartjob( /* int b; char *password; */ );
+
+extern void PSstatus( /* int *b; */ );
+
+extern void PSstatusdict();
+
+extern void PSstop();
+
+extern void PSstopped();
+
+extern void PSstore();
+
+extern void PSstring( /* int len; */ );
+
+extern void PSstringwidth( /* char *s; float *xp, *yp; */ );
+
+extern void PSstroke();
+
+extern void PSstrokepath();
+
+extern void PSsub();
+
+extern void PSsystemdict();
+
+extern void PStoken( /* int *b; */ );
+
+extern void PStransform( /* float x1, y1; float *x2, *y2; */ );
+
+extern void PStranslate( /* float x, y; */ );
+
+extern void PStrue();
+
+extern void PStruncate();
+
+extern void PStype();
+
+extern void PSuappend( /* char nums[]; int n; char ops[]; int l; */ );
+
+extern void PSucache();
+
+extern void PSucachestatus();
+
+extern void PSueofill( /* char nums[]; int n; char ops[]; int l; */ );
+
+extern void PSufill( /* char nums[]; int n; char ops[]; int l; */ );
+
+extern void PSundef( /* char *name; */ );
+
+extern void PSundefinefont( /* char *name; */ );
+
+extern void PSundefineresource( /* char *key, *category; */ );
+
+extern void PSundefineuserobject( /* int userObjIndex; */ );
+
+extern void PSupath( /* int b; */ );
+
+extern void PSuserdict();
+
+extern void PSusertime( /* int *milliseconds; */ );
+
+extern void PSustroke( /* char nums[]; int n; char ops[]; int l; */ );
+
+extern void PSustrokepath( /* char nums[]; int n; char ops[]; int l; */ );
+
+extern void PSversion( /* int bufsize; char buf[]; */ );
+
+extern void PSviewclip();
+
+extern void PSviewclippath();
+
+extern void PSvmreclaim( /* int code; */ );
+
+extern void PSvmstatus( /* int *level, *used, *maximum; */ );
+
+extern void PSwait();
+
+extern void PSwcheck( /* int *b; */ );
+
+extern void PSwhere( /* int *b; */ );
+
+extern void PSwidthshow( /* float x, y; int c; char *s; */ );
+
+extern void PSwrite();
+
+extern void PSwritehexstring();
+
+extern void PSwriteobject( /* int tag; */ );
+
+extern void PSwritestring();
+
+extern void PSwtranslation( /* float *x, *y; */ );
+
+extern void PSxcheck( /* int *b; */ );
+
+extern void PSxor();
+
+extern void PSxshow( /* char *s; float numarray[]; int size; */ );
+
+extern void PSxyshow( /* char *s; float numarray[]; int size; */ );
+
+extern void PSyield();
+
+extern void PSyshow( /* char *s; float numarray[]; int size; */ );
+
+#else /* _NO_PROTO */
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+extern void PSFontDirectory( void );
+
+extern void PSGlobalFontDirectory( void );
+
+extern void PSISOLatin1Encoding( void );
+
+extern void PSSharedFontDirectory( void );
+
+extern void PSStandardEncoding( void );
+
+extern void PSUserObjects( void );
+
+extern void PSabs( void );
+
+extern void PSadd( void );
+
+extern void PSaload( void );
+
+extern void PSanchorsearch(int *truth);
+
+extern void PSand( void );
+
+extern void PSarc(float x, float y, float r, float angle1, float angle2);
+
+extern void PSarcn(float x, float y, float r, float angle1, float angle2);
+
+extern void PSarct(float x1, float y1, float x2, float y2, float r);
+
+extern void PSarcto(float x1, float y1, float x2, float y2, float r, float *xt1, float *yt1, float *xt2, float *yt2);
+
+extern void PSarray(int len);
+
+extern void PSashow(float x, float y, const char *s);
+
+extern void PSastore( void );
+
+extern void PSatan( void );
+
+extern void PSawidthshow(float cx, float cy, int c, float ax, float ay, const char *s);
+
+extern void PSbanddevice( void );
+
+extern void PSbegin( void );
+
+extern void PSbind( void );
+
+extern void PSbitshift(int shift);
+
+extern void PSbytesavailable(int *n);
+
+extern void PScachestatus( void );
+
+extern void PSceiling( void );
+
+extern void PScharpath(const char *s, int b);
+
+extern void PSclear( void );
+
+extern void PScleardictstack( void );
+
+extern void PScleartomark( void );
+
+extern void PSclientXready(int i0, int i1, int i2, int i3);
+
+extern void PSclientsync( void );
+
+extern void PSclip( void );
+
+extern void PSclippath( void );
+
+extern void PSclosefile( void );
+
+extern void PSclosepath( void );
+
+extern void PScolorimage( void );
+
+extern void PSconcat(const float m[]);
+
+extern void PSconcatmatrix( void );
+
+extern void PScondition( void );
+
+extern void PScopy(int n);
+
+extern void PScopypage( void );
+
+extern void PScos( void );
+
+extern void PScount(int *n);
+
+extern void PScountdictstack(int *n);
+
+extern void PScountexecstack(int *n);
+
+extern void PScounttomark(int *n);
+
+extern void PScshow(const char *s);
+
+extern void PScurrentXdrawingfunction(int *function);
+
+extern void PScurrentXgcdrawable(int *gc, int *draw, int *x, int *y);
+
+extern void PScurrentXgcdrawablecolor(int *gc, int *draw, int *x, int *y, int colorInfo[]);
+
+extern void PScurrentXoffset(int *x, int *y);
+
+extern void PScurrentblackgeneration( void );
+
+extern void PScurrentcacheparams( void );
+
+extern void PScurrentcmykcolor(float *c, float *m, float *y, float *k);
+
+extern void PScurrentcolor( void );
+
+extern void PScurrentcolorrendering( void );
+
+extern void PScurrentcolorscreen( void );
+
+extern void PScurrentcolorspace( void );
+
+extern void PScurrentcolortransfer( void );
+
+extern void PScurrentcontext(int *cid);
+
+extern void PScurrentdash( void );
+
+extern void PScurrentdevparams(const char *dev);
+
+extern void PScurrentdict( void );
+
+extern void PScurrentfile( void );
+
+extern void PScurrentflat(float *flatness);
+
+extern void PScurrentfont( void );
+
+extern void PScurrentglobal(int *b);
+
+extern void PScurrentgray(float *gray);
+
+extern void PScurrentgstate(int gst);
+
+extern void PScurrenthalftone( void );
+
+extern void PScurrenthalftonephase(float *x, float *y);
+
+extern void PScurrenthsbcolor(float *h, float *s, float *b);
+
+extern void PScurrentlinecap(int *linecap);
+
+extern void PScurrentlinejoin(int *linejoin);
+
+extern void PScurrentlinewidth(float *width);
+
+extern void PScurrentmatrix( void );
+
+extern void PScurrentmiterlimit(float *limit);
+
+extern void PScurrentobjectformat(int *code);
+
+extern void PScurrentoverprint(int *b);
+
+extern void PScurrentpacking(int *b);
+
+extern void PScurrentpagedevice( void );
+
+extern void PScurrentpoint(float *x, float *y);
+
+extern void PScurrentrgbcolor(float *r, float *g, float *b);
+
+extern void PScurrentscreen( void );
+
+extern void PScurrentshared(int *b);
+
+extern void PScurrentstrokeadjust(int *b);
+
+extern void PScurrentsystemparams( void );
+
+extern void PScurrenttransfer( void );
+
+extern void PScurrentundercolorremoval( void );
+
+extern void PScurrentuserparams( void );
+
+extern void PScurveto(float x1, float y1, float x2, float y2, float x3, float y3);
+
+extern void PScvi( void );
+
+extern void PScvlit( void );
+
+extern void PScvn( void );
+
+extern void PScvr( void );
+
+extern void PScvrs( void );
+
+extern void PScvs( void );
+
+extern void PScvx( void );
+
+extern void PSdef( void );
+
+extern void PSdefaultmatrix( void );
+
+extern void PSdefinefont( void );
+
+extern void PSdefineresource(const char *category);
+
+extern void PSdefineusername(int i, const char *username);
+
+extern void PSdefineuserobject( void );
+
+extern void PSdeletefile(const char *filename);
+
+extern void PSdetach( void );
+
+extern void PSdeviceinfo( void );
+
+extern void PSdict(int len);
+
+extern void PSdictstack( void );
+
+extern void PSdiv( void );
+
+extern void PSdtransform(float x1, float y1, float *x2, float *y2);
+
+extern void PSdup( void );
+
+extern void PSecho(int b);
+
+extern void PSend( void );
+
+extern void PSeoclip( void );
+
+extern void PSeofill( void );
+
+extern void PSeoviewclip( void );
+
+extern void PSeq( void );
+
+extern void PSequals( void );
+
+extern void PSequalsequals( void );
+
+extern void PSerasepage( void );
+
+extern void PSerrordict( void );
+
+extern void PSexch( void );
+
+extern void PSexec( void );
+
+extern void PSexecform( void );
+
+extern void PSexecstack( void );
+
+extern void PSexecuserobject(int userObjIndex);
+
+extern void PSexecuteonly( void );
+
+extern void PSexit( void );
+
+extern void PSexp( void );
+
+extern void PSfalse( void );
+
+extern void PSfile(const char *name, const char *access);
+
+extern void PSfilenameforall( void );
+
+extern void PSfileposition(int *pos);
+
+extern void PSfill( void );
+
+extern void PSfilter( void );
+
+extern void PSfindencoding(const char *key);
+
+extern void PSfindfont(const char *name);
+
+extern void PSfindresource(const char *key, const char *category);
+
+extern void PSflattenpath( void );
+
+extern void PSfloor( void );
+
+extern void PSflush( void );
+
+extern void PSflushfile( void );
+
+extern void PSfor( void );
+
+extern void PSforall( void );
+
+extern void PSfork( void );
+
+extern void PSframedevice( void );
+
+extern void PSgcheck(int *b);
+
+extern void PSge( void );
+
+extern void PSget( void );
+
+extern void PSgetboolean(int *it);
+
+extern void PSgetchararray(int size, char s[]);
+
+extern void PSgetfloat(float *it);
+
+extern void PSgetfloatarray(int size, float a[]);
+
+extern void PSgetint(int *it);
+
+extern void PSgetintarray(int size, int a[]);
+
+extern void PSgetinterval( void );
+
+extern void PSgetstring(char *s);
+
+extern void PSglobaldict( void );
+
+extern void PSglyphshow(const char *name);
+
+extern void PSgrestore( void );
+
+extern void PSgrestoreall( void );
+
+extern void PSgsave( void );
+
+extern void PSgstate( void );
+
+extern void PSgt( void );
+
+extern void PSidentmatrix( void );
+
+extern void PSidiv( void );
+
+extern void PSidtransform(float x1, float y1, float *x2, float *y2);
+
+extern void PSif( void );
+
+extern void PSifelse( void );
+
+extern void PSimage( void );
+
+extern void PSimagemask( void );
+
+extern void PSindex(int i);
+
+extern void PSineofill(float x, float y, int *b);
+
+extern void PSinfill(float x, float y, int *b);
+
+extern void PSinitclip( void );
+
+extern void PSinitgraphics( void );
+
+extern void PSinitmatrix( void );
+
+extern void PSinitviewclip( void );
+
+extern void PSinstroke(float x, float y, int *b);
+
+extern void PSinueofill(float x, float y, const char nums[], int n, const char ops[], int l, int *b);
+
+extern void PSinufill(float x, float y, const char nums[], int n, const char ops[], int l, int *b);
+
+extern void PSinustroke(float x, float y, const char nums[], int n, const char ops[], int l, int *b);
+
+extern void PSinvertmatrix( void );
+
+extern void PSitransform(float x1, float y1, float *x2, float *y2);
+
+extern void PSjoin( void );
+
+extern void PSknown(int *b);
+
+extern void PSkshow(const char *s);
+
+extern void PSlanguagelevel(int *n);
+
+extern void PSle( void );
+
+extern void PSleftbracket( void );
+
+extern void PSleftleft( void );
+
+extern void PSlength(int *len);
+
+extern void PSlineto(float x, float y);
+
+extern void PSln( void );
+
+extern void PSload( void );
+
+extern void PSlock( void );
+
+extern void PSlog( void );
+
+extern void PSloop( void );
+
+extern void PSlt( void );
+
+extern void PSmakefont( void );
+
+extern void PSmakepattern( void );
+
+extern void PSmark( void );
+
+extern void PSmatrix( void );
+
+extern void PSmaxlength(int *len);
+
+extern void PSmod( void );
+
+extern void PSmonitor( void );
+
+extern void PSmoveto(float x, float y);
+
+extern void PSmul( void );
+
+extern void PSne( void );
+
+extern void PSneg( void );
+
+extern void PSnewpath( void );
+
+extern void PSnoaccess( void );
+
+extern void PSnot( void );
+
+extern void PSnotify( void );
+
+extern void PSnull( void );
+
+extern void PSnulldevice( void );
+
+extern void PSor( void );
+
+extern void PSpackedarray( void );
+
+extern void PSpathbbox(float *llx, float *lly, float *urx, float *ury);
+
+extern void PSpathforall( void );
+
+extern void PSpop( void );
+
+extern void PSprint( void );
+
+extern void PSprintobject(int tag);
+
+extern void PSproduct( void );
+
+extern void PSprompt( void );
+
+extern void PSpstack( void );
+
+extern void PSput( void );
+
+extern void PSputinterval( void );
+
+extern void PSquit( void );
+
+extern void PSrand( void );
+
+extern void PSrcheck(int *b);
+
+extern void PSrcurveto(float x1, float y1, float x2, float y2, float x3, float y3);
+
+extern void PSread(int *b);
+
+extern void PSreadhexstring(int *b);
+
+extern void PSreadline(int *b);
+
+extern void PSreadonly( void );
+
+extern void PSreadstring(int *b);
+
+extern void PSrealtime(int *i);
+
+extern void PSrectclip(float x, float y, float w, float h);
+
+extern void PSrectfill(float x, float y, float w, float h);
+
+extern void PSrectstroke(float x, float y, float w, float h);
+
+extern void PSrectviewclip(float x, float y, float w, float h);
+
+extern void PSrenamefile(const char *oldname, const char *newname);
+
+extern void PSrenderbands( void );
+
+extern void PSrepeat( void );
+
+extern void PSresetfile( void );
+
+extern void PSresourceforall(const char *category);
+
+extern void PSresourcestatus(const char *key, const char *category, int *b);
+
+extern void PSrestore( void );
+
+extern void PSreversepath( void );
+
+extern void PSrevision(int *n);
+
+extern void PSrightbracket( void );
+
+extern void PSrightright( void );
+
+extern void PSrlineto(float x, float y);
+
+extern void PSrmoveto(float x, float y);
+
+extern void PSroll(int n, int j);
+
+extern void PSrootfont( void );
+
+extern void PSrotate(float angle);
+
+extern void PSround( void );
+
+extern void PSrrand( void );
+
+extern void PSrun(const char *filename);
+
+extern void PSsave( void );
+
+extern void PSscale(float x, float y);
+
+extern void PSscalefont(float size);
+
+extern void PSscheck(int *b);
+
+extern void PSsearch(int *b);
+
+extern void PSselectfont(const char *name, float scale);
+
+extern void PSsendboolean(int it);
+
+extern void PSsendchararray(const char s[], int size);
+
+extern void PSsendfloat(float it);
+
+extern void PSsendfloatarray(const float a[], int size);
+
+extern void PSsendint(int it);
+
+extern void PSsendintarray(const int a[], int size);
+
+extern void PSsendstring(const char *s);
+
+extern void PSserialnumber(int *n);
+
+extern void PSsetXdrawingfunction(int function);
+
+extern void PSsetXgcdrawable(int gc, int draw, int x, int y);
+
+extern void PSsetXgcdrawablecolor(int gc, int draw, int x, int y, const int colorInfo[]);
+
+extern void PSsetXoffset(int x, int y);
+
+extern void PSsetXrgbactual(float r, float g, float b, int *success);
+
+extern void PSsetbbox(float llx, float lly, float urx, float ury);
+
+extern void PSsetblackgeneration( void );
+
+extern void PSsetcachedevice(float wx, float wy, float llx, float lly, float urx, float ury);
+
+extern void PSsetcachelimit(int n);
+
+extern void PSsetcacheparams( void );
+
+extern void PSsetcharwidth(float wx, float wy);
+
+extern void PSsetcmykcolor(float c, float m, float y, float k);
+
+extern void PSsetcolor( void );
+
+extern void PSsetcolorrendering( void );
+
+extern void PSsetcolorscreen( void );
+
+extern void PSsetcolorspace( void );
+
+extern void PSsetcolortransfer( void );
+
+extern void PSsetdash(const float pat[], int size, float offset);
+
+extern void PSsetdevparams( void );
+
+extern void PSsetfileposition(int pos);
+
+extern void PSsetflat(float flatness);
+
+extern void PSsetfont(int f);
+
+extern void PSsetglobal(int b);
+
+extern void PSsetgray(float gray);
+
+extern void PSsetgstate(int gst);
+
+extern void PSsethalftone( void );
+
+extern void PSsethalftonephase(float x, float y);
+
+extern void PSsethsbcolor(float h, float s, float b);
+
+extern void PSsetlinecap(int linecap);
+
+extern void PSsetlinejoin(int linejoin);
+
+extern void PSsetlinewidth(float width);
+
+extern void PSsetmatrix( void );
+
+extern void PSsetmiterlimit(float limit);
+
+extern void PSsetobjectformat(int code);
+
+extern void PSsetoverprint(int b);
+
+extern void PSsetpacking(int b);
+
+extern void PSsetpagedevice( void );
+
+extern void PSsetpattern( void );
+
+extern void PSsetrgbcolor(float r, float g, float b);
+
+extern void PSsetscreen( void );
+
+extern void PSsetshared(int b);
+
+extern void PSsetstrokeadjust(int b);
+
+extern void PSsetsystemparams( void );
+
+extern void PSsettransfer( void );
+
+extern void PSsetucacheparams( void );
+
+extern void PSsetundercolorremoval( void );
+
+extern void PSsetuserparams( void );
+
+extern void PSsetvmthreshold(int i);
+
+extern void PSshareddict( void );
+
+extern void PSshow(const char *s);
+
+extern void PSshowpage( void );
+
+extern void PSsin( void );
+
+extern void PSsqrt( void );
+
+extern void PSsrand( void );
+
+extern void PSstack( void );
+
+extern void PSstart( void );
+
+extern void PSstartjob(int b, const char *password);
+
+extern void PSstatus(int *b);
+
+extern void PSstatusdict( void );
+
+extern void PSstop( void );
+
+extern void PSstopped( void );
+
+extern void PSstore( void );
+
+extern void PSstring(int len);
+
+extern void PSstringwidth(const char *s, float *xp, float *yp);
+
+extern void PSstroke( void );
+
+extern void PSstrokepath( void );
+
+extern void PSsub( void );
+
+extern void PSsystemdict( void );
+
+extern void PStoken(int *b);
+
+extern void PStransform(float x1, float y1, float *x2, float *y2);
+
+extern void PStranslate(float x, float y);
+
+extern void PStrue( void );
+
+extern void PStruncate( void );
+
+extern void PStype( void );
+
+extern void PSuappend(const char nums[], int n, const char ops[], int l);
+
+extern void PSucache( void );
+
+extern void PSucachestatus( void );
+
+extern void PSueofill(const char nums[], int n, const char ops[], int l);
+
+extern void PSufill(const char nums[], int n, const char ops[], int l);
+
+extern void PSundef(const char *name);
+
+extern void PSundefinefont(const char *name);
+
+extern void PSundefineresource(const char *key, const char *category);
+
+extern void PSundefineuserobject(int userObjIndex);
+
+extern void PSupath(int b);
+
+extern void PSuserdict( void );
+
+extern void PSusertime(int *milliseconds);
+
+extern void PSustroke(const char nums[], int n, const char ops[], int l);
+
+extern void PSustrokepath(const char nums[], int n, const char ops[], int l);
+
+extern void PSversion(int bufsize, char buf[]);
+
+extern void PSviewclip( void );
+
+extern void PSviewclippath( void );
+
+extern void PSvmreclaim(int code);
+
+extern void PSvmstatus(int *level, int *used, int *maximum);
+
+extern void PSwait( void );
+
+extern void PSwcheck(int *b);
+
+extern void PSwhere(int *b);
+
+extern void PSwidthshow(float x, float y, int c, const char *s);
+
+extern void PSwrite( void );
+
+extern void PSwritehexstring( void );
+
+extern void PSwriteobject(int tag);
+
+extern void PSwritestring( void );
+
+extern void PSwtranslation(float *x, float *y);
+
+extern void PSxcheck(int *b);
+
+extern void PSxor( void );
+
+extern void PSxshow(const char *s, const float numarray[], int size);
+
+extern void PSxyshow(const char *s, const float numarray[], int size);
+
+extern void PSyield( void );
+
+extern void PSyshow(const char *s, const float numarray[], int size);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _NO_PROTO */
+
+#endif /* PSOPS_H */
diff --git a/xc/lib/dpstk/dpstkos2.def b/xc/lib/dpstk/dpstkos2.def
new file mode 100644
index 000000000..ef5beda5f
--- /dev/null
+++ b/xc/lib/dpstk/dpstkos2.def
@@ -0,0 +1,69 @@
+LIBRARY DPSTK
+DESCRIPTION "@#XFREE86:4.0#@ $XFree86: xc/lib/dpstk/dpstkos2.def,v 1.1 2000/04/05 18:13:23 dawes Exp $"
+CODE
+ PRELOAD
+DATA
+ MULTIPLE NONSHARED
+STACKSIZE 32768
+EXPORTS
+ XDPSSetFileFunctions @ 1
+ XDPSFileRewindFunc @ 2
+ XDPSFileGetsFunc @ 3
+ XDPSEmbeddedEPSFRewindFunc @ 4
+ XDPSEmbeddedGetsFunc @ 5
+ XDPSCreatePixmapForEPSF @ 6
+ XDPSPixelsPerPoint @ 7
+ XDPSSetImagingTimeout @ 8
+ XDPSCheckImagingResults @ 9
+ XDPSImageFileIntoDrawable 10
+ _DPSPSetMatrix @ 11
+ _DPSPClearArea @ 12
+ _DPSPSetMaskTransfer @ 13
+ _DPSPDefineExecFunction @ 14
+ _DPSPSaveBeforeExec @ 15
+ _DPSPCheckForError @ 16
+ _XDPSSetComponentInitialized @ 17
+ _XDPSTestComponentInitialized @ 18
+ XDPSSetContextDepth @ 19
+ XDPSSetContextDrawable @ 20
+ XDPSSetContextRGBMap @ 21
+ XDPSSetContextGrayMap @ 22
+ XDPSSetContextParameters @ 23
+ XDPSPushContextParameters @ 24
+ XDPSPopContextParameters @ 25
+ XDPSCaptureContextGState @ 26
+ XDPSUpdateContextGState @ 27
+ XDPSFreeContextGState @ 28
+ XDPSSetContextGState @ 29
+ XDPSPushContextGState @ 30
+ XDPSPopContextGState @ 31
+ XDPSRegisterContext @ 32
+ XDPSGetSharedContext @ 33
+ XDPSDestroySharedContext @ 34
+ XDPSUnregisterContext @ 35
+ XDPSFreeDisplayInfo @ 36
+ XDPSChainTextContext @ 37
+ XDPSExtensionPresent @ 38
+ PSDefineAsUserObj @ 39
+ PSRedefineUserObj @ 40
+ PSUndefineUserObj @ 41
+ DPSDefineAsUserObj @ 42
+ DPSRedefineUserObj @ 43
+ DPSUndefineUserObj @ 44
+ PSReserveUserObjIndices @ 45
+ DPSReserveUserObjIndices @ 46
+ PSReturnUserObjIndices @ 47
+ DPSReturnUserObjIndices @ 48
+ _DPSSSetContextParameters @ 49
+ _DPSSSetContextDrawable @ 50
+ _DPSSInstallDPSlibDict @ 51
+ _DPSSCaptureGState @ 52
+ _DPSSUpdateGState @ 53
+ _DPSSRestoreGState @ 54
+ _DPSSDefineUserObject @ 55
+ _DPSSUndefineUserObject @ 56
+ PSDoUserPath @ 57
+ DPSDoUserPath @ 58
+ PSHitUserPath @ 59
+ DPSHitUserPath @ 60
+
diff --git a/xc/lib/dpstk/dpstkos2.rsp b/xc/lib/dpstk/dpstkos2.rsp
new file mode 100644
index 000000000..4cf7bb26f
--- /dev/null
+++ b/xc/lib/dpstk/dpstkos2.rsp
@@ -0,0 +1,4 @@
+XDPSpreview.obj XDPSpwraps.obj XDPSshare.obj XDPSswraps.obj+
+XDPSuserpath.obj /NOI /NOL /NOD /BAT
+dpstk.dll
+dpstk.map
diff --git a/xc/lib/psres/psresos2.def b/xc/lib/psres/psresos2.def
new file mode 100644
index 000000000..27cbda37b
--- /dev/null
+++ b/xc/lib/psres/psresos2.def
@@ -0,0 +1,29 @@
+LIBRARY psres
+DESCRIPTION "@#XFREE86:4.0#@ $XFree86: xc/lib/psres/psresos2.def,v 1.1 2000/04/05 18:13:25 dawes Exp $"
+CODE
+ PRELOAD
+DATA
+ MULTIPLE NONSHARED
+STACKSIZE 32768
+EXPORTS
+ CheckPSResourceTime @ 1
+ EnumeratePSResourceFiles @ 2
+ FreePSResourceStorage @ 3
+ InSavedList @ 4
+ ListPSResourceFiles @ 5
+ ListPSResourceTypes @ 6
+ PSResEncoding @ 7
+ PSResFileWarningHandler @ 8
+ PSResFontAFM @ 9
+ PSResFontBDF @ 10
+ PSResFontBDFSizes @ 11
+ PSResFontFamily @ 12
+ PSResFontOutline @ 13
+ PSResFontPrebuilt @ 14
+ PSResForm @ 15
+ PSResFree @ 16
+ PSResMalloc @ 17
+ PSResPattern @ 18
+ PSResProcSet @ 19
+ PSResRealloc @ 20
+ SetPSResourcePolicy @ 21
diff --git a/xc/lib/psres/psresos2.rsp b/xc/lib/psres/psresos2.rsp
new file mode 100644
index 000000000..58480af0f
--- /dev/null
+++ b/xc/lib/psres/psresos2.rsp
@@ -0,0 +1,3 @@
+PSres.obj /NOI /NOL /NOD /BAT
+psres.dll
+psres.map