diff options
Diffstat (limited to 'nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos')
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/blit.S | 199 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/dmesa.c | 1430 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/dpmi.c | 166 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/internal.h | 131 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/null.c | 224 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/null.h | 41 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vesa.c | 531 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vesa.h | 47 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vga.c | 250 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vga.h | 42 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/video.c | 669 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/video.h | 65 | ||||
-rw-r--r-- | nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/virtual.S | 489 |
13 files changed, 4284 insertions, 0 deletions
diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/blit.S b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/blit.S new file mode 100644 index 000000000..f5888c7e3 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/blit.S @@ -0,0 +1,199 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.3 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@yahoo.com + * Web : http://www.geocities.com/dborca + */ + + + .file "blit.S" + +/* + * extern unsigned int vesa_gran_mask, vesa_gran_shift; + * extern int vl_video_selector; + + * extern void *vl_current_draw_buffer; + * extern int vl_current_stride, vl_current_height; + * extern int vl_current_offset, vl_current_delta; + */ + + .text + +/* Desc: VESA bank switching routine (BIOS) + * + * In : EBX=0, EDX = bank number + * Out : - + * + * Note: thrashes EAX + */ + .p2align 5,,31 +_vesa_swbankBIOS: + movw $0x4f05, %ax + int $0x10 + ret + + .p2align 2,,3 + .global _vesa_swbank +_vesa_swbank: .long _vesa_swbankBIOS + +/* Desc: void vesa_b_dump_virtual (void); + * + * In : - + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _vesa_b_dump_virtual +_vesa_b_dump_virtual: + cld + pushl %es + pushl %ebx + pushl %esi + pushl %edi + pushl %ebp + movl _vl_video_selector, %es + movl _vl_current_draw_buffer, %esi + movl _vl_current_offset, %edi + movl _vesa_gran_shift, %ecx + movl _vesa_gran_mask, %ebp + movl %edi, %edx + xorl %ebx, %ebx + andl %ebp, %edi + shrl %cl, %edx + incl %ebp + call *_vesa_swbank + movl _vl_current_stride, %ecx + movl _vl_current_height, %eax + movl _vl_current_delta, %ebx + shrl $2, %ecx + .balign 4 + 0: + pushl %ecx + .balign 4 + 1: + cmpl %ebp, %edi + jb 2f + pushl %eax + pushl %ebx + incl %edx + xorl %ebx, %ebx + call *_vesa_swbank + popl %ebx + popl %eax + subl %ebp, %edi + .balign 4 + 2: + movsl + decl %ecx + jnz 1b + popl %ecx + addl %ebx, %edi + decl %eax + jnz 0b + popl %ebp + popl %edi + popl %esi + popl %ebx + popl %es + ret + +/* Desc: void vesa_l_dump_virtual (void); + * + * In : - + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _vesa_l_dump_virtual +_vesa_l_dump_virtual: + cld + pushl %es + pushl %esi + pushl %edi + movl _vl_video_selector, %es + movl _vl_current_draw_buffer, %esi + movl _vl_current_offset, %edi + movl _vl_current_stride, %ecx + movl _vl_current_height, %edx + movl _vl_current_delta, %eax + shrl $2, %ecx + .balign 4 + 0: + pushl %ecx + rep; movsl + popl %ecx + addl %eax, %edi + decl %edx + jnz 0b + popl %edi + popl %esi + popl %es + ret + +/* Desc: void vesa_l_dump_virtual_mmx (void); + * + * In : - + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _vesa_l_dump_virtual_mmx +_vesa_l_dump_virtual_mmx: +#ifdef USE_MMX_ASM + pushl %esi + pushl %edi + movl _vl_video_selector, %fs + movl _vl_current_draw_buffer, %esi + movl _vl_current_offset, %edi + movl _vl_current_stride, %ecx + movl _vl_current_height, %edx + movl _vl_current_delta, %eax + shrl $3, %ecx + .balign 4 + 0: + pushl %ecx + .balign 4 + 1: + movq (%esi), %mm0 + addl $8, %esi + movq %mm0, %fs:(%edi) + addl $8, %edi + decl %ecx + jnz 1b + popl %ecx + addl %eax, %edi + decl %edx + jnz 0b + popl %edi + popl %esi + emms +#endif + ret diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/dmesa.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/dmesa.c new file mode 100644 index 000000000..d7c847709 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/dmesa.c @@ -0,0 +1,1430 @@ +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 1999-2004 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. + */ + +/* + * DOS/DJGPP device driver v1.7 for Mesa + * + * Copyright (c) 2003 - Daniel Borca + * Email : dborca@users.sourceforge.net + * Web : http://www.geocities.com/dborca + */ + + +#include "glheader.h" +#include "context.h" +#include "imports.h" +#ifndef FX +#include "bufferobj.h" +#include "buffers.h" +#include "extensions.h" +#include "macros.h" +#include "matrix.h" +#include "mtypes.h" +#include "texformat.h" +#include "teximage.h" +#include "texstore.h" +#include "array_cache/acache.h" +#include "swrast/s_context.h" +#include "swrast/s_depth.h" +#include "swrast/s_lines.h" +#include "swrast/s_triangle.h" +#include "swrast/swrast.h" +#include "swrast_setup/swrast_setup.h" +#include "tnl/tnl.h" +#include "tnl/t_context.h" +#include "tnl/t_pipeline.h" +#include "drivers/common/driverfuncs.h" +#include "video.h" +#else /* FX */ +#include "GL/fxmesa.h" +#endif /* FX */ + +#include "GL/dmesa.h" + + +#define SWTC 0 /* SW texture compression */ + + +/* + * In C++ terms, this class derives from the GLvisual class. + * Add system-specific fields to it. + */ +struct dmesa_visual { + GLvisual gl_visual; + GLboolean sw_alpha; /* use Mesa's alpha buffer? */ + int z_buffer; /* Z=buffer: 0=no, 1=SW, -1=HW */ +}; + +/* + * In C++ terms, this class derives from the GLframebuffer class. + * Add system-specific fields to it. + */ +struct dmesa_buffer { + GLframebuffer gl_buffer; /* The depth, stencil, accum, etc buffers */ + void *the_window; /* your window handle, etc */ + + int xpos, ypos; /* position */ + int width, height; /* size in pixels */ +}; + +/* + * In C++ terms, this class derives from the GLcontext class. + * Add system-specific fields to it. + */ +struct dmesa_context { + GLcontext gl_ctx; /* the core library context */ + DMesaVisual visual; + DMesaBuffer buffer; + GLuint ClearColor; + GLuint ClearIndex; + /* etc... */ +}; + + +#ifndef FX +/**************************************************************************** + * Read/Write pixels + ***************************************************************************/ +#define FLIP(y) (dmesa->buffer->height - (y) - 1) +#define FLIP2(y) (_b_ - (y)) + +#define DSTRIDE dmesa->buffer->width + +/**************************************************************************** + * RGB[A] + ***************************************************************************/ +static void +write_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, offset; + + offset = DSTRIDE * FLIP(y) + x; + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++, offset++) { + if (mask[i]) { + vl_putpixel(offset, vl_mixrgba(rgba[i])); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++, offset++) { + vl_putpixel(offset, vl_mixrgba(rgba[i])); + } + } +} + + +static void +write_rgb_span (const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgb[][3], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, offset; + + offset = DSTRIDE * FLIP(y) + x; + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++, offset++) { + if (mask[i]) { + vl_putpixel(offset, vl_mixrgb(rgb[i])); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++, offset++) { + vl_putpixel(offset, vl_mixrgb(rgb[i])); + } + } +} + + +static void +write_mono_rgba_span (const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLchan color[4], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, offset, rgba = vl_mixrgba(color); + + offset = DSTRIDE * FLIP(y) + x; + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++, offset++) { + if (mask[i]) { + vl_putpixel(offset, rgba); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++, offset++) { + vl_putpixel(offset, rgba); + } + } +} + + +static void +read_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, offset; + + offset = DSTRIDE * FLIP(y) + x; + /* read all pixels */ + for (i = 0; i < n; i++, offset++) { + vl_getrgba(offset, rgba[i]); + } +} + + +static void +write_rgba_pixels (const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte rgba[][4], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; + + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++) { + if (mask[i]) { + vl_putpixel(FLIP2(y[i])*_w_ + x[i], vl_mixrgba(rgba[i])); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++) { + vl_putpixel(FLIP2(y[i])*_w_ + x[i], vl_mixrgba(rgba[i])); + } + } +} + + +static void +write_mono_rgba_pixels (const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLchan color[4], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1, rgba = vl_mixrgba(color); + + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++) { + if (mask[i]) { + vl_putpixel(FLIP2(y[i])*_w_ + x[i], rgba); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++) { + vl_putpixel(FLIP2(y[i])*_w_ + x[i], rgba); + } + } +} + + +static void +read_rgba_pixels (const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; + + if (mask) { + /* read some pixels */ + for (i = 0; i < n; i++) { + if (mask[i]) { + vl_getrgba(FLIP2(y[i])*_w_ + x[i], rgba[i]); + } + } + } else { + /* read all pixels */ + for (i = 0; i < n; i++) { + vl_getrgba(FLIP2(y[i])*_w_ + x[i], rgba[i]); + } + } +} + + +/**************************************************************************** + * Index + ***************************************************************************/ +static void +write_index_span (const GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint n, GLint x, GLint y, + const GLuint index[], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, offset; + + offset = DSTRIDE * FLIP(y) + x; + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++, offset++) { + if (mask[i]) { + vl_putpixel(offset, index[i]); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++, offset++) { + vl_putpixel(offset, index[i]); + } + } +} + + +static void +write_index8_span (const GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint n, GLint x, GLint y, + const GLubyte index[], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, offset; + + offset = DSTRIDE * FLIP(y) + x; + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++, offset++) { + if (mask[i]) { + vl_putpixel(offset, index[i]); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++, offset++) { + vl_putpixel(offset, index[i]); + } + } +} + + +static void +write_mono_index_span (const GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint n, GLint x, GLint y, + GLuint colorIndex, const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, offset; + + offset = DSTRIDE * FLIP(y) + x; + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++, offset++) { + if (mask[i]) { + vl_putpixel(offset, colorIndex); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++, offset++) { + vl_putpixel(offset, colorIndex); + } + } +} + + +static void +read_index_span (const GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint n, GLint x, GLint y, GLuint index[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, offset; + + offset = DSTRIDE * FLIP(y) + x; + /* read all pixels */ + for (i = 0; i < n; i++, offset++) { + index[i] = vl_getpixel(offset); + } +} + + +static void +write_index_pixels (const GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint n, const GLint x[], const GLint y[], + const GLuint index[], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; + + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++) { + if (mask[i]) { + vl_putpixel(FLIP2(y[i])*_w_ + x[i], index[i]); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++) { + vl_putpixel(FLIP2(y[i])*_w_ + x[i], index[i]); + } + } +} + + +static void +write_mono_index_pixels (const GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint n, const GLint x[], const GLint y[], + GLuint colorIndex, const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; + + if (mask) { + /* draw some pixels */ + for (i = 0; i < n; i++) { + if (mask[i]) { + vl_putpixel(FLIP2(y[i])*_w_ + x[i], colorIndex); + } + } + } else { + /* draw all pixels */ + for (i = 0; i < n; i++) { + vl_putpixel(FLIP2(y[i])*_w_ + x[i], colorIndex); + } + } +} + + +static void +read_index_pixels (const GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint n, const GLint x[], const GLint y[], + GLuint index[], const GLubyte mask[]) +{ + const DMesaContext dmesa = (DMesaContext)ctx; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; + + if (mask) { + /* read some pixels */ + for (i = 0; i < n; i++) { + if (mask[i]) { + index[i] = vl_getpixel(FLIP2(y[i])*_w_ + x[i]); + } + } + } else { + /* read all pixels */ + for (i = 0; i < n; i++) { + index[i] = vl_getpixel(FLIP2(y[i])*_w_ + x[i]); + } + } +} + + +/**************************************************************************** + * Z-buffer + ***************************************************************************/ + + +/**************************************************************************** + * Optimized triangle rendering + ***************************************************************************/ + +/* + * NON-depth-buffered flat triangle. + */ +#define NAME tri_rgb_flat + +#define SETUP_CODE \ + const DMesaContext dmesa = (DMesaContext)ctx;\ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; \ + GLuint rgb = vl_mixrgb(v2->color); + +#define RENDER_SPAN(span) \ + GLuint i, offset = FLIP2(span.y)*_w_ + span.x;\ + for (i = 0; i < span.end; i++, offset++) { \ + vl_putpixel(offset, rgb); \ + } + +#include "swrast/s_tritemp.h" + + +/* + * Z-less flat triangle. + */ +#define NAME tri_rgb_flat_zless + +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE + +#define SETUP_CODE \ + const DMesaContext dmesa = (DMesaContext)ctx; \ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; \ + GLuint rgb = vl_mixrgb(v2->color); + +#define RENDER_SPAN(span) \ + GLuint i, offset = FLIP2(span.y)*_w_ + span.x;\ + for (i = 0; i < span.end; i++, offset++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z);\ + if (z < zRow[i]) { \ + vl_putpixel(offset, rgb); \ + zRow[i] = z; \ + } \ + span.z += span.zStep; \ + } + +#include "swrast/s_tritemp.h" + + +/* + * NON-depth-buffered iterated triangle. + */ +#define NAME tri_rgb_iter + +#define INTERP_RGB 1 + +#define SETUP_CODE \ + const DMesaContext dmesa = (DMesaContext)ctx;\ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; + +#define RENDER_SPAN(span) \ + GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \ + for (i = 0; i < span.end; i++, offset++) { \ + vl_putpixel(offset, vl_mixfix(span.red, span.green, span.blue)); \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + } + +#include "swrast/s_tritemp.h" + + +/* + * Z-less iterated triangle. + */ +#define NAME tri_rgb_iter_zless + +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE +#define INTERP_RGB 1 + +#define SETUP_CODE \ + const DMesaContext dmesa = (DMesaContext)ctx;\ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; + +#define RENDER_SPAN(span) \ + GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \ + for (i = 0; i < span.end; i++, offset++) { \ + const DEPTH_TYPE z = FixedToDepth(span.z); \ + if (z < zRow[i]) { \ + vl_putpixel(offset, vl_mixfix(span.red, span.green, span.blue));\ + zRow[i] = z; \ + } \ + span.red += span.redStep; \ + span.green += span.greenStep; \ + span.blue += span.blueStep; \ + span.z += span.zStep; \ + } + +#include "swrast/s_tritemp.h" + + +/* + * Analyze context state to see if we can provide a fast triangle function + * Otherwise, return NULL. + */ +static swrast_tri_func +dmesa_choose_tri_function (GLcontext *ctx) +{ + const SWcontext *swrast = SWRAST_CONTEXT(ctx); + + if ((ctx->RenderMode != GL_RENDER) + || (ctx->Polygon.SmoothFlag) + || (ctx->Polygon.StippleFlag) + || (ctx->Texture._EnabledUnits) + || (swrast->_RasterMask & MULTI_DRAW_BIT) + || (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)) { + return (swrast_tri_func)NULL; + } + + if (swrast->_RasterMask==DEPTH_BIT + && ctx->Depth.Func==GL_LESS + && ctx->Depth.Mask==GL_TRUE + && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS) { + return (ctx->Light.ShadeModel==GL_SMOOTH) ? tri_rgb_iter_zless : tri_rgb_flat_zless; + } + + if (swrast->_RasterMask==0) { /* no depth test */ + return (ctx->Light.ShadeModel==GL_SMOOTH) ? tri_rgb_iter : tri_rgb_flat; + } + + return (swrast_tri_func)NULL; +} + + +/* Override for the swrast triangle-selection function. Try to use one + * of our internal triangle functions, otherwise fall back to the + * standard swrast functions. + */ +static void +dmesa_choose_tri (GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + + if (!(swrast->Triangle=dmesa_choose_tri_function(ctx))) { + _swrast_choose_triangle(ctx); + } +} + + +/**************************************************************************** + * Optimized line rendering + ***************************************************************************/ + +/* + * NON-depth-buffered flat line. + */ +#define NAME line_rgb_flat + +#define INTERP_XY 1 +#define CLIP_HACK 1 + +#define SETUP_CODE \ + const DMesaContext dmesa = (DMesaContext)ctx;\ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; \ + GLuint rgb = vl_mixrgb(vert1->color); + +#define PLOT(X,Y) vl_putpixel(FLIP2(Y) * _w_ + X, rgb); + +#include "swrast/s_linetemp.h" + + +/* + * Z-less flat line. + */ +#define NAME line_rgb_flat_zless + +#define INTERP_XY 1 +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE +#define CLIP_HACK 1 + +#define SETUP_CODE \ + const DMesaContext dmesa = (DMesaContext)ctx;\ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; \ + GLuint rgb = vl_mixrgb(vert1->color); + +#define PLOT(X,Y) \ + if (Z < *zPtr) { \ + *zPtr = Z; \ + vl_putpixel(FLIP2(Y) * _w_ + X, rgb); \ + } + +#include "swrast/s_linetemp.h" + + +/* + * NON-depth-buffered iterated line. + */ +#define line_rgb_iter NULL + + +/* + * Z-less iterated line. + */ +#define line_rgb_iter_zless NULL + + +/* + * Analyze context state to see if we can provide a fast line function + * Otherwise, return NULL. + */ +static swrast_line_func +dmesa_choose_line_function (GLcontext *ctx) +{ + const SWcontext *swrast = SWRAST_CONTEXT(ctx); + + if ((ctx->RenderMode != GL_RENDER) + || (ctx->Line.SmoothFlag) + || (ctx->Texture._EnabledUnits) + || (ctx->Line.StippleFlag) + || (swrast->_RasterMask & MULTI_DRAW_BIT) + || (ctx->Line.Width!=1.0F)) { + return (swrast_line_func)NULL; + } + + if (swrast->_RasterMask==DEPTH_BIT + && ctx->Depth.Func==GL_LESS + && ctx->Depth.Mask==GL_TRUE + && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS) { + return (ctx->Light.ShadeModel==GL_SMOOTH) ? line_rgb_iter_zless : line_rgb_flat_zless; + } + + if (swrast->_RasterMask==0) { /* no depth test */ + return (ctx->Light.ShadeModel==GL_SMOOTH) ? line_rgb_iter : line_rgb_flat; + } + + return (swrast_line_func)NULL; +} + + +/* Override for the swrast line-selection function. Try to use one + * of our internal line functions, otherwise fall back to the + * standard swrast functions. + */ +static void +dmesa_choose_line (GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + + if (!(swrast->Line=dmesa_choose_line_function(ctx))) { + _swrast_choose_line(ctx); + } +} + + +/**************************************************************************** + * Miscellaneous device driver funcs + ***************************************************************************/ +static const struct gl_texture_format * +choose_tex_format (GLcontext *ctx, GLint internalFormat, + GLenum format, GLenum type) +{ + switch (internalFormat) { + case GL_COMPRESSED_RGB_ARB: + return &_mesa_texformat_rgb; + case GL_COMPRESSED_RGBA_ARB: + return &_mesa_texformat_rgba; + default: + return _mesa_choose_tex_format(ctx, internalFormat, format, type); + } +} + + +static void +clear_index (GLcontext *ctx, GLuint index) +{ + ((DMesaContext)ctx)->ClearIndex = index; +} + + +static void +clear_color (GLcontext *ctx, const GLfloat color[4]) +{ + GLubyte col[4]; + CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]); + CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]); + CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]); + CLAMPED_FLOAT_TO_UBYTE(col[3], color[3]); + ((DMesaContext)ctx)->ClearColor = vl_mixrgba(col); +} + + +static void +clear (GLcontext *ctx, GLbitfield mask, GLboolean all, + GLint x, GLint y, GLint width, GLint height) +{ + const DMesaContext c = (DMesaContext)ctx; + const GLuint *colorMask = (GLuint *)&ctx->Color.ColorMask; + + /* + * Clear the specified region of the buffers indicated by 'mask' + * using the clear color or index as specified by one of the two + * functions above. + * If all==GL_TRUE, clear whole buffer, else just clear region defined + * by x,y,width,height + */ + + /* we can't handle color or index masking */ + if ((*colorMask == 0xffffffff) && (ctx->Color.IndexMask == 0xffffffff)) { + if (mask & DD_BACK_LEFT_BIT) { + int color = ((GLvisual *)(c->visual))->rgbMode ? c->ClearColor : c->ClearIndex; + + if (all) { + vl_clear(color); + } else { + vl_rect(x, c->buffer->height - y - height, width, height, color); + } + + mask &= ~DD_BACK_LEFT_BIT; + } + } + + if (mask) { + _swrast_Clear(ctx, mask, all, x, y, width, height); + } +} + + +/* + * This function is called to specify which buffer to read and write + * for software rasterization (swrast) fallbacks. This doesn't necessarily + * correspond to glDrawBuffer() or glReadBuffer() calls. + */ +static void +set_buffer (GLcontext *ctx, GLframebuffer *colorBuffer, GLuint bufferBit) +{ + /* + * XXX todo - examine bufferBit and set read/write pointers + */ + /* Normally, we would have + * ctx->Driver.ReadBuffer == set_read_buffer + * ctx->Driver.DrawBuffer == set_draw_buffer + * and make sure set_draw_buffer calls _swrast_DrawBuffer, + * which in turn will call this routine via dd->SetBuffer. + */ +} + + +/* + * Return the width and height of the current buffer. + * If anything special has to been done when the buffer/window is + * resized, do it now. + */ +static void +get_buffer_size (GLframebuffer *buffer, GLuint *width, GLuint *height) +{ + DMesaBuffer b = (DMesaBuffer)buffer; + + *width = b->width; + *height = b->height; +} + + +static void +viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) +{ + /* poll for window size change and realloc software Z/stencil/etc if needed */ + _mesa_ResizeBuffersMESA(); +} + + +static const GLubyte * +get_string (GLcontext *ctx, GLenum name) +{ + switch (name) { + case GL_RENDERER: + return (const GLubyte *)"Mesa DJGPP"; + default: + return NULL; + } +} + + +static void +finish (GLcontext *ctx) +{ + /* + * XXX todo - OPTIONAL FUNCTION: implements glFinish if possible + */ +} + + +static void +flush (GLcontext *ctx) +{ + /* + * XXX todo - OPTIONAL FUNCTION: implements glFlush if possible + */ +} + + +/**************************************************************************** + * State + ***************************************************************************/ +#define DMESA_NEW_LINE (_NEW_LINE | \ + _NEW_TEXTURE | \ + _NEW_LIGHT | \ + _NEW_DEPTH | \ + _NEW_RENDERMODE | \ + _SWRAST_NEW_RASTERMASK) + +#define DMESA_NEW_TRIANGLE (_NEW_POLYGON | \ + _NEW_TEXTURE | \ + _NEW_LIGHT | \ + _NEW_DEPTH | \ + _NEW_RENDERMODE | \ + _SWRAST_NEW_RASTERMASK) + +/* Extend the software rasterizer with our line and triangle + * functions. + */ +static void +dmesa_register_swrast_functions (GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + + swrast->choose_line = dmesa_choose_line; + swrast->choose_triangle = dmesa_choose_tri; + + swrast->invalidate_line |= DMESA_NEW_LINE; + swrast->invalidate_triangle |= DMESA_NEW_TRIANGLE; +} + + +static void +dmesa_update_state (GLcontext *ctx, GLuint new_state) +{ + /* Propagate statechange information to swrast and swrast_setup + * modules. The DMesa driver has no internal GL-dependent state. + */ + _swrast_InvalidateState( ctx, new_state ); + _ac_InvalidateState( ctx, new_state ); + _tnl_InvalidateState( ctx, new_state ); + _swsetup_InvalidateState( ctx, new_state ); +} + + +/* Initialize the device driver function table with the functions + * we implement in this driver. + */ +static void +dmesa_init_driver_functions (DMesaVisual visual, + struct dd_function_table *driver) +{ + driver->UpdateState = dmesa_update_state; + driver->GetString = get_string; + driver->GetBufferSize = get_buffer_size; + driver->Viewport = viewport; + driver->Flush = flush; + driver->Finish = finish; + driver->Clear = clear; + driver->ClearColor = clear_color; + driver->ClearIndex = clear_index; +#if SWTC + driver->ChooseTextureFormat = choose_tex_format; +#endif +} + + +/* Setup pointers and other driver state that is constant for the life + * of a context. + */ +static void +dmesa_init_pointers (GLcontext *ctx) +{ + struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference(ctx); + + dd->SetBuffer = set_buffer; + + /* The span functions should be in `dmesa_update_state', but I'm + * pretty sure they will never change during the life of the Visual + */ + + /* Index span/pixel functions */ + dd->WriteCI32Span = write_index_span; + dd->WriteCI8Span = write_index8_span; + dd->WriteMonoCISpan = write_mono_index_span; + dd->WriteCI32Pixels = write_index_pixels; + dd->WriteMonoCIPixels = write_mono_index_pixels; + dd->ReadCI32Span = read_index_span; + dd->ReadCI32Pixels = read_index_pixels; + + /* RGB(A) span/pixel functions */ + dd->WriteRGBASpan = write_rgba_span; + dd->WriteRGBSpan = write_rgb_span; + dd->WriteMonoRGBASpan = write_mono_rgba_span; + dd->WriteRGBAPixels = write_rgba_pixels; + dd->WriteMonoRGBAPixels = write_mono_rgba_pixels; + dd->ReadRGBASpan = read_rgba_span; + dd->ReadRGBAPixels = read_rgba_pixels; +} +#endif /* FX */ + + +/**************************************************************************** + * DMesa Public API Functions + ***************************************************************************/ + +/* + * The exact arguments to this function will depend on your window system + */ +DMesaVisual +DMesaCreateVisual (GLint width, + GLint height, + GLint colDepth, + GLint refresh, + GLboolean dbFlag, + GLboolean rgbFlag, + GLint alphaSize, + GLint depthSize, + GLint stencilSize, + GLint accumSize) +{ + DMesaVisual v; + GLint redBits, greenBits, blueBits, alphaBits, indexBits; + GLboolean sw_alpha; + + alphaBits = 0; + + if (!rgbFlag) { + indexBits = 8; + redBits = 0; + greenBits = 0; + blueBits = 0; + } else { + indexBits = 0; + switch (colDepth) { + case 8: + redBits = 8; + greenBits = 8; + blueBits = 8; + break; + case 15: + alphaBits = 1; + redBits = 5; + greenBits = 5; + blueBits = 5; + break; + case 16: + redBits = 5; + greenBits = 6; + blueBits = 5; + break; + case 32: + alphaBits = 8; + case 24: + redBits = 8; + greenBits = 8; + blueBits = 8; + break; + default: + return NULL; + } + } + + /* Okay, + * `alphaBits' is what we can provide + * `alphaSize' is what app requests + * + * Note that alpha buffering is required only if destination alpha is used + * in alpha blending; alpha blending modes that do not use destination alpha + * can be used w/o alpha buffer. + * + * We will use whatever ALPHA app requests. Later, in `CreateBuffer' we'll + * instruct Mesa to use its own ALPHA buffer, by passing a non-FALSE value + * for ALPHA to `_mesa_initialize_framebuffer'. + * + * Basically, 32bit modes provide ALPHA storage, but can we rely on this? + */ + alphaBits = alphaSize; + sw_alpha = (alphaBits > 0); + +#ifndef FX + if (!dbFlag) { + return NULL; + } + if ((colDepth=vl_video_init(width, height, colDepth, rgbFlag, refresh)) <= 0) { + return NULL; + } +#else /* FX */ + if (!rgbFlag) { + return NULL; + } else { + char *env; + + if ((env = getenv("MESA_FX_INFO")) && (env[0] == 'r')) { + freopen("MESA.LOG", "w", stderr); + } + + if (refresh && (((env = getenv("FX_GLIDE_REFRESH")) == NULL) || !atoi(env))) { + /* if we are passed non-zero value for refresh, we need to override + * default refresh rate. However, if FX_GLIDE_REFRESH is already set + * to 0, we won't override it, because it has a special meaning for + * DJGPP Glide3x (switch via VESA, using BIOS default refresh). + */ + char tmp[32]; + sprintf(tmp, "FX_GLIDE_REFRESH=%u", refresh); + putenv(tmp); + } + } +#endif /* FX */ + + if ((v=(DMesaVisual)CALLOC_STRUCT(dmesa_visual)) != NULL) { + /* Create core visual */ + _mesa_initialize_visual((GLvisual *)v, + rgbFlag, /* rgb */ + dbFlag, + GL_FALSE, /* stereo */ + redBits, + greenBits, + blueBits, + alphaBits, + indexBits, /* indexBits */ + depthSize, + stencilSize, + accumSize, /* accumRed */ + accumSize, /* accumGreen */ + accumSize, /* accumBlue */ + alphaBits?accumSize:0, /* accumAlpha */ + 1); /* numSamples */ + +#ifndef FX + v->sw_alpha = sw_alpha; + v->z_buffer = (depthSize > 0) ? 1 : 0; +#endif + } + + return v; +} + + +void +DMesaDestroyVisual (DMesaVisual v) +{ +#ifndef FX + vl_video_exit(); +#endif + _mesa_destroy_visual((GLvisual *)v); +} + + +DMesaBuffer +DMesaCreateBuffer (DMesaVisual visual, + GLint xpos, GLint ypos, + GLint width, GLint height) +{ +#ifndef FX + DMesaBuffer b; + + if ((b=(DMesaBuffer)CALLOC_STRUCT(dmesa_buffer)) != NULL) { + _mesa_initialize_framebuffer((GLframebuffer *)b, + (GLvisual *)visual, + visual->z_buffer == 1, + ((GLvisual *)visual)->stencilBits > 0, + ((GLvisual *)visual)->accumRedBits > 0, + visual->sw_alpha); + b->xpos = xpos; + b->ypos = ypos; + b->width = width; + b->height = height; + } + + return b; +#else /* FX */ + + GLvisual *v = (GLvisual *)visual; + int i = 0, fx_attrib[32]; + + if (v->doubleBufferMode) fx_attrib[i++] = FXMESA_DOUBLEBUFFER; + if (v->depthBits > 0) { fx_attrib[i++] = FXMESA_DEPTH_SIZE; fx_attrib[i++] = v->depthBits; } + if (v->stencilBits > 0) { fx_attrib[i++] = FXMESA_STENCIL_SIZE; fx_attrib[i++] = v->stencilBits; } + if (v->accumRedBits > 0) { fx_attrib[i++] = FXMESA_ACCUM_SIZE; fx_attrib[i++] = v->accumRedBits; } + if (v->alphaBits) { fx_attrib[i++] = FXMESA_ALPHA_SIZE; fx_attrib[i++] = v->alphaBits; } + fx_attrib[i++] = FXMESA_COLORDEPTH; + fx_attrib[i++] = v->redBits + v->greenBits + v->blueBits; + fx_attrib[i] = FXMESA_NONE; + + return (DMesaBuffer)fxMesaCreateBestContext(-1, width, height, fx_attrib); +#endif /* FX */ +} + + +void +DMesaDestroyBuffer (DMesaBuffer b) +{ +#ifndef FX + if (b->the_window != NULL) { + free(b->the_window); + } + _mesa_destroy_framebuffer((GLframebuffer *)b); +#else + fxMesaDestroyContext((fxMesaContext)b); +#endif +} + + +DMesaContext +DMesaCreateContext (DMesaVisual visual, DMesaContext share) +{ + GLcontext *c; +#ifndef FX + TNLcontext *tnl; + struct dd_function_table functions; + + if ((c=(GLcontext *)CALLOC_STRUCT(dmesa_context)) != NULL) { + /* Initialize device driver function table */ + _mesa_init_driver_functions(&functions); + /* override with our functions */ + dmesa_init_driver_functions(visual, &functions); + + _mesa_initialize_context(c, + (GLvisual *)visual, + (GLcontext *)share, + &functions, + (void *)c); + + _mesa_enable_sw_extensions(c); + _mesa_enable_1_3_extensions(c); + _mesa_enable_1_4_extensions(c); + _mesa_enable_1_5_extensions(c); + _mesa_enable_2_0_extensions(c); +#if SWTC + if (c->Mesa_DXTn) { + _mesa_enable_extension(c, "GL_EXT_texture_compression_s3tc"); + _mesa_enable_extension(c, "GL_S3_s3tc"); + } + _mesa_enable_extension(c, "GL_3DFX_texture_compression_FXT1"); +#endif + + /* you probably have to do a bunch of other initializations here. */ + ((DMesaContext)c)->visual = visual; + + /* Initialize the software rasterizer and helper modules. + */ + _swrast_CreateContext(c); + _ac_CreateContext(c); + _tnl_CreateContext(c); + _swsetup_CreateContext(c); + /* tnl setup */ + tnl = TNL_CONTEXT(c); + tnl->Driver.RunPipeline = _tnl_run_pipeline; + /* swrast setup */ + if (((GLvisual *)visual)->rgbMode) dmesa_register_swrast_functions(c); + dmesa_init_pointers(c); + _swsetup_Wakeup(c); + } + +#else /* FX */ + c = (GLcontext *)0xdeadbeef; +#endif /* FX */ + + return (DMesaContext)c; +} + + +void +DMesaDestroyContext (DMesaContext c) +{ +#ifndef FX + if (c) { + _swsetup_DestroyContext((GLcontext *)c); + _swrast_DestroyContext((GLcontext *)c); + _tnl_DestroyContext((GLcontext *)c); + _ac_DestroyContext((GLcontext *)c); + _mesa_destroy_context((GLcontext *)c); + } +#endif +} + + +GLboolean +DMesaMoveBuffer (GLint xpos, GLint ypos) +{ +#ifndef FX + GET_CURRENT_CONTEXT(ctx); + DMesaBuffer b = ((DMesaContext)ctx)->buffer; + + if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) == 0) { + b->xpos = xpos; + b->ypos = ypos; + return GL_TRUE; + } +#endif + + return GL_FALSE; +} + + +GLboolean +DMesaResizeBuffer (GLint width, GLint height) +{ +#ifndef FX + GET_CURRENT_CONTEXT(ctx); + DMesaBuffer b = ((DMesaContext)ctx)->buffer; + + if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) == 0) { + b->width = width; + b->height = height; + return GL_TRUE; + } +#endif + + return GL_FALSE; +} + + +/* + * Make the specified context and buffer the current one. + */ +GLboolean +DMesaMakeCurrent (DMesaContext c, DMesaBuffer b) +{ +#ifndef FX + if ((c != NULL) && (b != NULL)) { + if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, b->width, b->height) != 0) { + return GL_FALSE; + } + + c->buffer = b; + + _mesa_make_current((GLcontext *)c, (GLframebuffer *)b); + } + else { + /* Detach */ + _mesa_make_current(NULL, NULL); + } + +#else + fxMesaMakeCurrent((fxMesaContext)b); +#endif + + return GL_TRUE; +} + + +void +DMesaSwapBuffers (DMesaBuffer b) +{ + /* copy/swap back buffer to front if applicable */ +#ifndef FX + GET_CURRENT_CONTEXT(ctx); + _mesa_notifySwapBuffers(ctx); + vl_flip(); +#else + fxMesaSwapBuffers(); +#endif +} + + +void +DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue) +{ +#ifndef FX + vl_setCI(ndx, red, green, blue); +#endif +} + + +DMesaContext +DMesaGetCurrentContext (void) +{ + GET_CURRENT_CONTEXT(ctx); + +#ifndef FX +#else + if (ctx != NULL) { + ctx = (GLcontext *)0xdeadbeef; + } +#endif + + return (DMesaContext)ctx; +} + + +DMesaBuffer +DMesaGetCurrentBuffer (void) +{ + const DMesaContext dmesa = DMesaGetCurrentContext(); + + if (dmesa == NULL) { + return NULL; + } + +#ifndef FX + return dmesa->buffer; +#else + return (DMesaBuffer)fxMesaGetCurrentContext(); +#endif +} + + +DMesaProc +DMesaGetProcAddress (const char *name) +{ + DMesaProc p = (DMesaProc)_glapi_get_proc_address(name); + + /* TODO: handle DMesa* namespace + if (p == NULL) { + } + */ + + return p; +} + + +int +DMesaGetIntegerv (GLenum pname, GLint *params) +{ + switch (pname) { + case DMESA_GET_SCREEN_SIZE: + #ifndef FX + vl_get(VL_GET_SCREEN_SIZE, params); + #else + fxGetScreenGeometry(¶ms[0], ¶ms[1]); + #endif + break; + case DMESA_GET_DRIVER_CAPS: + #ifndef FX + params[0] = DMESA_DRIVER_SWDB_BIT; + #else + params[0] = DMESA_DRIVER_LLWO_BIT; + #endif + break; + case DMESA_GET_VIDEO_MODES: + #ifndef FX + return vl_get(VL_GET_VIDEO_MODES, params); + #else + return -1; /* TODO */ + #endif + case DMESA_GET_BUFFER_ADDR: { + #ifndef FX + DMesaContext c = (DMesaContext)DMesaGetCurrentContext(); + if (c != NULL) { + DMesaBuffer b = c->buffer; + if (b != NULL) { + params[0] = (GLint)b->the_window; + } + } + break; + #else + return -1; + #endif + } + default: + return -1; + } + + return 0; +} + + +#if SWTC && (((__DJGPP__ << 8) | __DJGPP_MINOR__) >= 0x204) +#include <sys/dxe.h> + +extern_asm(___dj_assert); +extern_asm(_free); +extern_asm(_malloc); +extern_asm(_memset); + +DXE_EXPORT_TABLE_AUTO (___dxe_eta___dxtn) + DXE_EXPORT_ASM (___dj_assert) + DXE_EXPORT_ASM (_free) + DXE_EXPORT_ASM (_malloc) + DXE_EXPORT_ASM (_memset) +DXE_EXPORT_END +#endif diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/dpmi.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/dpmi.c new file mode 100644 index 000000000..b2cef04ac --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/dpmi.c @@ -0,0 +1,166 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.5 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@yahoo.com + * Web : http://www.geocities.com/dborca + */ + + +#include <dpmi.h> + +#include "internal.h" + + +#ifndef MAX +#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +#endif + + +/* _create_linear_mapping: + * Maps a physical address range into linear memory. + */ +int +_create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size) +{ + __dpmi_meminfo meminfo; + + if (physaddr >= 0x100000) { + /* map into linear memory */ + meminfo.address = physaddr; + meminfo.size = size; + if (__dpmi_physical_address_mapping(&meminfo) != 0) { + return -1; + } + + *linear = meminfo.address; + } else { + /* exploit 1 -> 1 physical to linear mapping in low megabyte */ + *linear = physaddr; + } + + return 0; +} + + +/* _remove_linear_mapping: + * Frees the DPMI resources being used to map a linear address range. + */ +void +_remove_linear_mapping (unsigned long *linear) +{ + __dpmi_meminfo meminfo; + + if (*linear) { + if (*linear >= 0x100000) { + meminfo.address = *linear; + __dpmi_free_physical_address_mapping(&meminfo); + } + + *linear = 0; + } +} + + +/* _create_selector: + * Allocates a selector to access a region of linear memory. + */ +int +_create_selector (int *segment, unsigned long base, int size) +{ + /* allocate an ldt descriptor */ + if ((*segment=__dpmi_allocate_ldt_descriptors(1)) < 0) { + *segment = 0; + return -1; + } + + /* create the linear mapping */ + if (_create_linear_mapping(&base, base, size)) { + __dpmi_free_ldt_descriptor(*segment); + *segment = 0; + return -1; + } + + /* set the descriptor base and limit */ + __dpmi_set_segment_base_address(*segment, base); + __dpmi_set_segment_limit(*segment, MAX(size-1, 0xFFFF)); + + return 0; +} + + +/* _remove_selector: + * Frees a DPMI segment selector. + */ +void +_remove_selector (int *segment) +{ + if (*segment) { + unsigned long base; + __dpmi_get_segment_base_address(*segment, &base); + _remove_linear_mapping(&base); + __dpmi_free_ldt_descriptor(*segment); + *segment = 0; + } +} + + +/* Desc: retrieve CPU MMX capability + * + * In : - + * Out : FALSE if CPU cannot do MMX + * + * Note: - + */ +int +_can_mmx (void) +{ +#ifdef USE_MMX_ASM + int x86_cpu_features = 0; + __asm("\n\ + pushfl \n\ + popl %%eax \n\ + movl %%eax, %%ecx \n\ + xorl $0x200000, %%eax\n\ + pushl %%eax \n\ + popfl \n\ + pushfl \n\ + popl %%eax \n\ + pushl %%ecx \n\ + popfl \n\ + xorl %%ecx, %%eax \n\ + jz 0f \n\ + movl $1, %%eax \n\ + cpuid \n\ + movl %%edx, %0 \n\ + 0: \n\ + ":"=g"(x86_cpu_features)::"%eax", "%ebx", "%ecx", "%edx"); + return (x86_cpu_features & 0x00800000); +#else + return 0; +#endif +} diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/internal.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/internal.h new file mode 100644 index 000000000..85b94d377 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/internal.h @@ -0,0 +1,131 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.6 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@users.sourceforge.net + * Web : http://www.geocities.com/dborca + */ + + +#ifndef INTERNAL_H_included +#define INTERNAL_H_included + +#include "../main/mtypes.h" + + +/* + * general purpose defines, etc. + */ +#ifndef FALSE +#define FALSE 0 +#define TRUE !FALSE +#endif + +#define __PACKED__ __attribute__((packed)) + +typedef unsigned char word8; +typedef unsigned short word16; +typedef unsigned long word32; + +#define _16_ *(word16 *)& +#define _32_ *(word32 *)& + + +/* + * video mode structure + */ +typedef struct vl_mode { + int xres, yres; + int bpp; + + int mode; + int scanlen; + + int sel; + int gran; +} vl_mode; + + +/* + * video driver structure + */ +typedef struct { + vl_mode *(*init) (void); + int (*entermode) (vl_mode *p, int refresh); + void (*blit) (void); + void (*setCI_f) (int index, float red, float green, float blue); + void (*setCI_i) (int index, int red, int green, int blue); + int (*get) (int pname, int *params); + void (*restore) (void); + void (*fini) (void); +} vl_driver; + + +/* + * memory mapping + */ +int _create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size); +void _remove_linear_mapping (unsigned long *linear); +int _create_selector (int *segment, unsigned long base, int size); +void _remove_selector (int *segment); + + +/* + * system routines + */ +int _can_mmx (void); + + +/* + * asm routines to deal with virtual buffering + */ +extern void v_clear8 (int color); +#define v_clear15 v_clear16 +extern void v_clear16 (int color); +extern void v_clear24 (int color); +extern void v_clear32 (int color); + +extern void v_clear8_mmx (int color); +#define v_clear15_mmx v_clear16_mmx +extern void v_clear16_mmx (int color); +extern void v_clear24_mmx (int color); +extern void v_clear32_mmx (int color); + +extern void v_rect8 (int x, int y, int width, int height, int color); +#define v_rect15 v_rect16 +extern void v_rect16 (int x, int y, int width, int height, int color); +extern void v_rect24 (int x, int y, int width, int height, int color); +extern void v_rect32 (int x, int y, int width, int height, int color); + +extern void v_putpixel8 (unsigned int offset, int color); +#define v_putpixel15 v_putpixel16 +extern void v_putpixel16 (unsigned int offset, int color); +extern void v_putpixel24 (unsigned int offset, int color); +extern void v_putpixel32 (unsigned int offset, int color); + + +#endif diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/null.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/null.c new file mode 100644 index 000000000..369255a42 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/null.c @@ -0,0 +1,224 @@ +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.7 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@users.sourceforge.net + * Web : http://www.geocities.com/dborca + */ + + +#include <stdlib.h> +#include <sys/segments.h> + +#include "video.h" +#include "null.h" + + +static vl_mode *modes; + +#define null_color_precision 8 + + +static void +null_blit_nop (void) +{ +} + + +/* Desc: Attempts to detect NUL, check video modes and create selectors. + * + * In : - + * Out : mode array + * + * Note: - + */ +static vl_mode * +null_init (void) +{ + static int m[][2] = { + { 320, 200 }, + { 320, 240 }, + { 400, 300 }, + { 512, 384 }, + { 640, 400 }, + { 640, 480 }, + { 800, 600 }, + { 1024, 768 }, + { 1280, 1024 }, + { 1600, 1200 } + }; + static int b[] = { + 8, + 15, + 16, + 24, + 32 + }; + const unsigned int m_count = sizeof(m) / sizeof(m[0]); + const unsigned int b_count = sizeof(b) / sizeof(b[0]); + + unsigned int i, j, k; + + if (modes == NULL) { + modes = malloc(sizeof(vl_mode) * (1 + m_count * b_count)); + + if (modes != NULL) { + for (k = 0, i = 0; i < m_count; i++) { + for (j = 0; j < b_count; j++, k++) { + modes[k].xres = m[i][0]; + modes[k].yres = m[i][1]; + modes[k].bpp = b[j]; + modes[k].mode = 0x4000; + modes[k].scanlen = m[i][0] * ((b[j] + 7) / 8); + modes[k].sel = -1; + modes[k].gran = -1; + } + } + modes[k].xres = -1; + modes[k].yres = -1; + modes[k].bpp = -1; + modes[k].mode = 0xffff; + modes[k].scanlen = -1; + modes[k].sel = -1; + modes[k].gran = -1; + } + } + + return modes; +} + + +/* Desc: Frees all resources allocated by NUL init code. + * + * In : - + * Out : - + * + * Note: - + */ +static void +null_fini (void) +{ + if (modes != NULL) { + free(modes); + modes = NULL; + } +} + + +/* Desc: Attempts to enter specified video mode. + * + * In : ptr to mode structure, refresh rate + * Out : 0 if success + * + * Note: - + */ +static int +null_entermode (vl_mode *p, int refresh) +{ + NUL.blit = null_blit_nop; + + return 0; + + (void)(p && refresh); /* silence compiler warning */ +} + + +/* Desc: Restores to the mode prior to first call to null_entermode. + * + * In : - + * Out : - + * + * Note: - + */ +static void +null_restore (void) +{ +} + + +/* Desc: set one palette entry + * + * In : color index, R, G, B + * Out : - + * + * Note: uses integer values + */ +static void +null_setCI_i (int index, int red, int green, int blue) +{ + (void)(index && red && green && blue); /* silence compiler warning */ +} + + +/* Desc: set one palette entry + * + * In : color index, R, G, B + * Out : - + * + * Note: uses normalized values + */ +static void +null_setCI_f (int index, float red, float green, float blue) +{ + float max = (1 << null_color_precision) - 1; + + null_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max)); +} + + +/* Desc: state retrieval + * + * In : parameter name, ptr to storage + * Out : 0 if request successfully processed + * + * Note: - + */ +static int +null_get (int pname, int *params) +{ + switch (pname) { + default: + params[0] = params[0]; /* silence compiler warning */ + return -1; + } + return 0; +} + + +/* + * the driver + */ +vl_driver NUL = { + null_init, + null_entermode, + NULL, + null_setCI_f, + null_setCI_i, + null_get, + null_restore, + null_fini +}; diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/null.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/null.h new file mode 100644 index 000000000..a38accc85 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/null.h @@ -0,0 +1,41 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.6 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@yahoo.com + * Web : http://www.geocities.com/dborca + */ + + +#ifndef NULL_H_included +#define NULL_H_included + +#include "internal.h" + +extern vl_driver NUL; + +#endif diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vesa.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vesa.c new file mode 100644 index 000000000..cd48a24bf --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vesa.c @@ -0,0 +1,531 @@ +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.6 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@users.sourceforge.net + * Web : http://www.geocities.com/dborca + */ + + +#include <dpmi.h> +#include <pc.h> +#include <stdlib.h> +#include <stubinfo.h> +#include <sys/exceptn.h> +#include <sys/segments.h> +#include <sys/farptr.h> +#include <sys/movedata.h> + +#include "video.h" +#include "vesa.h" + + +static vl_mode modes[128]; + +static word16 vesa_ver; +static int banked_selector, linear_selector; +static int oldmode = -1; + +static int vesa_color_precision = 6; + +static word16 *vesa_pmcode; +unsigned int vesa_gran_mask, vesa_gran_shift; + + +/* + * VESA info + */ +#define V_SIGN 0 +#define V_MINOR 4 +#define V_MAJOR 5 +#define V_OEM_OFS 6 +#define V_OEM_SEG 8 +#define V_MODE_OFS 14 +#define V_MODE_SEG 16 +#define V_MEMORY 18 + +/* + * mode info + */ +#define M_ATTR 0 +#define M_GRAN 4 +#define M_SCANLEN 16 +#define M_XRES 18 +#define M_YRES 20 +#define M_BPP 25 +#define M_RED 31 +#define M_GREEN 33 +#define M_BLUE 35 +#define M_PHYS_PTR 40 + +/* + * VESA 3.0 CRTC timings structure + */ +typedef struct CRTCInfoBlock { + unsigned short HorizontalTotal; + unsigned short HorizontalSyncStart; + unsigned short HorizontalSyncEnd; + unsigned short VerticalTotal; + unsigned short VerticalSyncStart; + unsigned short VerticalSyncEnd; + unsigned char Flags; + unsigned long PixelClock; /* units of Hz */ + unsigned short RefreshRate; /* units of 0.01 Hz */ + unsigned char reserved[40]; +} __PACKED__ CRTCInfoBlock; + +#define HNEG (1 << 2) +#define VNEG (1 << 3) +#define DOUBLESCAN (1 << 0) + + +/* Desc: Attempts to detect VESA, check video modes and create selectors. + * + * In : - + * Out : mode array + * + * Note: - + */ +static vl_mode * +vesa_init (void) +{ + __dpmi_regs r; + word16 *p; + vl_mode *q; + char vesa_info[512], tmp[512]; + int maxsize = 0; + word32 linearfb = 0; + + if (vesa_ver) { + return modes; + } + + _farpokel(_stubinfo->ds_selector, 0, 0x32454256); + r.x.ax = 0x4f00; + r.x.di = 0; + r.x.es = _stubinfo->ds_segment; + __dpmi_int(0x10, &r); + movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512); + if ((r.x.ax != 0x004f) || ((_32_ vesa_info[V_SIGN]) != 0x41534556)) { + return NULL; + } + + p = (word16 *)(((_16_ vesa_info[V_MODE_SEG])<<4) + (_16_ vesa_info[V_MODE_OFS])); + q = modes; + do { + if ((q->mode=_farpeekw(__djgpp_dos_sel, (unsigned long)(p++))) == 0xffff) { + break; + } + + r.x.ax = 0x4f01; + r.x.cx = q->mode; + r.x.di = 512; + r.x.es = _stubinfo->ds_segment; + __dpmi_int(0x10, &r); + movedata(_stubinfo->ds_selector, 512, _my_ds(), (unsigned)tmp, 256); + switch (tmp[M_BPP]) { + case 16: + q->bpp = tmp[M_RED] + tmp[M_GREEN] + tmp[M_BLUE]; + break; + case 8: + case 15: + case 24: + case 32: + q->bpp = tmp[M_BPP]; + break; + default: + q->bpp = 0; + } + if ((r.x.ax == 0x004f) && ((tmp[M_ATTR] & 0x11) == 0x11) && q->bpp) { + q->xres = _16_ tmp[M_XRES]; + q->yres = _16_ tmp[M_YRES]; + q->scanlen = _16_ tmp[M_SCANLEN]; + q->gran = (_16_ tmp[M_GRAN])<<10; + if (tmp[M_ATTR] & 0x80) { + vl_mode *q1 = q + 1; + *q1 = *q++; + linearfb = _32_ tmp[M_PHYS_PTR]; + q->mode |= 0x4000; + } + if (maxsize < (q->scanlen * q->yres)) { + maxsize = q->scanlen * q->yres; + } + q++; + } + } while (TRUE); + + if (q == modes) { + return NULL; + } + if (linearfb) { + maxsize = (maxsize + 0xfffUL) & ~0xfffUL; + if (_create_selector(&linear_selector, linearfb, maxsize)) { + return NULL; + } + } + if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) { + _remove_selector(&linear_selector); + return NULL; + } + + for (q = modes; q->mode != 0xffff; q++) { + q->sel = (q->mode & 0x4000) ? linear_selector : banked_selector; + } + + if (vesa_info[V_MAJOR] >= 2) { + r.x.ax = 0x4f0a; + r.x.bx = 0; + __dpmi_int(0x10, &r); + if (r.x.ax == 0x004f) { + vesa_pmcode = (word16 *)malloc(r.x.cx); + if (vesa_pmcode != NULL) { + movedata(__djgpp_dos_sel, (r.x.es << 4) + r.x.di, _my_ds(), (unsigned)vesa_pmcode, r.x.cx); + if (vesa_pmcode[3]) { + p = (word16 *)((long)vesa_pmcode + vesa_pmcode[3]); + while (*p++ != 0xffff) { + } + } else { + p = NULL; + } + if (p && (*p != 0xffff)) { + free(vesa_pmcode); + vesa_pmcode = NULL; + } else { + vesa_swbank = (void *)((long)vesa_pmcode + vesa_pmcode[0]); + } + } + } + } + + vesa_ver = _16_ vesa_info[V_MINOR]; + return modes; +} + + +/* Desc: Frees all resources allocated by VESA init code. + * + * In : - + * Out : - + * + * Note: - + */ +static void +vesa_fini (void) +{ + if (vesa_ver) { + _remove_selector(&linear_selector); + _remove_selector(&banked_selector); + if (vesa_pmcode != NULL) { + free(vesa_pmcode); + vesa_pmcode = NULL; + } + } +} + + +/* Desc: Uses VESA 3.0 function 0x4F0B to find the closest pixel clock to the requested value. + * + * In : mode, clock + * Out : desired clock + * + * Note: - + */ +static unsigned long +_closest_pixclk (int mode_no, unsigned long vclk) +{ + __dpmi_regs r; + + r.x.ax = 0x4F0B; + r.h.bl = 0; + r.d.ecx = vclk; + r.x.dx = mode_no; + __dpmi_int(0x10, &r); + + return (r.x.ax == 0x004f) ? r.d.ecx : 0; +} + + +/* Desc: Calculates CRTC mode timings. + * + * In : crtc block, geometry, adjust + * Out : + * + * Note: + */ +static void +_crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust, int yadjust) +{ + int HTotal, VTotal; + int HDisp, VDisp; + int HSS, VSS; + int HSE, VSE; + int HSWidth, VSWidth; + int SS, SE; + int doublescan = FALSE; + + if (yres < 400) { + doublescan = TRUE; + yres *= 2; + } + + HDisp = xres; + HTotal = (int)(HDisp * 1.27) & ~0x7; + HSWidth = (int)((HTotal - HDisp) / 5) & ~0x7; + HSS = HDisp + 16; + HSE = HSS + HSWidth; + VDisp = yres; + VTotal = VDisp * 1.07; + VSWidth = (VTotal / 100) + 1; + VSS = VDisp + ((int)(VTotal - VDisp) / 5) + 1; + VSE = VSS + VSWidth; + + SS = HSS + xadjust; + SE = HSE + xadjust; + + if (xadjust < 0) { + if (SS < (HDisp + 8)) { + SS = HDisp + 8; + SE = SS + HSWidth; + } + } else { + if ((HTotal - 24) < SE) { + SE = HTotal - 24; + SS = SE - HSWidth; + } + } + + HSS = SS; + HSE = SE; + + SS = VSS + yadjust; + SE = VSE + yadjust; + + if (yadjust < 0) { + if (SS < (VDisp + 3)) { + SS = VDisp + 3; + SE = SS + VSWidth; + } + } else { + if ((VTotal - 4) < SE) { + SE = VTotal - 4; + SS = SE - VSWidth; + } + } + + VSS = SS; + VSE = SE; + + crtc->HorizontalTotal = HTotal; + crtc->HorizontalSyncStart = HSS; + crtc->HorizontalSyncEnd = HSE; + crtc->VerticalTotal = VTotal; + crtc->VerticalSyncStart = VSS; + crtc->VerticalSyncEnd = VSE; + crtc->Flags = HNEG | VNEG; + + if (doublescan) { + crtc->Flags |= DOUBLESCAN; + } +} + + +/* Desc: Attempts to enter specified video mode. + * + * In : ptr to mode structure, refresh rate + * Out : 0 if success + * + * Note: - + */ +static int +vesa_entermode (vl_mode *p, int refresh) +{ + __dpmi_regs r; + + if (p->mode & 0x4000) { + VESA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual; + } else { + VESA.blit = vesa_b_dump_virtual; + { int n; for (vesa_gran_shift=0, n=p->gran; n; vesa_gran_shift++, n>>=1) ; } + vesa_gran_mask = (1 << (--vesa_gran_shift)) - 1; + if ((unsigned)p->gran != (vesa_gran_mask+1)) { + return !0; + } + } + + if (oldmode == -1) { + r.x.ax = 0x4f03; + __dpmi_int(0x10, &r); + oldmode = r.x.bx; + } + + r.x.ax = 0x4f02; + r.x.bx = p->mode; + + if (refresh && ((vesa_ver>>8) >= 3)) { + /* VESA 3.0 stuff for controlling the refresh rate */ + CRTCInfoBlock crtc; + unsigned long vclk; + double f0; + + _crtc_timing(&crtc, p->xres, p->yres, 0, 0); + + vclk = (double)crtc.HorizontalTotal * crtc.VerticalTotal * refresh; + vclk = _closest_pixclk(p->mode, vclk); + + if (vclk != 0) { + f0 = (double)vclk / (crtc.HorizontalTotal * crtc.VerticalTotal); + /*_current_refresh_rate = (int)(f0 + 0.5);*/ + + crtc.PixelClock = vclk; + crtc.RefreshRate = refresh * 100; + + movedata(_my_ds(), (unsigned)&crtc, _stubinfo->ds_selector, 0, sizeof(crtc)); + + r.x.di = 0; + r.x.es = _stubinfo->ds_segment; + r.x.bx |= 0x0800; + } + } + + __dpmi_int(0x10, &r); + if (r.x.ax != 0x004f) { + return !0; + } + + if (p->bpp == 8) { + r.x.ax = 0x4f08; + r.x.bx = 0x0800; + __dpmi_int(0x10, &r); + if (r.x.ax == 0x004f) { + r.x.ax = 0x4f08; + r.h.bl = 0x01; + __dpmi_int(0x10, &r); + vesa_color_precision = r.h.bh; + } + } + + return 0; +} + + +/* Desc: Restores to the mode prior to first call to vesa_entermode. + * + * In : - + * Out : - + * + * Note: - + */ +static void +vesa_restore (void) +{ + __dpmi_regs r; + + if (oldmode != -1) { + r.x.ax = 0x4f02; + r.x.bx = oldmode; + __dpmi_int(0x10, &r); + oldmode = -1; + } +} + + +/* Desc: set one palette entry + * + * In : color index, R, G, B + * Out : - + * + * Note: uses integer values + */ +static void +vesa_setCI_i (int index, int red, int green, int blue) +{ +#if 0 + __asm("\n\ + movw $0x1010, %%ax \n\ + movb %1, %%dh \n\ + movb %2, %%ch \n\ + int $0x10 \n\ + "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx"); +#else + outportb(0x03C8, index); + outportb(0x03C9, red); + outportb(0x03C9, green); + outportb(0x03C9, blue); +#endif +} + + +/* Desc: set one palette entry + * + * In : color index, R, G, B + * Out : - + * + * Note: uses normalized values + */ +static void +vesa_setCI_f (int index, float red, float green, float blue) +{ + float max = (1 << vesa_color_precision) - 1; + + vesa_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max)); +} + + +/* Desc: state retrieval + * + * In : parameter name, ptr to storage + * Out : 0 if request successfully processed + * + * Note: - + */ +static int +vesa_get (int pname, int *params) +{ + switch (pname) { + case VL_GET_CI_PREC: + params[0] = vesa_color_precision; + break; + default: + return -1; + } + return 0; +} + + +/* + * the driver + */ +vl_driver VESA = { + vesa_init, + vesa_entermode, + NULL, + vesa_setCI_f, + vesa_setCI_i, + vesa_get, + vesa_restore, + vesa_fini +}; diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vesa.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vesa.h new file mode 100644 index 000000000..9287697c3 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vesa.h @@ -0,0 +1,47 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.3 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@yahoo.com + * Web : http://www.geocities.com/dborca + */ + + +#ifndef VESA_H_included +#define VESA_H_included + +#include "internal.h" + +extern void *vesa_swbank; + +extern void vesa_b_dump_virtual (void); +extern void vesa_l_dump_virtual (void); +extern void vesa_l_dump_virtual_mmx (void); + +extern vl_driver VESA; + +#endif diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vga.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vga.c new file mode 100644 index 000000000..27758f14d --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vga.c @@ -0,0 +1,250 @@ +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.7 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@users.sourceforge.net + * Web : http://www.geocities.com/dborca + */ + + +#include <pc.h> +#include <stdlib.h> + +#include "video.h" +#include "vga.h" + + +static vl_mode modes[] = { + { + /* .xres = */ 320, + /* .yres = */ 200, + /* .bpp = */ 8, + /* .mode = */ 0x13 | 0x4000, + /* .scanlen = */ 320, + /* .sel = */ -1, + /* .gran = */ 320*200 + }, + { + /* .xres = */ -1, + /* .yres = */ -1, + /* .bpp = */ -1, + /* .mode = */ 0xffff, + /* .scanlen = */ -1, + /* .sel = */ -1, + /* .gran = */ -1 + } +}; + +static word16 vga_ver; +static int linear_selector; +static int oldmode = -1; + +#define vga_color_precision 6 + + +/* Desc: Attempts to detect VGA, check video modes and create selectors. + * + * In : - + * Out : mode array + * + * Note: - + */ +static vl_mode * +vga_init (void) +{ + int rv = 0; + + if (vga_ver) { + return modes; + } + + __asm("\n\ + movw $0x1a00, %%ax \n\ + int $0x10 \n\ + cmpb $0x1a, %%al \n\ + jne 0f \n\ + cmpb $0x07, %%bl \n\ + jb 0f \n\ + andl $0xff, %%ebx \n\ + movl %%ebx, %0 \n\ + 0:":"=g"(rv)::"%eax", "%ebx"); + if (rv == 0) { + return NULL; + } + + if (_create_selector(&linear_selector, 0xa0000, 0x10000)) { + return NULL; + } + + modes[0].sel = linear_selector; + + vga_ver = rv; + return modes; +} + + +/* Desc: Frees all resources allocated by VGA init code. + * + * In : - + * Out : - + * + * Note: - + */ +static void +vga_fini (void) +{ + if (vga_ver) { + _remove_selector(&linear_selector); + } +} + + +/* Desc: Attempts to enter specified video mode. + * + * In : ptr to mode structure, refresh rate + * Out : 0 if success + * + * Note: - + */ +static int +vga_entermode (vl_mode *p, int refresh) +{ + if (!(p->mode & 0x4000)) { + return -1; + } + VGA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual; + + if (oldmode == -1) { + __asm("\n\ + movb $0x0f, %%ah \n\ + int $0x10 \n\ + andl $0xff, %%eax \n\ + movl %%eax, %0 \n\ + ":"=g"(oldmode)::"%eax", "%ebx"); + } + + __asm("int $0x10"::"a"(p->mode&0xff)); + + return 0; + + (void)refresh; /* silence compiler warning */ +} + + +/* Desc: Restores to the mode prior to first call to vga_entermode. + * + * In : - + * Out : - + * + * Note: - + */ +static void +vga_restore (void) +{ + if (oldmode != -1) { + __asm("int $0x10"::"a"(oldmode)); + oldmode = -1; + } +} + + +/* Desc: set one palette entry + * + * In : color index, R, G, B + * Out : - + * + * Note: uses integer values + */ +static void +vga_setCI_i (int index, int red, int green, int blue) +{ +#if 0 + __asm("\n\ + movw $0x1010, %%ax \n\ + movb %1, %%dh \n\ + movb %2, %%ch \n\ + int $0x10 \n\ + "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx"); +#else + outportb(0x03C8, index); + outportb(0x03C9, red); + outportb(0x03C9, green); + outportb(0x03C9, blue); +#endif +} + + +/* Desc: set one palette entry + * + * In : color index, R, G, B + * Out : - + * + * Note: uses normalized values + */ +static void +vga_setCI_f (int index, float red, float green, float blue) +{ + float max = (1 << vga_color_precision) - 1; + + vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max)); +} + + +/* Desc: state retrieval + * + * In : parameter name, ptr to storage + * Out : 0 if request successfully processed + * + * Note: - + */ +static int +vga_get (int pname, int *params) +{ + switch (pname) { + case VL_GET_CI_PREC: + params[0] = vga_color_precision; + break; + default: + return -1; + } + return 0; +} + + +/* + * the driver + */ +vl_driver VGA = { + vga_init, + vga_entermode, + NULL, + vga_setCI_f, + vga_setCI_i, + vga_get, + vga_restore, + vga_fini +}; diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vga.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vga.h new file mode 100644 index 000000000..aeb8fadda --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/vga.h @@ -0,0 +1,42 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.3 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@yahoo.com + * Web : http://www.geocities.com/dborca + */ + + +#ifndef VGA_H_included +#define VGA_H_included + +#include "internal.h" +#include "vesa.h" + +extern vl_driver VGA; + +#endif diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/video.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/video.c new file mode 100644 index 000000000..60370afc8 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/video.c @@ -0,0 +1,669 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.6 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@users.sourceforge.net + * Web : http://www.geocities.com/dborca + * + * Thanks to CrazyPyro (Neil Funk) for FakeColor + */ + + +#include <stdlib.h> + +#include "internal.h" +#include "vesa.h" +#include "vga.h" +#include "null.h" +#include "video.h" + + +static vl_driver *drv; +/* based upon mode specific data: valid entire session */ +int vl_video_selector; +static vl_mode *video_mode; +static int video_scanlen, video_bypp; +/* valid until next buffer */ +void *vl_current_draw_buffer, *vl_current_read_buffer; +int vl_current_stride, vl_current_width, vl_current_height, vl_current_bytes; +int vl_current_offset, vl_current_delta; + + +#if HUGE_LOOKUP +/* These lookup tables are used to extract RGB values in [0,255] + * from 15/16-bit pixel values. + */ +static unsigned char pix15r[0x8000]; +static unsigned char pix15g[0x8000]; +static unsigned char pix15b[0x8000]; +static unsigned char pix16r[0x10000]; +static unsigned char pix16g[0x10000]; +static unsigned char pix16b[0x10000]; +#else +/* lookup table for scaling 5 bit colors up to 8 bits */ +static int _rgb_scale_5[32] = { + 0, 8, 16, 25, 33, 41, 49, 58, + 66, 74, 82, 90, 99, 107, 115, 123, + 132, 140, 148, 156, 165, 173, 181, 189, + 197, 206, 214, 222, 230, 239, 247, 255 +}; +#endif + +/* lookup table for scaling 6 bit colors up to 8 bits */ +static int _rgb_scale_6[64] = { + 0, 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 45, 49, 53, 57, 61, + 65, 69, 73, 77, 81, 85, 89, 93, + 97, 101, 105, 109, 113, 117, 121, 125, + 130, 134, 138, 142, 146, 150, 154, 158, + 162, 166, 170, 174, 178, 182, 186, 190, + 194, 198, 202, 206, 210, 215, 219, 223, + 227, 231, 235, 239, 243, 247, 251, 255 +}; + +/* FakeColor data */ +#define R_CNT 6 +#define G_CNT 6 +#define B_CNT 6 + +#define R_BIAS 7 +#define G_BIAS 7 +#define B_BIAS 7 + +static word32 VGAPalette[256]; +static word8 array_r[256]; +static word8 array_g[256]; +static word8 array_b[256]; + + +int (*vl_mixfix) (fixed r, fixed g, fixed b); +int (*vl_mixrgb) (const unsigned char rgb[]); +int (*vl_mixrgba) (const unsigned char rgba[]); +void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]); +int (*vl_getpixel) (unsigned int offset); +void (*vl_clear) (int color); +void (*vl_rect) (int x, int y, int width, int height, int color); +void (*vl_flip) (void); +void (*vl_putpixel) (unsigned int offset, int color); + + +/* Desc: color composition (w/o ALPHA) + * + * In : R, G, B + * Out : color + * + * Note: - + */ +static int +vl_mixfix8fake (fixed r, fixed g, fixed b) +{ + return array_b[b>>FIXED_SHIFT]*G_CNT*R_CNT + + array_g[g>>FIXED_SHIFT]*R_CNT + + array_r[r>>FIXED_SHIFT]; +} +#define vl_mixfix8 vl_mixfix8fake +static int +vl_mixfix15 (fixed r, fixed g, fixed b) +{ + return ((r>>(3+FIXED_SHIFT))<<10) + |((g>>(3+FIXED_SHIFT))<<5) + | (b>>(3+FIXED_SHIFT)); +} +static int +vl_mixfix16 (fixed r, fixed g, fixed b) +{ + return ((r>>(3+FIXED_SHIFT))<<11) + |((g>>(2+FIXED_SHIFT))<<5) + | (b>>(3+FIXED_SHIFT)); +} +#define vl_mixfix24 vl_mixfix32 +static int +vl_mixfix32 (fixed r, fixed g, fixed b) +{ + return ((r>>FIXED_SHIFT)<<16) + |((g>>FIXED_SHIFT)<<8) + | (b>>FIXED_SHIFT); +} + + +/* Desc: color composition (w/ ALPHA) + * + * In : array of integers (R, G, B, A) + * Out : color + * + * Note: - + */ +#define vl_mixrgba8 vl_mixrgb8fake +#define vl_mixrgba15 vl_mixrgb15 +#define vl_mixrgba16 vl_mixrgb16 +#define vl_mixrgba24 vl_mixrgb24 +static int +vl_mixrgba32 (const unsigned char rgba[]) +{ + /* Hack alert: + * currently, DMesa uses Mesa's alpha buffer; + * so we don't really care about alpha value here... + */ + return /*(rgba[3]<<24) | */(rgba[0]<<16) | (rgba[1]<<8) | (rgba[2]); +} + + +/* Desc: color composition (w/o ALPHA) + * + * In : array of integers (R, G, B) + * Out : color + * + * Note: - + */ +static int +vl_mixrgb8fake (const unsigned char rgb[]) +{ + return array_b[rgb[2]]*G_CNT*R_CNT + + array_g[rgb[1]]*R_CNT + + array_r[rgb[0]]; +} +#define vl_mixrgb8 vl_mixrgb8fake +static int +vl_mixrgb15 (const unsigned char rgb[]) +{ + return ((rgb[0]>>3)<<10) | ((rgb[1]>>3)<<5) | (rgb[2]>>3); +} +static int +vl_mixrgb16 (const unsigned char rgb[]) +{ + return ((rgb[0]>>3)<<11) | ((rgb[1]>>2)<<5) | (rgb[2]>>3); +} +#define vl_mixrgb24 vl_mixrgb32 +static int +vl_mixrgb32 (const unsigned char rgb[]) +{ + return (rgb[0]<<16) | (rgb[1]<<8) | (rgb[2]); +} + + +/* Desc: color decomposition + * + * In : pixel offset, array of integers to hold color components (R, G, B, A) + * Out : - + * + * Note: uses current read buffer + */ +static void +v_getrgba8fake6 (unsigned int offset, unsigned char rgba[4]) +{ + word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]]; + rgba[0] = _rgb_scale_6[(c >> 16) & 0x3F]; + rgba[1] = _rgb_scale_6[(c >> 8) & 0x3F]; + rgba[2] = _rgb_scale_6[ c & 0x3F]; + /*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */ +} +static void +v_getrgba8fake8 (unsigned int offset, unsigned char rgba[4]) +{ + word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]]; + rgba[0] = c >> 16; + rgba[1] = c >> 8; + rgba[2] = c; + /*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */ +} +#define v_getrgba8 v_getrgba8fake6 +static void +v_getrgba15 (unsigned int offset, unsigned char rgba[4]) +{ + word32 c = ((word16 *)vl_current_read_buffer)[offset]; +#if HUGE_LOOKUP + c &= 0x7fff; + rgba[0] = pix15r[c]; + rgba[1] = pix15g[c]; + rgba[2] = pix15b[c]; +#else + rgba[0] = _rgb_scale_5[(c >> 10) & 0x1F]; + rgba[1] = _rgb_scale_5[(c >> 5) & 0x1F]; + rgba[2] = _rgb_scale_5[ c & 0x1F]; +#endif + /*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */ +} +static void +v_getrgba16 (unsigned int offset, unsigned char rgba[4]) +{ + word32 c = ((word16 *)vl_current_read_buffer)[offset]; +#if HUGE_LOOKUP + rgba[0] = pix16r[c]; + rgba[1] = pix16g[c]; + rgba[2] = pix16b[c]; +#else + rgba[0] = _rgb_scale_5[(c >> 11) & 0x1F]; + rgba[1] = _rgb_scale_6[(c >> 5) & 0x3F]; + rgba[2] = _rgb_scale_5[ c & 0x1F]; +#endif + /*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */ +} +static void +v_getrgba24 (unsigned int offset, unsigned char rgba[4]) +{ + word32 c = *(word32 *)((long)vl_current_read_buffer+offset*3); + rgba[0] = c >> 16; + rgba[1] = c >> 8; + rgba[2] = c; + /*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */ +} +static void +v_getrgba32 (unsigned int offset, unsigned char rgba[4]) +{ + word32 c = ((word32 *)vl_current_read_buffer)[offset]; + rgba[0] = c >> 16; + rgba[1] = c >> 8; + rgba[2] = c; + /*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */ +} + + +/* Desc: pixel retrieval + * + * In : pixel offset + * Out : pixel value + * + * Note: uses current read buffer + */ +static int +v_getpixel8 (unsigned int offset) +{ + return ((word8 *)vl_current_read_buffer)[offset]; +} +#define v_getpixel15 v_getpixel16 +static int +v_getpixel16 (unsigned int offset) +{ + return ((word16 *)vl_current_read_buffer)[offset]; +} +static int +v_getpixel24 (unsigned int offset) +{ + return *(word32 *)((long)vl_current_read_buffer+offset*3); +} +static int +v_getpixel32 (unsigned int offset) +{ + return ((word32 *)vl_current_read_buffer)[offset]; +} + + +/* Desc: set one palette entry + * + * In : index, R, G, B + * Out : - + * + * Note: color components are in range [0.0 .. 1.0] + */ +void +vl_setCI (int index, float red, float green, float blue) +{ + drv->setCI_f(index, red, green, blue); +} + + +/* Desc: set one palette entry + * + * In : color, R, G, B + * Out : - + * + * Note: - + */ +static void +fake_setcolor (int c, int r, int g, int b) +{ + VGAPalette[c] = 0xff000000 | (r<<16) | (g<<8) | b; + + drv->setCI_i(c, r, g, b); +} + + +/* Desc: build FakeColor palette + * + * In : CI precision in bits + * Out : - + * + * Note: - + */ +static void +fake_buildpalette (int bits) +{ + double c_r, c_g, c_b; + int r, g, b, color = 0; + + double max = (1 << bits) - 1; + + for (b = 0; b < B_CNT; ++b) { + for (g = 0; g < G_CNT; ++g) { + for (r = 0; r < R_CNT; ++r) { + c_r = 0.5 + (double)r * (max-R_BIAS) / (R_CNT-1.) + R_BIAS; + c_g = 0.5 + (double)g * (max-G_BIAS) / (G_CNT-1.) + G_BIAS; + c_b = 0.5 + (double)b * (max-B_BIAS) / (B_CNT-1.) + B_BIAS; + fake_setcolor(color++, (int)c_r, (int)c_g, (int)c_b); + } + } + } + + for (color = 0; color < 256; color++) { + c_r = (double)color * R_CNT / 256.; + c_g = (double)color * G_CNT / 256.; + c_b = (double)color * B_CNT / 256.; + array_r[color] = (int)c_r; + array_g[color] = (int)c_g; + array_b[color] = (int)c_b; + } +} + + +#if HUGE_LOOKUP +/* Desc: initialize lookup arrays + * + * In : - + * Out : - + * + * Note: - + */ +void +v_init_pixeltables (void) +{ + unsigned int pixel; + + for (pixel = 0; pixel <= 0xffff; pixel++) { + unsigned int r, g, b; + + if (pixel <= 0x7fff) { + /* 15bit */ + r = (pixel & 0x7c00) >> 8; + g = (pixel & 0x03E0) >> 3; + b = (pixel & 0x001F) << 2; + + r = (unsigned int)(((double)r * 255. / 0x7c) + 0.5); + g = (unsigned int)(((double)g * 255. / 0x7c) + 0.5); + b = (unsigned int)(((double)b * 255. / 0x7c) + 0.5); + + pix15r[pixel] = r; + pix15g[pixel] = g; + pix15b[pixel] = b; + } + + /* 16bit */ + r = (pixel & 0xF800) >> 8; + g = (pixel & 0x07E0) >> 3; + b = (pixel & 0x001F) << 3; + + r = (unsigned int)(((double)r * 255. / 0xF8) + 0.5); + g = (unsigned int)(((double)g * 255. / 0xFC) + 0.5); + b = (unsigned int)(((double)b * 255. / 0xF8) + 0.5); + + pix16r[pixel] = r; + pix16g[pixel] = g; + pix16b[pixel] = b; + } +} +#endif + + +/* Desc: initialize hardware + * + * In : - + * Out : list of available modes + * + * Note: when returning non-NULL, global variable `drv' is guaranteed to be ok + */ +static vl_mode * +v_init_hw (void) +{ + static vl_mode *q = NULL; + + if (q == NULL) { + /* are we forced to NUL driver? */ + if (getenv("DMESA_NULDRV")) { + if ((q = NUL.init()) != NULL) { + drv = &NUL; + } + return q; + } + /* initialize hardware */ + if ((q = VESA.init()) != NULL) { + drv = &VESA; + } else if ((q = VGA.init()) != NULL) { + drv = &VGA; + } else { + drv = NULL; + } + } + + return q; +} + + +/* Desc: sync buffer with video hardware + * + * In : ptr to old buffer, position, size + * Out : 0 if success + * + * Note: - + */ +int +vl_sync_buffer (void **buffer, int x, int y, int width, int height) +{ + if ((width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) { + return -1; + } else { + void *newbuf = *buffer; + + if ((newbuf == NULL) || (vl_current_width != width) || (vl_current_height != height)) { + newbuf = realloc(newbuf, width * height * video_bypp); + } + + if (newbuf == NULL) { + return -2; + } + + vl_current_width = width; + vl_current_height = height; + vl_current_stride = vl_current_width * video_bypp; + vl_current_bytes = vl_current_stride * height; + + vl_current_offset = video_scanlen * y + video_bypp * x; + vl_current_delta = video_scanlen - vl_current_stride; + + vl_current_draw_buffer = vl_current_read_buffer = *buffer = newbuf; + return 0; + } +} + + +/* Desc: state retrieval + * + * In : name, storage + * Out : -1 for an error + * + * Note: - + */ +int +vl_get (int pname, int *params) +{ + switch (pname) { + case VL_GET_SCREEN_SIZE: + params[0] = video_mode->xres; + params[1] = video_mode->yres; + break; + case VL_GET_VIDEO_MODES: { + int n; + vl_mode *q; + if ((q = v_init_hw()) == NULL) { + return -1; + } + /* count available visuals */ + for (n = 0; q->mode != 0xffff; q++) { + if ((q + 1)->mode == (q->mode | 0x4000)) { + /* same mode, but linear */ + q++; + } + if (params) { + params[n] = (int)q; + } + n++; + } + return n; + } + default: + return (drv != NULL) ? drv->get(pname, params) : -1; + } + return 0; +} + + +/* Desc: setup mode + * + * In : ptr to mode definition + * Out : 0 if success + * + * Note: - + */ +static int +vl_setup_mode (vl_mode *p) +{ + if (p == NULL) { + return -1; + } + +#define INITPTR(bpp) \ + vl_putpixel = v_putpixel##bpp; \ + vl_getrgba = v_getrgba##bpp; \ + vl_getpixel = v_getpixel##bpp; \ + vl_rect = v_rect##bpp; \ + vl_mixfix = vl_mixfix##bpp; \ + vl_mixrgb = vl_mixrgb##bpp; \ + vl_mixrgba = vl_mixrgba##bpp; \ + vl_clear = _can_mmx() ? v_clear##bpp##_mmx : v_clear##bpp + + switch (p->bpp) { + case 8: + INITPTR(8); + break; + case 15: + INITPTR(15); + break; + case 16: + INITPTR(16); + break; + case 24: + INITPTR(24); + break; + case 32: + INITPTR(32); + break; + default: + return -1; + } + +#undef INITPTR + + video_mode = p; + video_bypp = (p->bpp+7)/8; + video_scanlen = p->scanlen; + vl_video_selector = p->sel; + + return 0; +} + + +/* Desc: restore to the mode prior to first call to `vl_video_init'. + * + * In : - + * Out : - + * + * Note: - + */ +void +vl_video_exit (void) +{ + drv->restore(); + drv->fini(); + video_mode = NULL; +} + + +/* Desc: enter mode + * + * In : xres, yres, bits/pixel, RGB, refresh rate + * Out : pixel width in bits if success + * + * Note: - + */ +int +vl_video_init (int width, int height, int bpp, int rgb, int refresh) +{ + int fake; + vl_mode *p, *q; + unsigned int min; + + fake = 0; + if (!rgb) { + bpp = 8; + } else if (bpp == 8) { + fake = 1; + } +#if HUGE_LOOKUP + else if (bpp < 24) { + v_init_pixeltables(); + } +#endif + + /* initialize hardware */ + if ((q = v_init_hw()) == NULL) { + return 0; + } + + /* search for a mode that fits our request */ + for (min = -1, p = NULL; q->mode != 0xffff; q++) { + if ((q->xres >= width) && (q->yres >= height) && (q->bpp == bpp)) { + if (min >= (unsigned)(q->xres * q->yres)) { + min = q->xres * q->yres; + p = q; + } + } + } + + /* setup and enter mode */ + if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) { + vl_flip = drv->blit; + if (fake) { + drv->get(VL_GET_CI_PREC, (int *)(&min)); + fake_buildpalette(min); + if (min == 8) { + vl_getrgba = v_getrgba8fake8; + } + } + return bpp; + } + + /* abort */ + return 0; +} diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/video.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/video.h new file mode 100644 index 000000000..e928f19c3 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/video.h @@ -0,0 +1,65 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.5 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@users.sourceforge.net + * Web : http://www.geocities.com/dborca + */ + + +#ifndef VIDEO_H_included +#define VIDEO_H_included + +typedef int fixed; + +#define VL_GET_CARD_NAME 0x0100 +#define VL_GET_VRAM 0x0101 +#define VL_GET_CI_PREC 0x0200 +#define VL_GET_HPIXELS 0x0201 +#define VL_GET_SCREEN_SIZE 0x0202 +#define VL_GET_VIDEO_MODES 0x0300 + +extern int (*vl_mixfix) (fixed r, fixed g, fixed b); +extern int (*vl_mixrgb) (const unsigned char rgb[]); +extern int (*vl_mixrgba) (const unsigned char rgba[]); +extern void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]); + +extern void (*vl_clear) (int color); +extern void (*vl_rect) (int x, int y, int width, int height, int color); +extern void (*vl_flip) (void); +extern void (*vl_putpixel) (unsigned int offset, int color); +extern int (*vl_getpixel) (unsigned int offset); + +void vl_setCI (int index, float red, float green, float blue); + +int vl_sync_buffer (void **buffer, int x, int y, int width, int height); +int vl_get (int pname, int *params); + +void vl_video_exit (void); +int vl_video_init (int width, int height, int bpp, int rgb, int refresh); + +#endif diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/virtual.S b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/virtual.S new file mode 100644 index 000000000..c5cc1fe86 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/dos/virtual.S @@ -0,0 +1,489 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.3 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : dborca@yahoo.com + * Web : http://www.geocities.com/dborca + */ + + + .file "virtual.S" + +/* + * extern void *vl_current_draw_buffer; + * extern int vl_current_width, vl_current_bytes; + */ + + .text + +/* Desc: void v_clear8 (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_clear8 +_v_clear8: + movl 4(%esp), %eax + movb %al, %ah + pushw %ax + pushw %ax + popl %eax + jmp _v_clear_common + +/* Desc: void v_clear16 (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_clear16 +_v_clear16: + movl 4(%esp), %eax + pushw %ax + pushw %ax + popl %eax + jmp _v_clear_common + +/* Desc: void v_clear32 (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_clear32 +_v_clear32: + movl 4(%esp), %eax + .balign 4 +_v_clear_common: + movl _vl_current_bytes, %ecx + movl _vl_current_draw_buffer, %edx + shrl $2, %ecx + .balign 4 + 0: + movl %eax, (%edx) + addl $4, %edx + decl %ecx + jnz 0b + ret + +/* Desc: void v_clear8_mmx (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_clear8_mmx +_v_clear8_mmx: +#ifdef USE_MMX_ASM + movd 4(%esp), %mm0 + punpcklbw %mm0, %mm0 + punpcklwd %mm0, %mm0 + jmp _v_clear_common_mmx +#endif + +/* Desc: void v_clear16_mmx (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_clear16_mmx +_v_clear16_mmx: +#ifdef USE_MMX_ASM + movd 4(%esp), %mm0 + punpcklwd %mm0, %mm0 + jmp _v_clear_common_mmx +#endif + +/* Desc: void v_clear32_mmx (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_clear32_mmx +_v_clear32_mmx: +#ifdef USE_MMX_ASM + movd 4(%esp), %mm0 + .balign 4 +_v_clear_common_mmx: + punpckldq %mm0, %mm0 + movl _vl_current_bytes, %ecx + movl _vl_current_draw_buffer, %edx + shrl $3, %ecx + .balign 4 + 0: + movq %mm0, (%edx) + addl $8, %edx + decl %ecx + jnz 0b + emms +#endif + ret + +/* Desc: void v_clear24 (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_clear24 +_v_clear24: + movl $0xaaaaaaab, %eax + mull _vl_current_bytes + movl 4(%esp), %eax + movl %edx, %ecx + pushl %ebx + movl _vl_current_draw_buffer, %edx + shrl %ecx + movb 10(%esp), %bl + .balign 4 + 0: + movw %ax, (%edx) + movb %bl, 2(%edx) + addl $3, %edx + decl %ecx + jnz 0b + popl %ebx + ret + +/* Desc: void v_clear24_mmx (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_clear24_mmx +_v_clear24_mmx: +#ifdef USE_MMX_ASM + movl 4(%esp), %eax + movl %eax, %edx + movl %eax, %ecx + shll $16, %edx + rorl $8, %ecx + movw %cx, %dx + rorl $16, %ecx + movb %dh, %cl + shll $8, %eax + movb %ch, %al + rorl $8, %eax + + pushl %edx + pushl %eax + movq (%esp), %mm0 + pushl %ecx + movq (%esp), %mm1 + pushl %edx + movq (%esp), %mm2 + + movl $0xaaaaaaab, %eax + mull _vl_current_bytes + movl %edx, %ecx + movl _vl_current_draw_buffer, %edx + shrl $4, %ecx + .balign 4 + 0: + movq %mm0, (%edx) + movq %mm1, 8(%edx) + movq %mm2, 16(%edx) + addl $24, %edx + decl %ecx + jnz 0b + emms + addl $16, %esp +#endif + ret + +/* Desc: void v_rect8 (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_rect8 +_v_rect8: + cld + pushl %esi + pushl %edi + movl 28(%esp), %eax + movl _vl_current_width, %esi + movl 16(%esp), %edi + movb %al, %ah + movl 20(%esp), %ecx + imull %esi, %edi + movl 24(%esp), %edx + subl %ecx, %esi + addl 12(%esp), %edi + pushw %ax + pushw %ax + pushl %ds + popl %es + addl _vl_current_draw_buffer, %edi + popl %eax + pushl %ebx + movl %ecx, %ebx + andl $3, %ebx + .balign 4 + 0: + pushl %ecx + .balign 4 + 1: + shrl $2, %ecx + rep; stosl + testl %ebx, %ebx + jz 2f + movl %ebx, %ecx + rep; stosb + .balign 4 + 2: + popl %ecx + addl %esi, %edi + decl %edx + jnz 0b + popl %ebx + popl %edi + popl %esi + ret + +/* Desc: void v_rect16 (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_rect16 +_v_rect16: + cld + pushl %esi + pushl %edi + movl 28(%esp), %eax + movl _vl_current_width, %esi + movl 16(%esp), %edi + movl 20(%esp), %ecx + imull %esi, %edi + movl 24(%esp), %edx + subl %ecx, %esi + addl 12(%esp), %edi + pushw %ax + shll %esi + pushw %ax + shll %edi + pushl %ds + popl %es + addl _vl_current_draw_buffer, %edi + popl %eax + .balign 4 + 0: + pushl %ecx + .balign 4 + 1: + shrl %ecx + rep; stosl + jnc 2f + stosw + .balign 4 + 2: + popl %ecx + addl %esi, %edi + decl %edx + jnz 0b + popl %edi + popl %esi + ret + +/* Desc: void v_rect24 (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_rect24 +_v_rect24: + pushl %esi + pushl %edi + movl 28(%esp), %eax + movl _vl_current_width, %esi + movl 16(%esp), %edi + movl 20(%esp), %ecx + imull %esi, %edi + movl 24(%esp), %edx + subl %ecx, %esi + addl 12(%esp), %edi + leal (%esi, %esi, 2), %esi + pushl %ebx + leal (%edi, %edi, 2), %edi + movl %eax, %ebx + addl _vl_current_draw_buffer, %edi + shrl $16, %ebx + .balign 4 + 0: + pushl %ecx + .balign 4 + 1: + movw %ax, (%edi) + movb %bl, 2(%edi) + addl $3, %edi + decl %ecx + jnz 1b + popl %ecx + addl %esi, %edi + decl %edx + jnz 0b + popl %ebx + popl %edi + popl %esi + ret + +/* Desc: void v_rect32 (int color); + * + * In : color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_rect32 +_v_rect32: + pushl %esi + pushl %edi + movl _vl_current_width, %esi + movl 16(%esp), %edi + movl 20(%esp), %ecx + imull %esi, %edi + movl 24(%esp), %edx + subl %ecx, %esi + addl 12(%esp), %edi + shll $2, %esi + shll $2, %edi + movl 28(%esp), %eax + addl _vl_current_draw_buffer, %edi + .balign 4 + 0: + pushl %ecx + .balign 4 + 1: + movl %eax, (%edi) + addl $4, %edi + decl %ecx + jnz 1b + popl %ecx + addl %esi, %edi + decl %edx + jnz 0b + popl %edi + popl %esi + ret + +/* Desc: void v_putpixel8 (unsigned int offset, int color); + * + * In : offset within buffer, color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_putpixel8 +_v_putpixel8: + movl 8(%esp), %ecx + movl 4(%esp), %edx + movl _vl_current_draw_buffer, %eax + movb %cl, (%eax,%edx) + ret + +/* Desc: void v_putpixel16 (unsigned int offset, int color); + * + * In : offset within buffer, color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_putpixel16 +_v_putpixel16: + movl 8(%esp), %ecx + movl 4(%esp), %edx + movl _vl_current_draw_buffer, %eax + movw %cx, (%eax,%edx,2) + ret + +/* Desc: void v_putpixel24 (unsigned int offset, int color); + * + * In : offset within buffer, color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_putpixel24 +_v_putpixel24: + movl 4(%esp), %eax + movl 8(%esp), %edx + movl _vl_current_draw_buffer, %ecx + leal (%eax,%eax,2), %eax + movw %dx, (%ecx,%eax) + shrl $16, %edx + movb %dl, 2(%ecx,%eax) + ret + +/* Desc: void v_putpixel32 (unsigned int offset, int color); + * + * In : offset within buffer, color + * Out : - + * + * Note: uses current draw buffer + */ + .p2align 5,,31 + .global _v_putpixel32 +_v_putpixel32: + movl 8(%esp), %ecx + movl 4(%esp), %edx + movl _vl_current_draw_buffer, %eax + movl %ecx, (%eax,%edx,4) + ret |