Daniel Borca's new DOS/DJGPP driver.
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 12 Feb 2002 03:24:56 +0000 (03:24 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 12 Feb 2002 03:24:56 +0000 (03:24 +0000)
docs/README.DJ [new file with mode: 0644]
include/GL/dmesa.h [new file with mode: 0644]
src/glu/mesa/Makefile.DJ [new file with mode: 0644]
src/mesa/drivers/dos/dmesa.c [new file with mode: 0644]
src/mesa/drivers/dos/dmesaint.h [new file with mode: 0644]
src/mesa/drivers/dos/dvesa.c [new file with mode: 0644]
src/mesa/drivers/dos/dvesa.h [new file with mode: 0644]
src/mesa/main/Makefile.DJ [new file with mode: 0644]

diff --git a/docs/README.DJ b/docs/README.DJ
new file mode 100644 (file)
index 0000000..c4a274c
--- /dev/null
@@ -0,0 +1,130 @@
+                   Mesa 4.0.1 DOS/DJGPP Port version 0.1\r
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+\r
+\r
+First of all...\r
+~~~~~~~~~~~~~~~\r
+\r
+This is a DOS port for MESA 4.0.1. I didn't bother to consider any DOS C\r
+compiler other than gcc, so this port was written using DJGPP v2. To be more\r
+precise:\r
+       djdev 2.03\r
+       gcc v3.0.3\r
+       make v3.79\r
+\r
+Almost all demos were compiled and ran succesfully on my system:\r
+       CPU:            Intel Pentium w/ MMX @166 MHz\r
+       Mainboard:      ViA Apollo VP2 w/ 128 MB SDRAM\r
+       Video card:     Matrox Millenium I w/ 4096 kB WRAM, Matrox BIOS v3.0\r
+\r
+Since I don't have access to any accelerated video hardware, this port is\r
+entirely based on VESA/SuperVGA. My little attempt to use FreeBE/AF ended in\r
+a failure, but that's another story: it seemed to work fine with my older\r
+Matrox Millenium w/ 2MB, and then I got another Matrox Millenium w/ 4MB. The\r
+problem with latter was it had a dead BIOS; I hot-flashed it and made it work\r
+in all environments (Windows 95, VESA, etc) but FreeBE/AF.\r
+\r
+\r
+\r
+Legal:\r
+~~~~~~\r
+\r
+This software is distributed under the terms of the GNU Lesser General Public\r
+License.\r
+\r
+Source code written by others is subject to its respective copyright.\r
+\r
+\r
+\r
+libGL (the core):\r
+~~~~~~~~~~~~~~~~~\r
+\r
+Of course, MESA 4.0.1 core sources are required. It will probably work with\r
+MESA 3.5, but not a chance with earlier versions due to major changes to the\r
+MESA driver interface and the directory tree. All should compile succesfully.\r
+\r
+The driver has its origins in ddsample.c, written by Brian Paul and found by\r
+me in MESA 3.4.2. I touched almost all the functions, changing the coding\r
+style ;-( Sorry!\r
+\r
+Pitfalls:\r
+1. The current version supports only RGB[A] modes, for it made no sense to me\r
+   to endorse color-index (aka palette) modes.\r
+2. Only double-buffered is allowed because it was simpler to implement at\r
+   that moment. Single-buffered will appear soon, especially if I can find a\r
+   way to use hardware acceleration.\r
+3. Another weird "feature" is that buffer width & height must be multiple of\r
+   4 (I'm a lazy programmer and I found that the easiest way to keep buffer\r
+   handling at peak performance ;-).\r
+4. The video mode selector is tricky: it searches for the smallest mode which\r
+   will entirely contain the buffer at its current position. If you want a\r
+   small buffer in a high-res mode, try to position it very far to the right\r
+   (or down). I'd really use some ideas here!!!\r
+\r
+\r
+\r
+libGLU:\r
+~~~~~~~\r
+\r
+Mesa GLU sources are required. Everything should run smooth.\r
+\r
+\r
+\r
+libGLUT (the toolkit):\r
+~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+Well, this "skeletal" GLUT implementation is not mine. Thanks should go to\r
+Bernhard Tschirren, Mark Kilgard, Brian Paul and probably others (or probably\r
+not ;-). I only changed it to be self-standing (Allegro-free). The keyboard,\r
+mouse and timer drivers were inspired from an old project of mine (D3Xl) and\r
+fixed with some Allegro "infusions"; my deeply thanks to Shawn Hargreaves and\r
+co.\r
+\r
+My keyboard driver used only scancodes, but since GLUT requires ASCII values\r
+for keys, I borrowed the translation tables (and maybe more) from Allegro.\r
+Ctrl-Alt-Del (plus Ctrl-Alt-End, for Windows users) will shut down the GLUT\r
+engine unconditionally: it will raise SIGINT, which in turn will call the\r
+destructors (let's hope), thus cleaning up your/my mess ;-)\r
+\r
+The mouse driver is far from complete (lack of positioning, drawing, etc),\r
+but is enough to make almost all the demos work.\r
+\r
+The timer is pretty versatile for it supports multiple timers with different\r
+frequencies. It may not be the most accurate timer in the known universe, but\r
+I think it's OK. Take this example: you have timer A with a very high rate,\r
+and then you have timer B with very low rate compared to A; now, A ticks OK,\r
+but timer B will probably loose precision!\r
+\r
+As an addition, stdout and stderr are redirected and dumped upon exit. This\r
+means that printf can be safely called during graphics, but all messages come\r
+in bulk! A bit of a hack, I know, but I think it's better than to miss them\r
+at all.\r
+\r
+Window creating defaults: 640x480x16 at (0,0), 8-bit stencil, 16-bit accum.\r
+\r
+\r
+\r
+Installation:\r
+~~~~~~~~~~~~~\r
+\r
+Unzip into the MESA directory, and type "make -f Makefile.DJ" to compile all\r
+libraries. Long filename support is required during compilation. The examples\r
+are not built automagically (see Pitfalls above).\r
+\r
+\r
+\r
+History:\r
+~~~~~~~~\r
+\r
+v0.1   feb-2002        initial release\r
+v0.2   ..soon..\r
+\r
+\r
+\r
+Contact:\r
+~~~~~~~~\r
+\r
+Name:   Borca Daniel\r
+E-mail: dborca@yahoo.com\r
+WWW:    http://www.geocities.com/dborca/\r
diff --git a/include/GL/dmesa.h b/include/GL/dmesa.h
new file mode 100644 (file)
index 0000000..bd5a34c
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  4.0\r
+ * \r
+ * Copyright (C) 1999  Brian Paul   All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v0.1 for Mesa 4.0\r
+ *\r
+ *  Copyright (C) 2002 - Borca Daniel\r
+ *  Email : dborca@yahoo.com\r
+ *  Web   : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#ifndef DMESA_included\r
+#define DMESA_included\r
+\r
+#define DMESA_MAJOR_VERSION 4\r
+#define DMESA_MINOR_VERSION 0\r
+\r
+typedef struct dmesa_context *DMesaContext;\r
+typedef struct dmesa_visual *DMesaVisual;\r
+typedef struct dmesa_buffer *DMesaBuffer;\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+DMesaVisual DMesaCreateVisual (GLint colDepth, GLboolean dbFlag,\r
+                               GLint depthSize, GLint stencilSize,\r
+                               GLint accumSize);\r
+\r
+void DMesaDestroyVisual (DMesaVisual v);\r
+\r
+DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,\r
+                               GLint width, GLint height,\r
+                               GLint xpos, GLint ypos);\r
+\r
+void DMesaDestroyBuffer (DMesaBuffer b);\r
+\r
+DMesaContext DMesaCreateContext (DMesaVisual visual,\r
+                                 DMesaContext share);\r
+\r
+void DMesaDestroyContext (DMesaContext c);\r
+\r
+GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b);\r
+\r
+void DMesaSwapBuffers (DMesaBuffer b);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r
diff --git a/src/glu/mesa/Makefile.DJ b/src/glu/mesa/Makefile.DJ
new file mode 100644 (file)
index 0000000..e097806
--- /dev/null
@@ -0,0 +1,69 @@
+# Mesa 3-D graphics library\r
+# Version:  4.0\r
+# \r
+# Copyright (C) 1999  Brian Paul   All Rights Reserved.\r
+# \r
+# Permission is hereby granted, free of charge, to any person obtaining a\r
+# copy of this software and associated documentation files (the "Software"),\r
+# to deal in the Software without restriction, including without limitation\r
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+# and/or sell copies of the Software, and to permit persons to whom the\r
+# Software is furnished to do so, subject to the following conditions:\r
+# \r
+# The above copyright notice and this permission notice shall be included\r
+# in all copies or substantial portions of the Software.\r
+# \r
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+\r
+# DOS/DJGPP glu makefile v0.1 for Mesa 4.0\r
+#\r
+#  Copyright (C) 2002 - Borca Daniel\r
+#  Email : dborca@yahoo.com\r
+#  Web   : http://www.geocities.com/dborca\r
+\r
+\r
+.PHONY: all clean\r
+\r
+TOP = ..\r
+CC = gcc\r
+CFLAGS = -I$(TOP)/include -Wall -W -Wno-unused -mcpu=pentium -ffast-math -O2\r
+AR = ar\r
+ARFLAGS = ruv\r
+LIBDIR = $(TOP)/lib\r
+\r
+GLU_LIB = libglu.a\r
+\r
+CORE_SOURCES = \\r
+       glu.c \\r
+       mipmap.c \\r
+       nurbs.c \\r
+       nurbscrv.c \\r
+       nurbssrf.c \\r
+       nurbsutl.c \\r
+       polytest.c \\r
+       project.c \\r
+       quadric.c \\r
+       tess.c \\r
+       tesselat.c\r
+\r
+SOURCES = $(CORE_SOURCES)\r
+\r
+OBJECTS = $(SOURCES:.c=.o)\r
+\r
+.c.o:\r
+       gcc -o $@ -c $(CFLAGS) $<\r
+\r
+all: $(LIBDIR)/$(GLU_LIB)\r
+\r
+$(LIBDIR)/$(GLU_LIB): $(OBJECTS)\r
+       $(AR) $(ARFLAGS) $(LIBDIR)/$(GLU_LIB) $(OBJECTS)\r
+\r
+clean:\r
+       -$(RM) *.o\r
+\r
+include depend\r
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
new file mode 100644 (file)
index 0000000..01be301
--- /dev/null
@@ -0,0 +1,592 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  4.0\r
+ * \r
+ * Copyright (C) 1999  Brian Paul   All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v0.1 for Mesa 4.0\r
+ *\r
+ *  Copyright (C) 2002 - Borca Daniel\r
+ *  Email : dborca@yahoo.com\r
+ *  Web   : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#ifdef PC_HEADER\r
+#include "all.h"\r
+#else\r
+#include "glheader.h"\r
+#include "context.h"\r
+#include "GL/dmesa.h"\r
+#include "matrix.h"\r
+#include "texformat.h"\r
+#include "texstore.h"\r
+#include "array_cache/acache.h"\r
+#include "swrast/swrast.h"\r
+#include "swrast_setup/swrast_setup.h"\r
+#include "tnl/tnl.h"\r
+#include "tnl/t_context.h"\r
+#include "tnl/t_pipeline.h"\r
+#endif\r
+\r
+#include "dvesa.h"\r
+#include "dmesaint.h"\r
+\r
+\r
+\r
+/*\r
+ * In C++ terms, this class derives from the GLvisual class.\r
+ * Add system-specific fields to it.\r
+ */\r
+struct dmesa_visual {\r
+   GLvisual *gl_visual;\r
+   GLboolean db_flag;           /* double buffered? */\r
+   GLboolean rgb_flag;          /* RGB mode? */\r
+   GLuint depth;                /* bits per pixel (1, 8, 24, etc) */\r
+};\r
+\r
+/*\r
+ * In C++ terms, this class derives from the GLframebuffer class.\r
+ * Add system-specific fields to it.\r
+ */\r
+struct dmesa_buffer {\r
+   GLframebuffer *gl_buffer;    /* The depth, stencil, accum, etc buffers */\r
+   void *the_window;            /* your window handle, etc */\r
+\r
+   int width, height;           /* size in pixels */\r
+   int xpos, ypos;              /* buffer position */\r
+   int xsize, len;              /* number of bytes in a line, then total */\r
+   int delta;                   /* used to wrap around */\r
+   int offset;                  /* offset in video */\r
+   struct dvmode *video;\r
+};\r
+\r
+/*\r
+ * In C++ terms, this class derives from the GLcontext class.\r
+ * Add system-specific fields to it.\r
+ */\r
+struct dmesa_context {\r
+   GLcontext *gl_ctx;           /* the core library context */\r
+   DMesaVisual visual;\r
+   DMesaBuffer Buffer;\r
+   GLuint ClearColor;\r
+   /* etc... */\r
+};\r
+\r
+\r
+\r
+static void dmesa_update_state (GLcontext *ctx, GLuint new_state);\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/*****            Read/Write pixels                               *****/\r
+/**********************************************************************/\r
+\r
+\r
+\r
+WRITE_RGBA_SPAN(15)\r
+WRITE_RGBA_SPAN(16)\r
+WRITE_RGBA_SPAN(24)\r
+WRITE_RGBA_SPAN(32)\r
+\r
+WRITE_RGB_SPAN(15)\r
+WRITE_RGB_SPAN(16)\r
+WRITE_RGB_SPAN(24)\r
+WRITE_RGB_SPAN(32)\r
+\r
+WRITE_MONO_RGBA_SPAN(15)\r
+WRITE_MONO_RGBA_SPAN(16)\r
+WRITE_MONO_RGBA_SPAN(24)\r
+WRITE_MONO_RGBA_SPAN(32)\r
+\r
+READ_RGBA_SPAN(15)\r
+READ_RGBA_SPAN(16)\r
+READ_RGBA_SPAN(24)\r
+READ_RGBA_SPAN(32)\r
+\r
+WRITE_RGBA_PIXELS(15)\r
+WRITE_RGBA_PIXELS(16)\r
+WRITE_RGBA_PIXELS(24)\r
+WRITE_RGBA_PIXELS(32)\r
+\r
+WRITE_MONO_RGBA_PIXELS(15)\r
+WRITE_MONO_RGBA_PIXELS(16)\r
+WRITE_MONO_RGBA_PIXELS(24)\r
+WRITE_MONO_RGBA_PIXELS(32)\r
+\r
+READ_RGBA_PIXELS(15)\r
+READ_RGBA_PIXELS(16)\r
+READ_RGBA_PIXELS(24)\r
+READ_RGBA_PIXELS(32)\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/*****              Miscellaneous device driver funcs             *****/\r
+/**********************************************************************/\r
+\r
+\r
+\r
+static void clear_color (GLcontext *ctx, const GLchan color[4])\r
+{\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+ c->ClearColor = dv_color(color);\r
+}\r
+\r
+\r
+\r
+static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,\r
+                   GLint x, GLint y, GLint width, GLint height)\r
+{\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+ const GLuint *colorMask = (GLuint *)&ctx->Color.ColorMask;\r
+ DMesaBuffer b = c->Buffer;\r
+\r
+/*\r
+ * Clear the specified region of the buffers indicated by 'mask'\r
+ * using the clear color or index as specified by one of the two\r
+ * functions above.\r
+ * If all==GL_TRUE, clear whole buffer, else just clear region defined\r
+ * by x,y,width,height\r
+ */\r
+\r
+ /* we can't handle color or index masking */\r
+ if (*colorMask==0xffffffff && ctx->Color.IndexMask==0xffffffff) {\r
+    if (mask&DD_BACK_LEFT_BIT) {\r
+       if (all) {\r
+          dv_clear_virtual(b->the_window, b->len, c->ClearColor);\r
+       } else {\r
+          dv_fillrect(b->the_window, b->width, x, y, width, height, c->ClearColor);\r
+       }\r
+       mask &= ~DD_BACK_LEFT_BIT;\r
+    }\r
+ }\r
+\r
+ if (mask) {\r
+    _swrast_Clear(ctx, mask, all, x, y, width, height);\r
+ }\r
+}\r
+\r
+\r
+\r
+/*\r
+ * Set the current reading buffer.\r
+ */\r
+static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer,\r
+                             GLenum mode)\r
+{\r
+/*\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+ dmesa_update_state(ctx);\r
+*/\r
+}\r
+\r
+\r
+\r
+/*\r
+ * Set the destination/draw buffer.\r
+ */\r
+static GLboolean set_draw_buffer (GLcontext *ctx, GLenum mode)\r
+{\r
+ if (mode==GL_BACK_LEFT) {\r
+    return GL_TRUE;\r
+ } else {\r
+    return GL_FALSE;\r
+ }\r
+}\r
+\r
+\r
+\r
+/*\r
+ * Return the width and height of the current buffer.\r
+ * If anything special has to been done when the buffer/window is\r
+ * resized, do it now.\r
+ */\r
+static void get_buffer_size (GLcontext *ctx, GLuint *width, GLuint *height)\r
+{\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+\r
+ *width  = c->Buffer->width;\r
+ *height = c->Buffer->height;\r
+}\r
+\r
+\r
+\r
+static const GLubyte* get_string (GLcontext *ctx, GLenum name)\r
+{\r
+ switch (name) {\r
+        case GL_RENDERER:\r
+             return (const GLubyte *)"DOS Mesa";\r
+        default:\r
+             return NULL;\r
+ }\r
+}\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/*****              Miscellaneous device driver funcs             *****/\r
+/*****           Note that these functions are mandatory          *****/\r
+/**********************************************************************/\r
+\r
+\r
+\r
+/* OPTIONAL FUNCTION: implements glFinish if possible */\r
+static void finish (GLcontext *ctx)\r
+{\r
+/*\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+*/\r
+}\r
+\r
+\r
+\r
+/* OPTIONAL FUNCTION: implements glFlush if possible */\r
+static void flush (GLcontext *ctx)\r
+{\r
+/*\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+*/\r
+}\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/**********************************************************************/\r
+\r
+\r
+\r
+/* Setup pointers and other driver state that is constant for the life\r
+ * of a context.\r
+ */\r
+void dmesa_init_pointers (GLcontext *ctx)\r
+{\r
+ TNLcontext *tnl;\r
+\r
+ ctx->Driver.UpdateState = dmesa_update_state;\r
+\r
+ ctx->Driver.GetString = get_string;\r
+ ctx->Driver.GetBufferSize = get_buffer_size;\r
+ ctx->Driver.Flush = flush;\r
+ ctx->Driver.Finish = finish;\r
+    \r
+ /* Software rasterizer pixel paths:\r
+  */\r
+ ctx->Driver.Accum = _swrast_Accum;\r
+ ctx->Driver.Bitmap = _swrast_Bitmap;\r
+ ctx->Driver.Clear = clear;\r
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;\r
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;\r
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;\r
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;\r
+\r
+ /* Software texture functions:\r
+  */\r
+ ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;\r
+ ctx->Driver.TexImage1D = _mesa_store_teximage1d;\r
+ ctx->Driver.TexImage2D = _mesa_store_teximage2d;\r
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;\r
+ ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;\r
+ ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;\r
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;\r
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;\r
+\r
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;\r
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;\r
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;\r
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;\r
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;\r
+\r
+ ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;\r
+ ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;\r
+ ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;\r
+\r
+ /* Swrast hooks for imaging extensions:\r
+  */\r
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;\r
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;\r
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;\r
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;\r
+\r
+ /* Statechange callbacks:\r
+  */\r
+ ctx->Driver.SetDrawBuffer = set_draw_buffer;\r
+ ctx->Driver.ClearColor = clear_color;\r
+\r
+ /* Initialize the TNL driver interface:\r
+  */\r
+ tnl = TNL_CONTEXT(ctx);\r
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;\r
+   \r
+ /* Install swsetup for tnl->Driver.Render.*:\r
+  */\r
+ _swsetup_Wakeup(ctx);\r
+}\r
+\r
+\r
+\r
+static void dmesa_update_state (GLcontext *ctx, GLuint new_state)\r
+{\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);\r
+\r
+ /* Initialize all the pointers in the DD struct.  Do this whenever */\r
+ /* a new context is made current or we change buffers via set_buffer! */\r
+\r
+ _swrast_InvalidateState(ctx, new_state);\r
+ _swsetup_InvalidateState(ctx, new_state);\r
+ _ac_InvalidateState(ctx, new_state);\r
+ _tnl_InvalidateState(ctx, new_state);\r
+\r
+ swdd->SetReadBuffer = set_read_buffer;\r
+\r
+ /* RGB(A) span/pixel functions */\r
+ switch (c->visual->depth) {\r
+        case 15:\r
+             swdd->WriteRGBASpan = write_rgba_span_15;\r
+             swdd->WriteRGBSpan = write_rgb_span_15;\r
+             swdd->WriteMonoRGBASpan = write_mono_rgba_span_15;\r
+             swdd->WriteRGBAPixels = write_rgba_pixels_15;\r
+             swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_15;\r
+             swdd->ReadRGBASpan = read_rgba_span_15;\r
+             swdd->ReadRGBAPixels = read_rgba_pixels_15;\r
+             break;\r
+        case 16:\r
+             swdd->WriteRGBASpan = write_rgba_span_16;\r
+             swdd->WriteRGBSpan = write_rgb_span_16;\r
+             swdd->WriteMonoRGBASpan = write_mono_rgba_span_16;\r
+             swdd->WriteRGBAPixels = write_rgba_pixels_16;\r
+             swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_16;\r
+             swdd->ReadRGBASpan = read_rgba_span_16;\r
+             swdd->ReadRGBAPixels = read_rgba_pixels_16;\r
+             break;\r
+        case 24:\r
+             swdd->WriteRGBASpan = write_rgba_span_24;\r
+             swdd->WriteRGBSpan = write_rgb_span_24;\r
+             swdd->WriteMonoRGBASpan = write_mono_rgba_span_24;\r
+             swdd->WriteRGBAPixels = write_rgba_pixels_24;\r
+             swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_24;\r
+             swdd->ReadRGBASpan = read_rgba_span_24;\r
+             swdd->ReadRGBAPixels = read_rgba_pixels_24;\r
+             break;\r
+        case 32:\r
+             swdd->WriteRGBASpan = write_rgba_span_32;\r
+             swdd->WriteRGBSpan = write_rgb_span_32;\r
+             swdd->WriteMonoRGBASpan = write_mono_rgba_span_32;\r
+             swdd->WriteRGBAPixels = write_rgba_pixels_32;\r
+             swdd->WriteMonoRGBAPixels = write_mono_rgba_pixels_32;\r
+             swdd->ReadRGBASpan = read_rgba_span_32;\r
+             swdd->ReadRGBAPixels = read_rgba_pixels_32;\r
+             break;\r
+ }\r
+}\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/*****               DMesa Public API Functions                   *****/\r
+/**********************************************************************/\r
+\r
+\r
+\r
+/*\r
+ * The exact arguments to this function will depend on your window system\r
+ */\r
+DMesaVisual DMesaCreateVisual (GLint colDepth, GLboolean dbFlag,\r
+                               GLint depthSize, GLint stencilSize,\r
+                               GLint accumSize)\r
+{\r
+ DMesaVisual v;\r
+ GLint redBits, greenBits, blueBits, alphaBits;\r
+\r
+ if (!dbFlag) {\r
+    return NULL;\r
+ }\r
+ switch (colDepth) {\r
+        case 15:\r
+             redBits = 5;\r
+             greenBits = 5;\r
+             blueBits = 5;\r
+             break;\r
+        case 16:\r
+             redBits = 5;\r
+             greenBits = 6;\r
+             blueBits = 5;\r
+             break;\r
+        case 24:\r
+        case 32:\r
+             redBits = 8;\r
+             greenBits = 8;\r
+             blueBits = 8;\r
+             break;\r
+        default:\r
+             return NULL;\r
+ }\r
+ alphaBits = 8;\r
+\r
+ if ((v=(DMesaVisual)calloc(1, sizeof(struct dmesa_visual)))!=NULL) {\r
+    /* Create core visual */\r
+    v->gl_visual = _mesa_create_visual(colDepth>8,             /* rgb */\r
+                                       dbFlag,\r
+                                       GL_FALSE,               /* stereo */\r
+                                       redBits,\r
+                                       greenBits,\r
+                                       blueBits,\r
+                                       alphaBits,\r
+                                       0,                      /* indexBits */\r
+                                       depthSize,\r
+                                       stencilSize,\r
+                                       accumSize,              /* accumRed */\r
+                                       accumSize,              /* accumGreen */\r
+                                       accumSize,              /* accumBlue */\r
+                                       alphaBits?accumSize:0,  /* accumAlpha */\r
+                                       1);                     /* numSamples */\r
+\r
+    v->depth = colDepth;\r
+    v->db_flag = dbFlag;\r
+ }\r
+\r
+ return v;\r
+}\r
+\r
+\r
+\r
+void DMesaDestroyVisual (DMesaVisual v)\r
+{\r
+ _mesa_destroy_visual(v->gl_visual);\r
+ free(v);\r
+}\r
+\r
+\r
+\r
+DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,\r
+                               GLint width, GLint height,\r
+                               GLint xpos, GLint ypos)\r
+{\r
+ DMesaBuffer b;\r
+\r
+ if ((b=(DMesaBuffer)calloc(1, sizeof(struct dmesa_buffer)))!=NULL) {\r
+    if (visual->db_flag) {\r
+       if ((b->the_window=calloc(1, width*height*((visual->depth+7)/8)))==NULL) {\r
+          return NULL;\r
+       }\r
+    }\r
+\r
+    b->gl_buffer = _mesa_create_framebuffer(visual->gl_visual,\r
+                                            visual->gl_visual->depthBits > 0,\r
+                                            visual->gl_visual->stencilBits > 0,\r
+                                            visual->gl_visual->accumRedBits > 0,\r
+                                            visual->gl_visual->alphaBits > 0);\r
+    b->width = width;\r
+    b->height = height;\r
+    b->xpos = xpos;\r
+    b->ypos = ypos;\r
+ }\r
+\r
+ return b;\r
+}\r
+\r
+\r
+\r
+void DMesaDestroyBuffer (DMesaBuffer b)\r
+{\r
+ free(b->the_window);\r
+ _mesa_destroy_framebuffer(b->gl_buffer);\r
+ free(b);\r
+}\r
+\r
+\r
+\r
+DMesaContext DMesaCreateContext (DMesaVisual visual,\r
+                                 DMesaContext share)\r
+{\r
+ DMesaContext c;\r
+ GLboolean direct = GL_FALSE;\r
+\r
+ if ((c=(DMesaContext)calloc(1, sizeof(struct dmesa_context)))!=NULL) {\r
+    c->gl_ctx = _mesa_create_context(visual->gl_visual,\r
+                                     share ? share->gl_ctx : NULL,\r
+                                     (void *)c, direct);\r
+\r
+   /* you probably have to do a bunch of other initializations here. */\r
+    c->visual = visual;\r
+\r
+   /* Initialize the software rasterizer and helper modules.\r
+    */\r
+    _swrast_CreateContext(c->gl_ctx);\r
+    _ac_CreateContext(c->gl_ctx);\r
+    _tnl_CreateContext(c->gl_ctx);\r
+    _swsetup_CreateContext(c->gl_ctx);\r
+    dmesa_init_pointers(c->gl_ctx);\r
+ }\r
+\r
+ return c;\r
+}\r
+\r
+\r
+\r
+void DMesaDestroyContext (DMesaContext c)\r
+{\r
+ _mesa_destroy_context(c->gl_ctx);\r
+ free(c);\r
+}\r
+\r
+\r
+\r
+/*\r
+ * Make the specified context and buffer the current one.\r
+ */\r
+GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)\r
+{\r
+ if (c&&b) {\r
+    c->Buffer = b;\r
+    if ((b->video=dv_select_mode(b->xpos, b->ypos, b->width, b->height, c->visual->depth, &b->delta, &b->offset))==NULL) {\r
+       return GL_FALSE;\r
+    }\r
+\r
+    b->xsize = b->width*((c->visual->depth+7)/8);\r
+    b->len = b->xsize*b->height;\r
+\r
+    dmesa_update_state(c->gl_ctx, 0);\r
+    _mesa_make_current(c->gl_ctx, b->gl_buffer);\r
+    if (c->gl_ctx->Viewport.Width==0) {\r
+       /* initialize viewport to window size */\r
+       _mesa_Viewport(0, 0, c->Buffer->width, c->Buffer->height);\r
+    }\r
+ } else {\r
+    /* Detach */\r
+    _mesa_make_current(NULL, NULL);\r
+ }\r
+\r
+ return GL_TRUE;\r
+}\r
+\r
+\r
+\r
+void DMesaSwapBuffers (DMesaBuffer b)\r
+{\r
+ /* copy/swap back buffer to front if applicable */\r
+ if (b->the_window) {\r
+    dv_dump_virtual(b->the_window, b->xsize, b->height, b->offset, b->delta);\r
+ }\r
+}\r
diff --git a/src/mesa/drivers/dos/dmesaint.h b/src/mesa/drivers/dos/dmesaint.h
new file mode 100644 (file)
index 0000000..b8aa706
--- /dev/null
@@ -0,0 +1,231 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  4.0\r
+ * \r
+ * Copyright (C) 1999  Brian Paul   All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v0.1 for Mesa 4.0\r
+ *\r
+ *  Copyright (C) 2002 - Borca Daniel\r
+ *  Email : dborca@yahoo.com\r
+ *  Web   : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#ifndef DMESAINT_H_included\r
+#define DMESAINT_H_included\r
+\r
+\r
+\r
+#define FLIP(y)  (c->Buffer->height - (y) - 1)\r
+#define FLIP2(y) (h - (y) - 1)\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/*****            Write spans of pixels                           *****/\r
+/**********************************************************************/\r
+#define WRITE_RGBA_SPAN(bpp) \\r
+static void write_rgba_span_##bpp (const GLcontext *ctx, GLuint n, GLint x, GLint y, \\r
+                                   const GLubyte rgba[][4], const GLubyte mask[])    \\r
+{                                                                                    \\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;                                      \\r
+ void *b = c->Buffer->the_window;                                                    \\r
+ GLuint i, offset;                                                                   \\r
+                                                                                     \\r
+ offset = c->Buffer->width * FLIP(y) + x;                                            \\r
+ if (mask) {                                                                         \\r
+    /* draw some pixels */                                                           \\r
+    for (i=0; i<n; i++, offset++) {                                                  \\r
+        if (mask[i]) {                                                               \\r
+           dv_putpixel##bpp(b, offset, dv_color##bpp(rgba[i]));                      \\r
+        }                                                                            \\r
+    }                                                                                \\r
+ } else {                                                                            \\r
+    /* draw all pixels */                                                            \\r
+    for (i=0; i<n; i++, offset++) {                                                  \\r
+        dv_putpixel##bpp(b, offset, dv_color##bpp(rgba[i]));                         \\r
+    }                                                                                \\r
+ }                                                                                   \\r
+}\r
+\r
+\r
+\r
+#define WRITE_RGB_SPAN(bpp) \\r
+static void write_rgb_span_##bpp (const GLcontext *ctx, GLuint n, GLint x, GLint y, \\r
+                                  const GLubyte rgb[][3], const GLubyte mask[])     \\r
+{                                                                                   \\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;                                     \\r
+ void *b = c->Buffer->the_window;                                                   \\r
+ GLuint i, offset;                                                                  \\r
+                                                                                    \\r
+ offset = c->Buffer->width * FLIP(y) + x;                                           \\r
+ if (mask) {                                                                        \\r
+    /* draw some pixels */                                                          \\r
+    for (i=0; i<n; i++, offset++) {                                                 \\r
+        if (mask[i]) {                                                              \\r
+           dv_putpixel##bpp(b, offset, dv_color##bpp(rgb[i]));                      \\r
+        }                                                                           \\r
+    }                                                                               \\r
+ } else {                                                                           \\r
+    /* draw all pixels */                                                           \\r
+    for (i=0; i<n; i++, offset++) {                                                 \\r
+        dv_putpixel##bpp(b, offset, dv_color##bpp(rgb[i]));                         \\r
+    }                                                                               \\r
+ }                                                                                  \\r
+}\r
+\r
+\r
+\r
+#define WRITE_MONO_RGBA_SPAN(bpp) \\r
+static void write_mono_rgba_span_##bpp (const GLcontext *ctx,                        \\r
+                                        GLuint n, GLint x, GLint y,                  \\r
+                                        const GLchan color[4], const GLubyte mask[]) \\r
+{                                                                                    \\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;                                      \\r
+ void *b = c->Buffer->the_window;                                                    \\r
+ GLuint i, offset, rgba = dv_color##bpp(color);                                      \\r
+                                                                                     \\r
+ offset = c->Buffer->width * FLIP(y) + x;                                            \\r
+ if (mask) {                                                                         \\r
+    /* draw some pixels */                                                           \\r
+    for (i=0; i<n; i++, offset++) {                                                  \\r
+        if (mask[i]) {                                                               \\r
+           dv_putpixel##bpp(b, offset, rgba);                                        \\r
+        }                                                                            \\r
+    }                                                                                \\r
+ } else {                                                                            \\r
+    /* draw all pixels */                                                            \\r
+    for (i=0; i<n; i++, offset++) {                                                  \\r
+        dv_putpixel##bpp(b, offset, rgba);                                           \\r
+    }                                                                                \\r
+ }                                                                                   \\r
+}\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/*****                 Read spans of pixels                       *****/\r
+/**********************************************************************/\r
+#define READ_RGBA_SPAN(bpp) \\r
+static void read_rgba_span_##bpp (const GLcontext *ctx, GLuint n, GLint x, GLint y, \\r
+                                  GLubyte rgba[][4])                                \\r
+{                                                                                   \\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;                                     \\r
+ void *b = c->Buffer->the_window;                                                   \\r
+ GLuint i, offset;                                                                  \\r
+                                                                                    \\r
+ offset = c->Buffer->width * FLIP(y) + x;                                           \\r
+ /* read all pixels */                                                              \\r
+ for (i=0; i<n; i++, offset++) {                                                    \\r
+     dv_getrgba##bpp(b, offset, rgba[i]);                                           \\r
+ }                                                                                  \\r
+}\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/*****              Write arrays of pixels                        *****/\r
+/**********************************************************************/\r
+#define WRITE_RGBA_PIXELS(bpp) \\r
+static void write_rgba_pixels_##bpp (const GLcontext *ctx,                          \\r
+                                     GLuint n, const GLint x[], const GLint y[],    \\r
+                                     const GLubyte rgba[][4], const GLubyte mask[]) \\r
+{                                                                                   \\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;                                     \\r
+ void *b = c->Buffer->the_window;                                                   \\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height;                             \\r
+                                                                                    \\r
+ if (mask) {                                                                        \\r
+    /* draw some pixels */                                                          \\r
+    for (i=0; i<n; i++) {                                                           \\r
+        if (mask[i]) {                                                              \\r
+           dv_putpixel##bpp(b, FLIP2(y[i])*w + x[i], dv_color##bpp(rgba[i]));       \\r
+        }                                                                           \\r
+    }                                                                               \\r
+ } else {                                                                           \\r
+    /* draw all pixels */                                                           \\r
+    for (i=0; i<n; i++) {                                                           \\r
+        dv_putpixel##bpp(b, FLIP2(y[i])*w + x[i], dv_color##bpp(rgba[i]));          \\r
+    }                                                                               \\r
+ }                                                                                  \\r
+}\r
+\r
+\r
+\r
+#define WRITE_MONO_RGBA_PIXELS(bpp) \\r
+static void write_mono_rgba_pixels_##bpp (const GLcontext *ctx,                        \\r
+                                          GLuint n, const GLint x[], const GLint y[],  \\r
+                                          const GLchan color[4], const GLubyte mask[]) \\r
+{                                                                                      \\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;                                        \\r
+ void *b = c->Buffer->the_window;                                                      \\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height, rgba = dv_color##bpp(color);   \\r
+                                                                                       \\r
+ if (mask) {                                                                           \\r
+    /* draw some pixels */                                                             \\r
+    for (i=0; i<n; i++) {                                                              \\r
+        if (mask[i]) {                                                                 \\r
+           dv_putpixel##bpp(b, FLIP2(y[i])*w + x[i], rgba);                            \\r
+        }                                                                              \\r
+    }                                                                                  \\r
+ } else {                                                                              \\r
+    /* draw all pixels */                                                              \\r
+    for (i=0; i<n; i++) {                                                              \\r
+        dv_putpixel##bpp(b, FLIP2(y[i])*w + x[i], rgba);                               \\r
+    }                                                                                  \\r
+ }                                                                                     \\r
+}\r
+\r
+\r
+\r
+\r
+/**********************************************************************/\r
+/*****                   Read arrays of pixels                    *****/\r
+/**********************************************************************/\r
+#define READ_RGBA_PIXELS(bpp) \\r
+static void read_rgba_pixels_##bpp (const GLcontext *ctx,                       \\r
+                                    GLuint n, const GLint x[], const GLint y[], \\r
+                                    GLubyte rgba[][4], const GLubyte mask[])    \\r
+{                                                                               \\r
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;                                 \\r
+ void *b = c->Buffer->the_window;                                               \\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height;                         \\r
+                                                                                \\r
+ if (mask) {                                                                    \\r
+    /* read some pixels */                                                      \\r
+    for (i=0; i<n; i++) {                                                       \\r
+        if (mask[i]) {                                                          \\r
+           dv_getrgba##bpp(b, FLIP2(y[i])*w + x[i], rgba[i]);                   \\r
+        }                                                                       \\r
+    }                                                                           \\r
+ } else {                                                                       \\r
+    /* read all pixels */                                                       \\r
+    for (i=0; i<n; i++) {                                                       \\r
+        dv_getrgba##bpp(b, FLIP2(y[i])*w + x[i], rgba[i]);                      \\r
+    }                                                                           \\r
+ }                                                                              \\r
+}\r
+\r
+\r
+\r
+#endif\r
diff --git a/src/mesa/drivers/dos/dvesa.c b/src/mesa/drivers/dos/dvesa.c
new file mode 100644 (file)
index 0000000..27464e5
--- /dev/null
@@ -0,0 +1,549 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  4.0\r
+ * \r
+ * Copyright (C) 1999  Brian Paul   All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v0.1 for Mesa 4.0\r
+ *\r
+ *  Copyright (C) 2002 - Borca Daniel\r
+ *  Email : dborca@yahoo.com\r
+ *  Web   : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include <dpmi.h>\r
+#include <string.h>\r
+#include <stubinfo.h>\r
+#include <sys/exceptn.h>\r
+#include <sys/farptr.h>\r
+#include <sys/segments.h>\r
+\r
+#include "dvesa.h"\r
+\r
+\r
+\r
+typedef struct dvmode {\r
+       int mode;\r
+       int xres, yres;\r
+       int scanlen;\r
+       int bpp;\r
+       word32 opaque;\r
+} dvmode;\r
+\r
+#define _16_ *(word16 *)&\r
+#define _32_ *(word32 *)&\r
+\r
+static int init;\r
+static int selector = -1;\r
+static int granularity;\r
+static dvmode modes[128];\r
+static void (*dv_putpixel) (void *buffer, int offset, int color);\r
+int (*dv_color) (const unsigned char rgba[]);\r
+void (*dv_dump_virtual) (void *buffer, int width, int height, int offset, int delta);\r
+void (*dv_clear_virtual) (void *buffer, int len, int color);\r
+\r
+extern void dv_dump_virtual_linear (void *buffer, int width, int height, int offset, int delta);\r
+extern void dv_dump_virtual_banked (void *buffer, int width, int height, int offset, int delta);\r
+\r
+extern void dv_clear_virtual16 (void *buffer, int len, int color);\r
+extern void dv_clear_virtual24 (void *buffer, int len, int color);\r
+extern void dv_clear_virtual32 (void *buffer, int len, int color);\r
+\r
+/* lookup table for scaling 5 bit colors up to 8 bits */\r
+int _rgb_scale_5[32] =\r
+{\r
+   0,   8,   16,  24,  32,  41,  49,  57,\r
+   65,  74,  82,  90,  98,  106, 115, 123,\r
+   131, 139, 148, 156, 164, 172, 180, 189,\r
+   197, 205, 213, 222, 230, 238, 246, 255\r
+};\r
+\r
+/* lookup table for scaling 6 bit colors up to 8 bits */\r
+int _rgb_scale_6[64] =\r
+{\r
+   0,   4,   8,   12,  16,  20,  24,  28,\r
+   32,  36,  40,  44,  48,  52,  56,  60,\r
+   64,  68,  72,  76,  80,  85,  89,  93,\r
+   97,  101, 105, 109, 113, 117, 121, 125,\r
+   129, 133, 137, 141, 145, 149, 153, 157,\r
+   161, 165, 170, 174, 178, 182, 186, 190,\r
+   194, 198, 202, 206, 210, 214, 218, 222,\r
+   226, 230, 234, 238, 242, 246, 250, 255\r
+};\r
+\r
+\r
+\r
+/*\r
+ * colors\r
+ */\r
+int dv_color15 (const unsigned char rgba[])\r
+{\r
+ return ((rgba[0]>>3)<<10)|((rgba[1]>>3)<<5)|(rgba[2]>>3);\r
+}\r
+int dv_color16 (const unsigned char rgba[])\r
+{\r
+ return ((rgba[0]>>3)<<11)|((rgba[1]>>2)<<5)|(rgba[2]>>3);\r
+}\r
+int dv_color32 (const unsigned char rgba[])\r
+{\r
+ return (rgba[0]<<16)|(rgba[1]<<8)|(rgba[2]);\r
+}\r
+\r
+\r
+\r
+/*\r
+ * getpixel + decompose\r
+ */\r
+void dv_getrgba15 (void *buffer, int offset, unsigned char rgba[4])\r
+{\r
+ int c = ((word16 *)buffer)[offset];\r
+ rgba[0] = _rgb_scale_5[(c >> 10) & 0x1F];\r
+ rgba[1] = _rgb_scale_5[(c >> 5) & 0x1F];\r
+ rgba[2] = _rgb_scale_5[c & 0x1F];\r
+ rgba[3] = 255;\r
+}\r
+void dv_getrgba16 (void *buffer, int offset, unsigned char rgba[4])\r
+{\r
+ int c = ((word16 *)buffer)[offset];\r
+ rgba[0] = _rgb_scale_5[(c >> 11) & 0x1F];\r
+ rgba[1] = _rgb_scale_6[(c >> 5) & 0x3F];\r
+ rgba[2] = _rgb_scale_5[c & 0x1F];\r
+ rgba[3] = 255;\r
+}\r
+void dv_getrgba24 (void *buffer, int offset, unsigned char rgba[4])\r
+{\r
+ int c = *(word32 *)(buffer+offset*3);\r
+ rgba[0] = c >> 16;\r
+ rgba[1] = c >> 8;\r
+ rgba[2] = c;\r
+ rgba[3] = 255;\r
+}\r
+void dv_getrgba32 (void *buffer, int offset, unsigned char rgba[4])\r
+{\r
+ int c = ((word32 *)buffer)[offset];\r
+ rgba[0] = c >> 16;\r
+ rgba[1] = c >> 8;\r
+ rgba[2] = c; \r
+ rgba[3] = 255;\r
+}\r
+\r
+\r
+\r
+/*\r
+ * request mapping from DPMI\r
+ */\r
+static word32 _map_linear (word32 phys, word32 len)\r
+{\r
+ __dpmi_meminfo meminfo;\r
+\r
+ if (phys >= 0x100000) {\r
+    /* map into linear memory */\r
+    meminfo.address = (long)phys;\r
+    meminfo.size = len;\r
+    if (__dpmi_physical_address_mapping(&meminfo)) {\r
+       return 0;\r
+    }\r
+    return meminfo.address;\r
+ } else {\r
+    /* exploit 1 -> 1 physical to linear mapping in low megabyte */\r
+    return phys;\r
+ }\r
+}\r
+\r
+\r
+\r
+/*\r
+ * attempts to detect VESA and video modes\r
+ */\r
+static word16 dv_get_vesa (void)\r
+{\r
+ __dpmi_regs r;\r
+ unsigned short *p;\r
+ dvmode *q;\r
+ char vesa_info[512], tmp[512];\r
+\r
+ _farpokel(_stubinfo->ds_selector, 0, 0x32454256);\r
+ r.x.ax = 0x4f00;\r
+ r.x.di = 0;\r
+ r.x.es = _stubinfo->ds_segment;\r
+ __dpmi_int(0x10, &r);\r
+ if (r.x.ax==0x004f) {\r
+    movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512);\r
+    if ((_32_ vesa_info[0])==0x41534556) {\r
+       p = (unsigned short *)(((_16_ vesa_info[0x10])<<4) + (_16_ vesa_info[0x0e]));\r
+       q = modes;\r
+       do {\r
+          if ((q->mode=_farpeekw(__djgpp_dos_sel, (unsigned long)(p++)))==0xffff) {\r
+             break;\r
+          }\r
+\r
+          r.x.ax = 0x4f01;\r
+          r.x.cx = q->mode;\r
+          r.x.di = 512;\r
+          r.x.es = _stubinfo->ds_segment;\r
+          __dpmi_int(0x10, &r);\r
+          movedata(_stubinfo->ds_selector, 512, _my_ds(), (unsigned)tmp, 256);\r
+          switch (tmp[0x19]) {\r
+                 case 16:\r
+                      q->bpp = tmp[0x1f] + tmp[0x21] + tmp[0x23];\r
+                      break;\r
+                 case 15:\r
+                 case 24:\r
+                 case 32:\r
+                      q->bpp = tmp[0x19];\r
+                      break;\r
+                 default:\r
+                      q->bpp = 0;\r
+          }\r
+          if ((r.x.ax==0x004f)&&((tmp[0]&0x11)==0x11)&&q->bpp) {\r
+             q->xres = _16_ tmp[0x12];\r
+             q->yres = _16_ tmp[0x14];\r
+             q->scanlen = _16_ tmp[0x10];\r
+             q->opaque = (_16_ tmp[4])<<10;\r
+             if (tmp[0]&0x80) {\r
+                *(q+1) = *q++;\r
+                q->opaque = _32_ tmp[0x28];\r
+                q->mode |= 0x4000;\r
+             }\r
+             q++;\r
+          }\r
+       } while (!0);\r
+\r
+       return _16_ vesa_info[4];\r
+    }\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+\r
+\r
+/*\r
+ * select a mode\r
+ */\r
+dvmode *dv_select_mode (int x, int y, int width, int height, int depth, int *delta, int *offset)\r
+{\r
+ dvmode *p, *q;\r
+ unsigned int min;\r
+\r
+ if ((width&3)||(height&3)||(depth<=8)) {\r
+    return NULL;\r
+ }\r
+\r
+ if (!init) {\r
+    init = !init;\r
+    if (!dv_get_vesa()) {\r
+       return NULL;\r
+    }\r
+ }\r
+\r
+ for (min=-1, p=NULL, q=modes; q->mode!=0xffff; q++) {\r
+     if ((q->xres>=(x+width))&&(q->yres>=(y+height))&&(q->bpp==depth)) {\r
+        if (min>(unsigned)(q->xres*q->yres)) {\r
+           min = q->xres*q->yres;\r
+           p = q;\r
+        }\r
+     }\r
+ }\r
+\r
+ if (p) {\r
+    int sel = -1;\r
+    unsigned base, limit;\r
+\r
+    if ((p->mode|0x4000)==(p+1)->mode) {\r
+       p++;\r
+    }\r
+\r
+    if (selector==-1) {\r
+       if ((selector=sel=__dpmi_allocate_ldt_descriptors(1))==-1) {\r
+          return NULL;\r
+       }\r
+    }\r
+    if (p->mode&0x4000) {\r
+       limit = ((p->scanlen*p->yres+0xfffUL)&~0xfffUL) - 1;\r
+       if ((base=_map_linear(p->opaque, limit))==NULL) {\r
+          if (sel!=-1) {\r
+             selector = -1;\r
+             __dpmi_free_ldt_descriptor(sel);\r
+          }\r
+          return NULL;\r
+       }\r
+       dv_dump_virtual = dv_dump_virtual_linear;\r
+    } else {\r
+       limit = granularity = p->opaque;\r
+       base = 0xa0000;\r
+       dv_dump_virtual = dv_dump_virtual_banked;\r
+    }\r
+    __dpmi_set_segment_base_address(selector, base);\r
+    __dpmi_set_descriptor_access_rights(selector, ((_my_ds()&3)<<5)|0x4092);\r
+    __dpmi_set_segment_limit(selector, limit);\r
+\r
+    switch (p->bpp) {\r
+           case 15:\r
+                dv_clear_virtual = dv_clear_virtual16;\r
+                dv_putpixel = dv_putpixel16;\r
+                dv_color = dv_color15;\r
+                break;\r
+           case 16:\r
+                dv_clear_virtual = dv_clear_virtual16;\r
+                dv_putpixel = dv_putpixel16;\r
+                dv_color = dv_color16;\r
+                break;\r
+           case 24:\r
+                dv_clear_virtual = dv_clear_virtual24;\r
+                dv_putpixel = dv_putpixel24;\r
+                dv_color = dv_color32;\r
+                break;\r
+           case 32:\r
+                dv_clear_virtual = dv_clear_virtual32;\r
+                dv_putpixel = dv_putpixel32;\r
+                dv_color = dv_color32;\r
+                break;\r
+           default:\r
+                dv_clear_virtual = NULL;\r
+                dv_putpixel = NULL;\r
+    }\r
+\r
+    *delta = p->scanlen - ((depth+7)/8) * width;\r
+    *offset = p->scanlen*y + ((depth+7)/8) * x;\r
+    \r
+    __asm__("movw $0x4f02, %%ax; int  $0x10"::"b"(p->mode):"%eax");\r
+ }\r
+\r
+ return p;\r
+}\r
+\r
+\r
+\r
+/*\r
+ * fill rectangle\r
+ */\r
+void dv_fillrect (void *buffer, int bwidth, int x, int y, int width, int height, int color)\r
+{\r
+ int i, offset;\r
+\r
+ offset = y*bwidth + x;\r
+ bwidth -= width;\r
+ for (height+=y; y<height; y++) {\r
+     for (i=0; i<width; i++, offset++) {\r
+         dv_putpixel(buffer, offset, color);\r
+     }\r
+     offset += bwidth;\r
+ }\r
+}\r
+\r
+\r
+\r
+/*\r
+ * dv_dump_virtual_linear\r
+ */\r
+__asm__("\n\\r
+               .balign 4                       \n\\r
+               .global _dv_dump_virtual_linear \n\\r
+_dv_dump_virtual_linear:                       \n\\r
+               pushl   %fs                     \n\\r
+               pushl   %ebx                    \n\\r
+               pushl   %esi                    \n\\r
+               pushl   %edi                    \n\\r
+               movl    _selector, %fs          \n\\r
+               movl    4*4+4+0(%esp), %esi     \n\\r
+               movl    4*4+4+12(%esp), %edi    \n\\r
+               movl    4*4+4+4(%esp), %ecx     \n\\r
+               movl    4*4+4+8(%esp), %edx     \n\\r
+               movl    4*4+4+16(%esp), %ebx    \n\\r
+               shrl    $2, %ecx                \n\\r
+               .balign 4                       \n\\r
+       0:                                      \n\\r
+               pushl   %ecx                    \n\\r
+               .balign 4                       \n\\r
+       1:                                      \n\\r
+               movl    (%esi), %eax            \n\\r
+               addl    $4, %esi                \n\\r
+               movl    %eax, %fs:(%edi)        \n\\r
+               addl    $4, %edi                \n\\r
+               decl    %ecx                    \n\\r
+               jnz     1b                      \n\\r
+               popl    %ecx                    \n\\r
+               addl    %ebx, %edi              \n\\r
+               decl    %edx                    \n\\r
+               jnz     0b                      \n\\r
+               popl    %edi                    \n\\r
+               popl    %esi                    \n\\r
+               popl    %ebx                    \n\\r
+               popl    %fs                     \n\\r
+               ret");\r
+/*\r
+ * dv_dump_virtual_banked\r
+ */\r
+__asm__("\n\\r
+               .balign 4                       \n\\r
+               .global _dv_dump_virtual_banked \n\\r
+_dv_dump_virtual_banked:                       \n\\r
+               pushl   %fs                     \n\\r
+               pushl   %ebx                    \n\\r
+               pushl   %esi                    \n\\r
+               pushl   %edi                    \n\\r
+               pushl   %ebp                    \n\\r
+               movl    _selector, %fs          \n\\r
+               movl    4*5+4+0(%esp), %esi     \n\\r
+               movl    _granularity, %ebp      \n\\r
+               xorl    %edx, %edx              \n\\r
+               movl    4*5+4+12(%esp), %eax    \n\\r
+               divl    %ebp                    \n\\r
+               movl    %edx, %edi              \n\\r
+               pushl   %eax                    \n\\r
+               movl    %eax, %edx              \n\\r
+               xorl    %ebx, %ebx              \n\\r
+               movw    $0x4f05, %ax            \n\\r
+               int     $0x10                   \n\\r
+               movl    4*6+4+16(%esp), %ebx    \n\\r
+               movl    4*6+4+4(%esp), %ecx     \n\\r
+               movl    4*6+4+8(%esp), %edx     \n\\r
+               shrl    $2, %ecx                \n\\r
+               .balign 4                       \n\\r
+       0:                                      \n\\r
+               pushl   %ecx                    \n\\r
+               .balign 4                       \n\\r
+       1:                                      \n\\r
+               cmpl    %ebp, %edi              \n\\r
+               jb      2f                      \n\\r
+               pushl   %ebx                    \n\\r
+               pushl   %edx                    \n\\r
+               incl    12(%esp)                \n\\r
+               movw    $0x4f05, %ax            \n\\r
+               movl    12(%esp), %edx          \n\\r
+               xorl    %ebx, %ebx              \n\\r
+               int     $0x10                   \n\\r
+               popl    %edx                    \n\\r
+               popl    %ebx                    \n\\r
+               subl    %ebp, %edi              \n\\r
+       2:                                      \n\\r
+               movl    (%esi), %eax            \n\\r
+               addl    $4, %esi                \n\\r
+               movl    %eax, %fs:(%edi)        \n\\r
+               addl    $4, %edi                \n\\r
+               decl    %ecx                    \n\\r
+               jnz     1b                      \n\\r
+               popl    %ecx                    \n\\r
+               addl    %ebx, %edi              \n\\r
+               decl    %edx                    \n\\r
+               jnz     0b                      \n\\r
+               popl    %eax                    \n\\r
+               popl    %ebp                    \n\\r
+               popl    %edi                    \n\\r
+               popl    %esi                    \n\\r
+               popl    %ebx                    \n\\r
+               popl    %fs                     \n\\r
+               ret");\r
+\r
+\r
+\r
+/*\r
+ * dv_clear_virtual??\r
+ */\r
+__asm__("\n\\r
+               .balign 4                       \n\\r
+               .global _dv_clear_virtual16     \n\\r
+_dv_clear_virtual16:                           \n\\r
+               movl    12(%esp), %eax          \n\\r
+               pushw   %ax                     \n\\r
+               pushw   %ax                     \n\\r
+               popl    %eax                    \n\\r
+               jmp     _dv_clear_virtual_common\n\\r
+               .balign 4                       \n\\r
+               .global _dv_clear_virtual32     \n\\r
+_dv_clear_virtual32:                           \n\\r
+               movl    12(%esp), %eax          \n\\r
+                                               \n\\r
+               .balign 4                       \n\\r
+               .global _dv_clear_virtual_common\n\\r
+_dv_clear_virtual_common:                      \n\\r
+               movl    8(%esp), %ecx           \n\\r
+               movl    4(%esp), %edx           \n\\r
+               shrl    $2, %ecx                \n\\r
+               .balign 4                       \n\\r
+       0:                                      \n\\r
+               movl    %eax, (%edx)            \n\\r
+               addl    $4, %edx                \n\\r
+               decl    %ecx                    \n\\r
+               jnz     0b                      \n\\r
+               ret");\r
+__asm__("\n\\r
+               .balign 4                       \n\\r
+               .global _dv_clear_virtual24     \n\\r
+_dv_clear_virtual24:                           \n\\r
+               movl    8(%esp), %edx           \n\\r
+               movl    $0xaaaaaaab, %eax       \n\\r
+               mull    %edx                    \n\\r
+               movl    12(%esp), %eax          \n\\r
+               movl    %edx, %ecx              \n\\r
+               movl    4(%esp), %edx           \n\\r
+               pushl   %ebx                    \n\\r
+               shrl    %ecx                    \n\\r
+               movb    18(%esp), %bl           \n\\r
+               .balign 4                       \n\\r
+       0:                                      \n\\r
+               movw    %ax, (%edx)             \n\\r
+               movb    %bl, 2(%edx)            \n\\r
+               addl    $3, %edx                \n\\r
+               decl    %ecx                    \n\\r
+               jnz     0b                      \n\\r
+               popl    %ebx                    \n\\r
+               ret");\r
+\r
+\r
+\r
+/*\r
+ * dv_putpixel??\r
+ */\r
+__asm__("\n\\r
+               .balign 4                       \n\\r
+               .global _dv_putpixel16          \n\\r
+_dv_putpixel16:                                        \n\\r
+               movl    8(%esp), %edx           \n\\r
+               shll    %edx                    \n\\r
+               movl    12(%esp), %eax          \n\\r
+               addl    4(%esp), %edx           \n\\r
+               movw    %ax, (%edx)             \n\\r
+               ret");\r
+__asm__("\n\\r
+               .balign 4                       \n\\r
+               .global _dv_putpixel32          \n\\r
+_dv_putpixel32:                                        \n\\r
+               movl    8(%esp), %edx           \n\\r
+               shll    $2, %edx                \n\\r
+               movl    12(%esp), %eax          \n\\r
+               addl    4(%esp), %edx           \n\\r
+               movl    %eax, (%edx)            \n\\r
+               ret");\r
+__asm__("\n\\r
+               .global _dv_putpixel24          \n\\r
+_dv_putpixel24:                                        \n\\r
+               movl    8(%esp), %edx           \n\\r
+               leal    (%edx, %edx, 2), %edx   \n\\r
+               movl    12(%esp), %eax          \n\\r
+               addl    4(%esp), %edx           \n\\r
+               movw    %ax, (%edx)             \n\\r
+               shrl    $16, %eax               \n\\r
+               movb    %al, 2(%edx)            \n\\r
+               ret");\r
diff --git a/src/mesa/drivers/dos/dvesa.h b/src/mesa/drivers/dos/dvesa.h
new file mode 100644 (file)
index 0000000..aaa4be7
--- /dev/null
@@ -0,0 +1,127 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  4.0\r
+ * \r
+ * Copyright (C) 1999  Brian Paul   All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v0.1 for Mesa 4.0\r
+ *\r
+ *  Copyright (C) 2002 - Borca Daniel\r
+ *  Email : dborca@yahoo.com\r
+ *  Web   : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#ifndef DVESA_H_included\r
+#define DVESA_H_included\r
+\r
+typedef unsigned char word8;\r
+typedef unsigned short word16;\r
+typedef unsigned long word32;\r
+\r
+struct dvmode;\r
+\r
+extern int (*dv_color) (const unsigned char rgba[]);\r
+extern void (*dv_dump_virtual) (void *buffer, int width, int height, int offset, int delta);\r
+extern void (*dv_clear_virtual) (void *buffer, int len, int color);\r
+\r
+struct dvmode *dv_select_mode (int x, int y, int width, int height, int depth, int *delta, int *offset);\r
+void dv_fillrect (void *buffer, int bwidth, int x, int y, int width, int height, int color);\r
+\r
+/*\r
+ * not so public...\r
+ */\r
+extern int _rgb_scale_5[32];\r
+extern int _rgb_scale_6[64];\r
+\r
+/*\r
+ * dv_putpixel inlines\r
+ */\r
+#define dv_putpixel15 dv_putpixel16\r
+extern __inline__ void dv_putpixel16 (void *buffer, int offset, int color)\r
+{\r
+ ((word16 *)buffer)[offset] = (word16)color;\r
+}\r
+extern __inline__ void dv_putpixel24 (void *buffer, int offset, int color)\r
+{\r
+ *(word16 *)(buffer+offset*3) = (word16)color;\r
+ *(word8 *)(buffer+offset*3+2) = (word8)(color>>16);\r
+}\r
+extern __inline__ void dv_putpixel32 (void *buffer, int offset, int color)\r
+{\r
+ ((word32 *)buffer)[offset] = color;\r
+}\r
+\r
+/*\r
+ * dv_color inlines\r
+ */\r
+extern __inline__ int dv_color15 (const unsigned char rgba[])\r
+{\r
+ return ((rgba[0]>>3)<<10)|((rgba[1]>>3)<<5)|(rgba[2]>>3);\r
+}\r
+extern __inline__ int dv_color16 (const unsigned char rgba[])\r
+{\r
+ return ((rgba[0]>>3)<<11)|((rgba[1]>>2)<<5)|(rgba[2]>>3);\r
+}\r
+#define dv_color24 dv_color32\r
+extern __inline__ int dv_color32 (const unsigned char rgba[])\r
+{\r
+ return (rgba[0]<<16)|(rgba[1]<<8)|(rgba[2]);\r
+}\r
+\r
+/*\r
+ * dv_getrgba inlines\r
+ */\r
+extern __inline__ void dv_getrgba15 (void *buffer, int offset, unsigned char rgba[4])\r
+{\r
+ int c = ((word16 *)buffer)[offset];\r
+ rgba[0] = _rgb_scale_5[(c >> 10) & 0x1F];\r
+ rgba[1] = _rgb_scale_5[(c >> 5) & 0x1F];\r
+ rgba[2] = _rgb_scale_5[c & 0x1F];\r
+ rgba[3] = 255;\r
+}\r
+extern __inline__ void dv_getrgba16 (void *buffer, int offset, unsigned char rgba[4])\r
+{\r
+ int c = ((word16 *)buffer)[offset];\r
+ rgba[0] = _rgb_scale_5[(c >> 11) & 0x1F];\r
+ rgba[1] = _rgb_scale_6[(c >> 5) & 0x3F];\r
+ rgba[2] = _rgb_scale_5[c & 0x1F];\r
+ rgba[3] = 255;\r
+}\r
+extern __inline__ void dv_getrgba24 (void *buffer, int offset, unsigned char rgba[4])\r
+{\r
+ int c = *(word32 *)(buffer+offset*3);\r
+ rgba[0] = c >> 16;\r
+ rgba[1] = c >> 8;\r
+ rgba[2] = c;\r
+ rgba[3] = 255;\r
+}\r
+extern __inline__ void dv_getrgba32 (void *buffer, int offset, unsigned char rgba[4])\r
+{\r
+ int c = ((word32 *)buffer)[offset];\r
+ rgba[0] = c >> 16;\r
+ rgba[1] = c >> 8;\r
+ rgba[2] = c;\r
+ rgba[3] = 255;\r
+}\r
+\r
+#endif\r
diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ
new file mode 100644 (file)
index 0000000..4895cc3
--- /dev/null
@@ -0,0 +1,163 @@
+# DOS/DJGPP core makefile v0.1 for Mesa 4.0.x\r
+#\r
+#  Copyright (C) 2002 - Borca Daniel\r
+#  Email : dborca@yahoo.com\r
+#  Web   : http://www.geocities.com/dborca\r
+\r
+\r
+.PHONY: all clean\r
+\r
+TOP = ..\r
+CC = gcc\r
+CFLAGS = -I$(TOP)/include -I. -Wall -W -Wno-unused -mcpu=pentium -ffast-math -O2\r
+AR = ar\r
+ARFLAGS = ruv\r
+LIBDIR = $(TOP)/lib\r
+\r
+GL_LIB = libgl.a\r
+\r
+CORE_SOURCES = \\r
+       accum.c \\r
+       api_arrayelt.c \\r
+       api_loopback.c \\r
+       api_noop.c \\r
+       api_validate.c \\r
+       array_cache/ac_context.c \\r
+       array_cache/ac_import.c \\r
+       attrib.c \\r
+       blend.c \\r
+       buffers.c \\r
+       clip.c \\r
+       colortab.c \\r
+       config.c \\r
+       context.c \\r
+       convolve.c \\r
+       debug.c \\r
+       depth.c \\r
+       dispatch.c \\r
+       dlist.c \\r
+       drawpix.c \\r
+       enable.c \\r
+       enums.c \\r
+       eval.c \\r
+       extensions.c \\r
+       feedback.c \\r
+       fog.c \\r
+       get.c \\r
+       glapi.c \\r
+       glthread.c \\r
+       hash.c \\r
+       hint.c \\r
+       histogram.c \\r
+       image.c \\r
+       imports.c \\r
+       light.c \\r
+       lines.c \\r
+       math/m_debug_clip.c \\r
+       math/m_debug_norm.c \\r
+       math/m_debug_vertex.c \\r
+       math/m_debug_xform.c \\r
+       math/m_eval.c \\r
+       math/m_matrix.c \\r
+       math/m_translate.c \\r
+       math/m_vector.c \\r
+       math/m_vertices.c \\r
+       math/m_xform.c \\r
+       matrix.c \\r
+       mem.c \\r
+       mmath.c \\r
+       pixel.c \\r
+       points.c \\r
+       polygon.c \\r
+       rastpos.c \\r
+       state.c \\r
+       stencil.c \\r
+       swrast/s_aaline.c \\r
+       swrast/s_aatriangle.c \\r
+       swrast/s_accum.c \\r
+       swrast/s_alpha.c \\r
+       swrast/s_alphabuf.c \\r
+       swrast/s_bitmap.c \\r
+       swrast/s_blend.c \\r
+       swrast/s_buffers.c \\r
+       swrast/s_context.c \\r
+       swrast/s_copypix.c \\r
+       swrast/s_depth.c \\r
+       swrast/s_drawpix.c \\r
+       swrast/s_feedback.c \\r
+       swrast/s_fog.c \\r
+       swrast/s_histogram.c \\r
+       swrast/s_imaging.c \\r
+       swrast/s_lines.c \\r
+       swrast/s_logic.c \\r
+       swrast/s_masking.c \\r
+       swrast/s_pb.c \\r
+       swrast/s_pixeltex.c \\r
+       swrast/s_points.c \\r
+       swrast/s_readpix.c \\r
+       swrast/s_scissor.c \\r
+       swrast/s_span.c \\r
+       swrast/s_stencil.c \\r
+       swrast/s_texstore.c \\r
+       swrast/s_texture.c \\r
+       swrast/s_triangle.c \\r
+       swrast/s_zoom.c \\r
+       swrast_setup/ss_context.c \\r
+       swrast_setup/ss_triangle.c \\r
+       swrast_setup/ss_vb.c \\r
+       texformat.c \\r
+       teximage.c \\r
+       texobj.c \\r
+       texstate.c \\r
+       texstore.c \\r
+       texutil.c \\r
+       tnl/t_array_api.c \\r
+       tnl/t_array_import.c \\r
+       tnl/t_context.c \\r
+       tnl/t_eval_api.c \\r
+       tnl/t_imm_alloc.c \\r
+       tnl/t_imm_api.c \\r
+       tnl/t_imm_debug.c \\r
+       tnl/t_imm_dlist.c \\r
+       tnl/t_imm_elt.c \\r
+       tnl/t_imm_eval.c \\r
+       tnl/t_imm_exec.c \\r
+       tnl/t_imm_fixup.c \\r
+       tnl/t_pipeline.c \\r
+       tnl/t_vb_fog.c \\r
+       tnl/t_vb_light.c \\r
+       tnl/t_vb_normals.c \\r
+       tnl/t_vb_points.c \\r
+       tnl/t_vb_render.c \\r
+       tnl/t_vb_texgen.c \\r
+       tnl/t_vb_texmat.c \\r
+       tnl/t_vb_vertex.c \\r
+       varray.c \\r
+       vtxfmt.c\r
+\r
+DRIVER_SOURCES = DOS/dmesa.c DOS/dvesa.c\r
+\r
+SOURCES = $(CORE_SOURCES) $(DRIVER_SOURCES)\r
+\r
+OBJECTS = $(SOURCES:.c=.o)\r
+\r
+.c.o:\r
+       gcc -o $@ -c $(CFLAGS) $<\r
+\r
+all: $(LIBDIR)/$(GL_LIB)\r
+\r
+$(LIBDIR)/$(GL_LIB): $(OBJECTS)\r
+       $(AR) $(ARFLAGS) $(LIBDIR)/$(GL_LIB) $(OBJECTS)\r
+\r
+clean:\r
+       -$(RM) *.o\r
+       -$(RM) DOS\*.o\r
+\r
+include depend\r
+\r
+DOS/dmesa.o: DOS/dmesa.c glheader.h ../include/GL/gl.h context.h glapi.h \\r
+  mtypes.h config.h glapitable.h glthread.h math/m_matrix.h dd.h \\r
+  ../include/GL/dmesa.h matrix.h texformat.h texstore.h array_cache/acache.h \\r
+  swrast/swrast.h swrast_setup/swrast_setup.h tnl/tnl.h tnl/t_context.h \\r
+  math/m_vector.h math/m_xform.h tnl/t_pipeline.h DOS/dvesa.h DOS/dmesaint.h\r
+DOS/dvesa.o: DOS/dvesa.c DOS/dvesa.h\r