summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dos
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-12-18 15:06:36 +0000
committerBrian Paul <[email protected]>2002-12-18 15:06:36 +0000
commit03516d9efa76720be2b0b8677573a5f93845c2da (patch)
treee6cda83d0b5f863aaa15ab5bca8c7637fc71d2b4 /src/mesa/drivers/dos
parentc0fc0d4e5f5c246fc2459348a3d114b232d0c545 (diff)
DOS updates from Daniel Borca.
Diffstat (limited to 'src/mesa/drivers/dos')
-rw-r--r--src/mesa/drivers/dos/dmesa.c593
-rw-r--r--src/mesa/drivers/dos/dpmi.c4
-rw-r--r--src/mesa/drivers/dos/internal.h127
-rw-r--r--src/mesa/drivers/dos/vesa/vesa.c201
-rw-r--r--src/mesa/drivers/dos/vesa/vesa.h8
-rw-r--r--src/mesa/drivers/dos/video.c350
-rw-r--r--src/mesa/drivers/dos/video.h27
-rw-r--r--src/mesa/drivers/dos/virtual.S469
8 files changed, 1376 insertions, 403 deletions
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 2ccfffb521c..4541559e2ca 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.0
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.2 for Mesa 4.1
+ * DOS/DJGPP device driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -31,6 +31,8 @@
*/
+#ifndef FX
+
#include "glheader.h"
#include "context.h"
#include "GL/dmesa.h"
@@ -54,6 +56,13 @@
#include "video.h"
+#else
+
+#include "../FX/fxdrv.h"
+#include "GL/dmesa.h"
+
+#endif
+
/*
@@ -77,7 +86,6 @@ struct dmesa_buffer {
int xpos, ypos; /* position */
int width, height; /* size in pixels */
- int bypp, stride, bytes; /* bytes per pixel, in a line, then total */
};
/*
@@ -89,22 +97,26 @@ struct dmesa_context {
DMesaVisual visual;
DMesaBuffer Buffer;
GLuint ClearColor;
+ GLuint ClearIndex;
/* etc... */
};
+#ifndef FX
/****************************************************************************
* Read/Write pixels
***************************************************************************/
#define FLIP(y) (c->Buffer->height - (y) - 1)
-#define FLIP2(y) (h - (y) - 1)
+#define FLIP2(y) (b - (y))
+/****************************************************************************
+ * 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 c = (DMesaContext)ctx->DriverCtx;
- void *b = c->Buffer->the_window;
GLuint i, offset;
offset = c->Buffer->width * FLIP(y) + x;
@@ -112,13 +124,13 @@ static void write_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
/* draw some pixels */
for (i=0; i<n; i++, offset++) {
if (mask[i]) {
- vl_putpixel(b, offset, vl_mixrgba(rgba[i]));
+ vl_putpixel(offset, vl_mixrgba(rgba[i]));
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++, offset++) {
- vl_putpixel(b, offset, vl_mixrgba(rgba[i]));
+ vl_putpixel(offset, vl_mixrgba(rgba[i]));
}
}
}
@@ -129,7 +141,6 @@ static void write_rgb_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLubyte rgb[][3], const GLubyte mask[])
{
const DMesaContext c = (DMesaContext)ctx->DriverCtx;
- void *b = c->Buffer->the_window;
GLuint i, offset;
offset = c->Buffer->width * FLIP(y) + x;
@@ -137,13 +148,13 @@ static void write_rgb_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
/* draw some pixels */
for (i=0; i<n; i++, offset++) {
if (mask[i]) {
- vl_putpixel(b, offset, vl_mixrgb(rgb[i]));
+ vl_putpixel(offset, vl_mixrgb(rgb[i]));
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++, offset++) {
- vl_putpixel(b, offset, vl_mixrgb(rgb[i]));
+ vl_putpixel(offset, vl_mixrgb(rgb[i]));
}
}
}
@@ -155,7 +166,6 @@ static void write_mono_rgba_span (const GLcontext *ctx,
const GLchan color[4], const GLubyte mask[])
{
const DMesaContext c = (DMesaContext)ctx->DriverCtx;
- void *b = c->Buffer->the_window;
GLuint i, offset, rgba = vl_mixrgba(color);
offset = c->Buffer->width * FLIP(y) + x;
@@ -163,13 +173,13 @@ static void write_mono_rgba_span (const GLcontext *ctx,
/* draw some pixels */
for (i=0; i<n; i++, offset++) {
if (mask[i]) {
- vl_putpixel(b, offset, rgba);
+ vl_putpixel(offset, rgba);
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++, offset++) {
- vl_putpixel(b, offset, rgba);
+ vl_putpixel(offset, rgba);
}
}
}
@@ -180,13 +190,12 @@ static void read_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
GLubyte rgba[][4])
{
const DMesaContext c = (DMesaContext)ctx->DriverCtx;
- void *b = c->Buffer->the_window;
GLuint i, offset;
offset = c->Buffer->width * FLIP(y) + x;
/* read all pixels */
for (i=0; i<n; i++, offset++) {
- vl_getrgba(b, offset, rgba[i]);
+ vl_getrgba(offset, rgba[i]);
}
}
@@ -197,20 +206,19 @@ static void write_rgba_pixels (const GLcontext *ctx,
const GLubyte rgba[][4], const GLubyte mask[])
{
const DMesaContext c = (DMesaContext)ctx->DriverCtx;
- void *b = c->Buffer->the_window;
- GLuint i, w = c->Buffer->width, h = c->Buffer->height;
+ GLuint i, w = c->Buffer->width, b = c->Buffer->height - 1;
if (mask) {
/* draw some pixels */
for (i=0; i<n; i++) {
if (mask[i]) {
- vl_putpixel(b, FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[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(b, FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[i]));
+ vl_putpixel(FLIP2(y[i])*w + x[i], vl_mixrgba(rgba[i]));
}
}
}
@@ -222,20 +230,19 @@ static void write_mono_rgba_pixels (const GLcontext *ctx,
const GLchan color[4], const GLubyte mask[])
{
const DMesaContext c = (DMesaContext)ctx->DriverCtx;
- void *b = c->Buffer->the_window;
- GLuint i, w = c->Buffer->width, h = c->Buffer->height, rgba = vl_mixrgba(color);
+ GLuint i, w = c->Buffer->width, b = c->Buffer->height - 1, rgba = vl_mixrgba(color);
if (mask) {
/* draw some pixels */
for (i=0; i<n; i++) {
if (mask[i]) {
- vl_putpixel(b, FLIP2(y[i])*w + x[i], rgba);
+ vl_putpixel(FLIP2(y[i])*w + x[i], rgba);
}
}
} else {
/* draw all pixels */
for (i=0; i<n; i++) {
- vl_putpixel(b, FLIP2(y[i])*w + x[i], rgba);
+ vl_putpixel(FLIP2(y[i])*w + x[i], rgba);
}
}
}
@@ -247,20 +254,180 @@ static void read_rgba_pixels (const GLcontext *ctx,
GLubyte rgba[][4], const GLubyte mask[])
{
const DMesaContext c = (DMesaContext)ctx->DriverCtx;
- void *b = c->Buffer->the_window;
- GLuint i, w = c->Buffer->width, h = c->Buffer->height;
+ GLuint i, w = c->Buffer->width, b = c->Buffer->height - 1;
if (mask) {
/* read some pixels */
for (i=0; i<n; i++) {
if (mask[i]) {
- vl_getrgba(b, FLIP2(y[i])*w + x[i], rgba[i]);
+ vl_getrgba(FLIP2(y[i])*w + x[i], rgba[i]);
}
}
} else {
/* read all pixels */
for (i=0; i<n; i++) {
- vl_getrgba(b, FLIP2(y[i])*w + x[i], rgba[i]);
+ vl_getrgba(FLIP2(y[i])*w + x[i], rgba[i]);
+ }
+ }
+}
+
+/****************************************************************************
+ * Index
+ ***************************************************************************/
+static void write_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLuint index[], const GLubyte mask[])
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint i, offset;
+
+ offset = c->Buffer->width * 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, GLuint n, GLint x, GLint y,
+ const GLubyte index[], const GLubyte mask[])
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint i, offset;
+
+ offset = c->Buffer->width * 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,
+ GLuint n, GLint x, GLint y,
+ GLuint colorIndex, const GLubyte mask[])
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint i, offset;
+
+ offset = c->Buffer->width * 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, GLuint n, GLint x, GLint y,
+ GLuint index[])
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint i, offset;
+
+ offset = c->Buffer->width * FLIP(y) + x;
+ /* read all pixels */
+ for (i=0; i<n; i++, offset++) {
+ index[i] = vl_getCIpixel(offset);
+ }
+}
+
+
+
+static void write_index_pixels (const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLuint index[], const GLubyte mask[])
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint i, w = c->Buffer->width, b = c->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,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint colorIndex, const GLubyte mask[])
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint i, w = c->Buffer->width, b = c->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,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint index[], const GLubyte mask[])
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint i, w = c->Buffer->width, b = c->Buffer->height - 1;
+
+ if (mask) {
+ /* read some pixels */
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ index[i] = vl_getCIpixel(FLIP2(y[i])*w + x[i]);
+ }
+ }
+ } else {
+ /* read all pixels */
+ for (i=0; i<n; i++) {
+ index[i] = vl_getCIpixel(FLIP2(y[i])*w + x[i]);
}
}
}
@@ -274,105 +441,115 @@ static void read_rgba_pixels (const GLcontext *ctx,
/*
* flat, NON-depth-buffered, triangle.
*/
-#define NAME tri_rgb_flat
-#define SETUP_CODE \
- GLuint rgb = vl_mixrgb(v2->color); \
- const DMesaContext c = (DMesaContext)ctx->DriverCtx; \
- void *b = c->Buffer->the_window; \
- GLuint w = c->Buffer->width, h = c->Buffer->height;
+static void tri_rgb_flat (GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint w = c->Buffer->width, b = c->Buffer->height - 1;
+
+#define SETUP_CODE 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(b, offset, rgb); \
+ vl_putpixel(offset, rgb); \
}
-#include "swrast/s_tritemp.h"
+#include "swrast/s_tritemp.h"
+}
/*
* flat, depth-buffered, triangle.
*/
-#define NAME tri_rgb_flat_z
+static void tri_rgb_flat_z (GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint w = c->Buffer->width, b = c->Buffer->height - 1;
+
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define SETUP_CODE \
- const DMesaContext c = (DMesaContext)ctx->DriverCtx; \
- void *b = c->Buffer->the_window; \
- GLuint w = c->Buffer->width, h = c->Buffer->height; \
- GLuint rgb = vl_mixrgb(v2->color);
+#define SETUP_CODE 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(b, offset, rgb); \
+ vl_putpixel(offset, rgb); \
zRow[i] = z; \
} \
span.z += span.zStep; \
}
-#include "swrast/s_tritemp.h"
+#include "swrast/s_tritemp.h"
+}
/*
* smooth, NON-depth-buffered, triangle.
*/
-#define NAME tri_rgb_smooth
+static void tri_rgb_smooth (GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint w = c->Buffer->width, b = c->Buffer->height - 1;
+
#define INTERP_RGB 1
-#define SETUP_CODE \
- const DMesaContext c = (DMesaContext)ctx->DriverCtx; \
- void *b = c->Buffer->the_window; \
- GLuint w = c->Buffer->width, h = c->Buffer->height;
-#define RENDER_SPAN(span) \
- GLuint i, offset = FLIP2(span.y)*w + span.x; \
- for (i = 0; i < span.end; i++, offset++) { \
- unsigned char rgb[3]; \
- rgb[0] = FixedToInt(span.red); \
- rgb[1] = FixedToInt(span.green); \
- rgb[2] = FixedToInt(span.blue); \
- vl_putpixel(b, offset, vl_mixrgb(rgb)); \
- span.red += span.redStep; \
- span.green += span.greenStep; \
- span.blue += span.blueStep; \
+#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"
+}
/*
* smooth, depth-buffered, triangle.
*/
-#define NAME tri_rgb_smooth_z
+static void tri_rgb_smooth_z (GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ const DMesaContext c = (DMesaContext)ctx->DriverCtx;
+ GLuint w = c->Buffer->width, b = c->Buffer->height - 1;
+
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define SETUP_CODE \
- const DMesaContext c = (DMesaContext)ctx->DriverCtx; \
- void *b = c->Buffer->the_window; \
- GLuint w = c->Buffer->width, h = c->Buffer->height;
-#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]) { \
- unsigned char rgb[3]; \
- rgb[0] = FixedToInt(span.red); \
- rgb[1] = FixedToInt(span.green); \
- rgb[2] = FixedToInt(span.blue); \
- vl_putpixel(b, offset, vl_mixrgb(rgb)); \
- zRow[i] = z; \
- } \
- span.red += span.redStep; \
- span.green += span.greenStep; \
- span.blue += span.blueStep; \
- span.z += span.zStep; \
+
+#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"
+#include "swrast/s_tritemp.h"
+}
@@ -384,35 +561,24 @@ static swrast_tri_func dmesa_choose_tri_function (GLcontext *ctx)
{
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
- if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
- if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
- if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;
-
- if (ctx->Light.ShadeModel==GL_SMOOTH
- && swrast->_RasterMask==DEPTH_BIT
- && ctx->Depth.Func==GL_LESS
- && ctx->Depth.Mask==GL_TRUE
- && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- return tri_rgb_smooth_z;
+ 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 (ctx->Light.ShadeModel==GL_FLAT
- && swrast->_RasterMask==DEPTH_BIT
+
+ if (swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
- && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- return tri_rgb_flat_z;
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS) {
+ return (ctx->Light.ShadeModel==GL_SMOOTH) ? tri_rgb_smooth_z : tri_rgb_flat_z;
}
- if (swrast->_RasterMask==0 /* no depth test */
- && ctx->Light.ShadeModel==GL_SMOOTH
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- return tri_rgb_smooth;
- }
- if (swrast->_RasterMask==0 /* no depth test */
- && ctx->Light.ShadeModel==GL_FLAT
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- return tri_rgb_flat;
+
+ if (swrast->_RasterMask==0) { /* no depth test */
+ return (ctx->Light.ShadeModel==GL_SMOOTH) ? tri_rgb_smooth : tri_rgb_flat;
}
return (swrast_tri_func)NULL;
@@ -421,7 +587,7 @@ static swrast_tri_func dmesa_choose_tri_function (GLcontext *ctx)
/* Override for the swrast triangle-selection function. Try to use one
- * of our internal line functions, otherwise fall back to the
+ * of our internal triangle functions, otherwise fall back to the
* standard swrast functions.
*/
static void dmesa_choose_tri (GLcontext *ctx)
@@ -438,6 +604,13 @@ static void dmesa_choose_tri (GLcontext *ctx)
* Miscellaneous device driver funcs
***************************************************************************/
+static void clear_index (GLcontext *ctx, GLuint index)
+{
+ DMesaContext c = (DMesaContext)ctx->DriverCtx;
+
+ c->ClearIndex = index;
+}
+
static void clear_color (GLcontext *ctx, const GLfloat color[4])
{
GLubyte col[4];
@@ -456,7 +629,6 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,
{
const DMesaContext c = (DMesaContext)ctx->DriverCtx;
const GLuint *colorMask = (GLuint *)&ctx->Color.ColorMask;
- DMesaBuffer b = c->Buffer;
/*
* Clear the specified region of the buffers indicated by 'mask'
@@ -467,13 +639,16 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,
*/
/* we can't handle color or index masking */
- if (*colorMask==0xffffffff) {
+ if ((*colorMask == 0xffffffff) && (ctx->Color.IndexMask == 0xffffffff)) {
if (mask & DD_BACK_LEFT_BIT) {
+ int color = c->visual->rgb_flag ? c->ClearColor : c->ClearIndex;
+
if (all) {
- vl_clear(b->the_window, b->bytes, c->ClearColor);
+ vl_clear(color);
} else {
- vl_rect(b->the_window, x, y, width, height, c->ClearColor);
+ vl_rect(x, y, width, height, color);
}
+
mask &= ~DD_BACK_LEFT_BIT;
}
}
@@ -485,15 +660,6 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,
-static void color_mask (GLcontext *ctx, GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask)
-{
- /*
- * XXX todo - Implements glColorMask()
- */
-}
-
-
-
static void set_buffer (GLcontext *ctx, GLframebuffer *colorBuffer, GLuint bufferBit)
{
/*
@@ -503,15 +669,6 @@ static void set_buffer (GLcontext *ctx, GLframebuffer *colorBuffer, GLuint buffe
-static void enable (GLcontext *ctx, GLenum pname, GLboolean state)
-{
- /*
- * XXX todo -
- */
-}
-
-
-
/*
* Return the width and height of the current buffer.
* If anything special has to been done when the buffer/window is
@@ -531,7 +688,7 @@ static const GLubyte* get_string (GLcontext *ctx, GLenum name)
{
switch (name) {
case GL_RENDERER:
- return (const GLubyte *)"Mesa DJGPP\0port (c) Borca Daniel nov-2002";
+ return (const GLubyte *)"Mesa DJGPP\0port (c) Borca Daniel dec-2002";
default:
return NULL;
}
@@ -639,8 +796,7 @@ static void dmesa_init_pointers (GLcontext *ctx)
/* Statechange callbacks:
*/
ctx->Driver.ClearColor = clear_color;
- ctx->Driver.ColorMask = color_mask;
- ctx->Driver.Enable = enable;
+ ctx->Driver.ClearIndex = clear_index;
/* Initialize the TNL driver interface:
*/
@@ -668,6 +824,15 @@ static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
_tnl_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
+ /* 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;
@@ -677,6 +842,7 @@ static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
dd->ReadRGBASpan = read_rgba_span;
dd->ReadRGBAPixels = read_rgba_pixels;
}
+#endif
@@ -687,80 +853,126 @@ static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
/*
* The exact arguments to this function will depend on your window system
*/
-DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
- GLboolean dbFlag, GLint depthSize,
+DMesaVisual DMesaCreateVisual (GLint width,
+ GLint height,
+ GLint colDepth,
+ GLint refresh,
+ GLboolean dbFlag,
+ GLboolean rgbFlag,
+ GLboolean alphaFlag,
+ GLint depthSize,
GLint stencilSize,
GLint accumSize)
{
+#ifndef FX
DMesaVisual v;
- GLint redBits, greenBits, blueBits, alphaBits;
-
- char *var = getenv("DMESA_REFRESH");
- int refresh = (var != NULL) ? atoi(var) : 0;
+ GLint redBits, greenBits, blueBits, alphaBits, indexBits;
if (!dbFlag) {
return NULL;
}
alphaBits = 0;
- switch (colDepth) {
- case 15:
- 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;
+
+ 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:
+ 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;
+ }
}
- if (vl_video_init(width, height, colDepth, refresh) != 0) {
+ if ((colDepth=vl_video_init(width, height, colDepth, rgbFlag, refresh)) <= 0) {
return NULL;
}
+ if (alphaFlag && (alphaBits==0)) {
+ alphaBits = 8;
+ }
+
if ((v=(DMesaVisual)calloc(1, sizeof(struct dmesa_visual))) != NULL) {
/* Create core visual */
- v->gl_visual = _mesa_create_visual(colDepth>8, /* rgb */
+ v->gl_visual = _mesa_create_visual(rgbFlag, /* rgb */
dbFlag,
GL_FALSE, /* stereo */
redBits,
greenBits,
blueBits,
alphaBits,
- 0, /* indexBits */
+ indexBits, /* indexBits */
depthSize,
stencilSize,
accumSize, /* accumRed */
accumSize, /* accumGreen */
accumSize, /* accumBlue */
- alphaBits?accumSize:0, /* accumAlpha */
+ alphaFlag?accumSize:0, /* accumAlpha */
1); /* numSamples */
v->depth = colDepth;
v->db_flag = dbFlag;
+ v->rgb_flag = rgbFlag;
}
return v;
+
+#else
+
+ int i = 0, fx_attrib[32];
+
+ if (!rgbFlag) {
+ return NULL;
+ }
+
+ if (dbFlag) fx_attrib[i++] = FXMESA_DOUBLEBUFFER;
+ if (depthSize > 0) { fx_attrib[i++] = FXMESA_DEPTH_SIZE; fx_attrib[i++] = depthSize; }
+ if (stencilSize > 0) { fx_attrib[i++] = FXMESA_STENCIL_SIZE; fx_attrib[i++] = stencilSize; }
+ if (accumSize > 0) { fx_attrib[i++] = FXMESA_ACCUM_SIZE; fx_attrib[i++] = accumSize; }
+ if (alphaFlag) { fx_attrib[i++] = FXMESA_ALPHA_SIZE; fx_attrib[i++] = 1; }
+ fx_attrib[i] = FXMESA_NONE;
+
+ return (DMesaVisual)fxMesaCreateBestContext(-1, width, height, fx_attrib);
+#endif
}
void DMesaDestroyVisual (DMesaVisual v)
{
- vl_video_exit();
+#ifndef FX
_mesa_destroy_visual(v->gl_visual);
free(v);
+
+ vl_video_exit();
+#else
+ fxMesaDestroyContext((fxMesaContext)v);
+#endif
}
@@ -769,6 +981,7 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
GLint xpos, GLint ypos,
GLint width, GLint height)
{
+#ifndef FX
DMesaBuffer b;
if ((b=(DMesaBuffer)calloc(1, sizeof(struct dmesa_buffer))) != NULL) {
@@ -783,19 +996,23 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
b->ypos = ypos;
b->width = width;
b->height = height;
- b->bypp = (visual->depth+7)/8;
}
return b;
+#else
+ return (DMesaBuffer)visual;
+#endif
}
void DMesaDestroyBuffer (DMesaBuffer b)
{
+#ifndef FX
free(b->the_window);
_mesa_free_framebuffer_data(&b->gl_buffer);
free(b);
+#endif
}
@@ -803,6 +1020,7 @@ void DMesaDestroyBuffer (DMesaBuffer b)
DMesaContext DMesaCreateContext (DMesaVisual visual,
DMesaContext share)
{
+#ifndef FX
DMesaContext c;
GLboolean direct = GL_FALSE;
@@ -812,6 +1030,7 @@ DMesaContext DMesaCreateContext (DMesaVisual visual,
(void *)c, direct);
_mesa_enable_sw_extensions(c->gl_ctx);
+ _mesa_enable_1_3_extensions(c->gl_ctx);
_mesa_enable_1_4_extensions(c->gl_ctx);
/* you probably have to do a bunch of other initializations here. */
@@ -825,19 +1044,32 @@ DMesaContext DMesaCreateContext (DMesaVisual visual,
_ac_CreateContext(c->gl_ctx);
_tnl_CreateContext(c->gl_ctx);
_swsetup_CreateContext(c->gl_ctx);
- dmesa_register_swrast_functions(c->gl_ctx);
+ if (visual->rgb_flag) dmesa_register_swrast_functions(c->gl_ctx);
dmesa_init_pointers(c->gl_ctx);
}
return c;
+
+#else
+
+ return (DMesaContext)visual;
+#endif
}
void DMesaDestroyContext (DMesaContext c)
{
- _mesa_destroy_context(c->gl_ctx);
+#ifndef FX
+ if (c->gl_ctx) {
+ _swsetup_DestroyContext(c->gl_ctx);
+ _swrast_DestroyContext(c->gl_ctx);
+ _tnl_DestroyContext(c->gl_ctx);
+ _ac_DestroyContext(c->gl_ctx);
+ _mesa_destroy_context(c->gl_ctx);
+ }
free(c);
+#endif
}
@@ -846,6 +1078,7 @@ GLboolean DMesaViewport (DMesaBuffer b,
GLint xpos, GLint ypos,
GLint width, GLint height)
{
+#ifndef FX
void *new_window;
if ((new_window=vl_sync_buffer(b->the_window, xpos, ypos, width, height)) == NULL) {
@@ -856,10 +1089,13 @@ GLboolean DMesaViewport (DMesaBuffer b,
b->ypos = ypos;
b->width = width;
b->height = height;
- b->stride = width * b->bypp;
- b->bytes = b->stride * height;
return GL_TRUE;
}
+
+#else
+
+ return GL_FALSE;
+#endif
}
@@ -869,6 +1105,7 @@ GLboolean DMesaViewport (DMesaBuffer b,
*/
GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
{
+#ifndef FX
if ((c != NULL) && (b != NULL)) {
if (!DMesaViewport(b, b->xpos, b->ypos, b->width, b->height)) {
return GL_FALSE;
@@ -886,6 +1123,11 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
_mesa_make_current(NULL, NULL);
}
+#else
+
+ fxMesaMakeCurrent((fxMesaContext)c);
+#endif
+
return GL_TRUE;
}
@@ -894,7 +1136,20 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
void DMesaSwapBuffers (DMesaBuffer b)
{
/* copy/swap back buffer to front if applicable */
+#ifndef FX
GET_CURRENT_CONTEXT(ctx);
_mesa_notifySwapBuffers(ctx);
- vl_flip(b->the_window, b->stride, b->height);
+ vl_flip();
+#else
+ fxMesaSwapBuffers();
+#endif
+}
+
+
+
+void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue)
+{
+#ifndef FX
+ vl_setCI(ndx, red, green, blue);
+#endif
}
diff --git a/src/mesa/drivers/dos/dpmi.c b/src/mesa/drivers/dos/dpmi.c
index 60610acddf2..882cda390a4 100644
--- a/src/mesa/drivers/dos/dpmi.c
+++ b/src/mesa/drivers/dos/dpmi.c
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.1 for Mesa 4.0
+ * DOS/DJGPP device driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -33,7 +33,7 @@
#include <dpmi.h>
-#include "dpmiint.h"
+#include "internal.h"
diff --git a/src/mesa/drivers/dos/internal.h b/src/mesa/drivers/dos/internal.h
new file mode 100644
index 00000000000..824d963d360
--- /dev/null
+++ b/src/mesa/drivers/dos/internal.h
@@ -0,0 +1,127 @@
+/*
+ * 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 5.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : [email protected]
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef INTERNAL_H_included
+#define INTERNAL_H_included
+
+#include "../mmath.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 mode;
+ int xres, yres;
+ int scanlen;
+ int bpp;
+
+ 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 (*getCIprec) (void);
+ void (*restore) (void);
+ void (*finit) (void);
+} vl_driver;
+
+
+
+/*
+ * memory mapping
+ */
+int _create_selector (int *segment, unsigned long base, int size);
+void _remove_selector (int *segment);
+
+/*
+ * system routines
+ */
+int vl_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/src/mesa/drivers/dos/vesa/vesa.c b/src/mesa/drivers/dos/vesa/vesa.c
index 8dbeb9e52c4..26c474317fe 100644
--- a/src/mesa/drivers/dos/vesa/vesa.c
+++ b/src/mesa/drivers/dos/vesa/vesa.c
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.2 for Mesa 4.1
+ * DOS/DJGPP device driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -32,7 +32,7 @@
#include <dpmi.h>
-#include <string.h>
+#include <stdlib.h>
#include <stubinfo.h>
#include <sys/exceptn.h>
#include <sys/segments.h>
@@ -40,7 +40,6 @@
#include <sys/movedata.h>
#include "vesa.h"
-#include "../dpmiint.h"
@@ -50,6 +49,11 @@ static word16 vesa_ver;
static int banked_selector, linear_selector;
static int oldmode = -1;
+static int vesa_color_precision = 6;
+
+static void *vesa_pmcode;
+unsigned int vesa_gran_mask, vesa_gran_shift;
+
/*
@@ -100,11 +104,14 @@ typedef struct CRTCInfoBlock {
-/* vesa_init:
- * Attempts to detect VESA, check video modes and create selectors.
- * Returns 0 if error.
+/* Desc: Attempts to detect VESA, check video modes and create selectors.
+ *
+ * In : -
+ * Out : mode array
+ *
+ * Note: -
*/
-static word16 vesa_init (void)
+static vl_mode *vesa_init (void)
{
__dpmi_regs r;
word16 *p;
@@ -114,7 +121,7 @@ static word16 vesa_init (void)
word32 linearfb = 0;
if (vesa_ver) {
- return vesa_ver;
+ return modes;
}
_farpokel(_stubinfo->ds_selector, 0, 0x32454256);
@@ -124,7 +131,7 @@ static word16 vesa_init (void)
__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 0;
+ return NULL;
}
p = (word16 *)(((_16_ vesa_info[V_MODE_SEG])<<4) + (_16_ vesa_info[V_MODE_OFS]));
@@ -144,6 +151,7 @@ static word16 vesa_init (void)
case 16:
q->bpp = tmp[M_RED] + tmp[M_GREEN] + tmp[M_BLUE];
break;
+ case 8:
case 15:
case 24:
case 32:
@@ -175,54 +183,74 @@ static word16 vesa_init (void)
} while (TRUE);
if (q==modes) {
- return 0;
+ return NULL;
}
if (linearfb) {
maxsize = ((maxsize+0xfffUL)&~0xfffUL);
if (_create_selector(&linear_selector, linearfb, maxsize)) {
- return 0;
+ return NULL;
}
}
if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) {
_remove_selector(&linear_selector);
- return 0;
+ return NULL;
}
for (q=modes; q->mode!=0xffff; q++) {
q->sel = (q->mode&0x4000) ? linear_selector : banked_selector;
}
- return (vesa_ver = _16_ vesa_info[V_MINOR]);
+ if (vesa_info[V_MAJOR] >= 2) {
+ r.x.ax = 0x4f0a;
+ r.h.bl = 0;
+ __dpmi_int(0x10, &r);
+ if (r.x.ax == 0x004f) {
+ vesa_pmcode = malloc(r.x.cx);
+ movedata(__djgpp_dos_sel, (r.x.es << 4) + r.x.di, _my_ds(), (unsigned)vesa_pmcode, r.x.cx);
+ p = (word16 *)((long)vesa_pmcode + ((word16 *)vesa_pmcode)[3]);
+ while (*p++ != 0xffff) ;
+ if (*p != 0xffff) {
+ free(vesa_pmcode);
+ vesa_pmcode = NULL;
+ } else {
+ vesa_swbank = (char *)vesa_pmcode + ((word16 *)vesa_pmcode)[0];
+ }
+ }
+ }
+
+ vesa_ver = _16_ vesa_info[V_MINOR];
+ return modes;
}
-/* vesa_finit:
- * Frees all resources allocated by VESA init code.
+/* Desc: Frees all resources allocated by VESA init code.
+ *
+ * In : -
+ * Out : -
+ *
+ * Note: -
*/
static void vesa_finit (void)
{
if (vesa_ver) {
_remove_selector(&linear_selector);
_remove_selector(&banked_selector);
+ if (vesa_pmcode != NULL) {
+ free(vesa_pmcode);
+ vesa_pmcode = NULL;
+ }
}
}
-/* vesa_getmodes:
- * Returns ptr to mode array.
- */
-static vl_mode *vesa_getmodes (void)
-{
- return (vesa_init() == 0) ? NULL : modes;
-}
-
-
-
-/* _closest_pixclk:
- * Uses VESA 3.0 function 0x4F0B to find the closest pixel clock to the
- * requested value.
+/* 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)
{
@@ -239,8 +267,12 @@ static unsigned long _closest_pixclk (int mode_no, unsigned long vclk)
-/* _crtc_timing:
- * Calculates CRTC mode timings.
+/* 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)
{
@@ -318,16 +350,28 @@ static void _crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust,
-/* vesa_entermode:
- * Attempts to enter specified video mode.
+/* Desc: Attempts to enter specified video mode.
+ *
+ * In : ptr to mode structure, refresh rate
+ * Out : 0 if success
*
- * success: 0
- * failure: !0
+ * Note: -
*/
static int vesa_entermode (vl_mode *p, int refresh)
{
__dpmi_regs r;
+ if (p->mode & 0x4000) {
+ VESA.blit = vl_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);
@@ -364,14 +408,33 @@ static int vesa_entermode (vl_mode *p, int refresh)
}
__dpmi_int(0x10, &r);
+ if (r.x.ax != 0x004f) {
+ return !0;
+ }
- return (r.x.ax != 0x004f);
+ 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;
}
-/* vesa_restore:
- * Restores to the mode prior to first call to vesa_entermode.
+/* Desc: Restores to the mode prior to first call to vesa_entermode.
+ *
+ * In : -
+ * Out : -
+ *
+ * Note: -
*/
static void vesa_restore (void)
{
@@ -386,12 +449,74 @@ static void vesa_restore (void)
+/* 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;
+
+ int _red = red * max;
+ int _green = green * max;
+ int _blue = blue * max;
+
+ __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");
+}
+
+
+
+/* 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)
+{
+ __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");
+}
+
+
+
+/* Desc: retrieve CI precision
+ *
+ * In : -
+ * Out : precision in bits
+ *
+ * Note: -
+ */
+static int vesa_getCIprec (void)
+{
+ return vesa_color_precision;
+}
+
+
+
/*
* the driver
*/
vl_driver VESA = {
- vesa_getmodes,
+ vesa_init,
vesa_entermode,
+ NULL,
+ vesa_setCI_f,
+ vesa_setCI_i,
+ vesa_getCIprec,
vesa_restore,
vesa_finit
};
diff --git a/src/mesa/drivers/dos/vesa/vesa.h b/src/mesa/drivers/dos/vesa/vesa.h
index 22ecbd538ab..eb914e16c13 100644
--- a/src/mesa/drivers/dos/vesa/vesa.h
+++ b/src/mesa/drivers/dos/vesa/vesa.h
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.1 for Mesa 4.0
+ * DOS/DJGPP device driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -34,9 +34,13 @@
#ifndef VESA_H_included
#define VESA_H_included
-#include "../videoint.h"
+#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;
diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c
index 16e72cf5810..5f4d9d5bedb 100644
--- a/src/mesa/drivers/dos/video.c
+++ b/src/mesa/drivers/dos/video.c
@@ -23,32 +23,33 @@
*/
/*
- * DOS/DJGPP device driver v1.1 for Mesa 4.0
+ * DOS/DJGPP device driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
* Web : http://www.geocities.com/dborca
+ *
+ * Thanks to CrazyPyro (Neil Funk) for FakeColor
*/
#include <stdlib.h>
#include "video.h"
-#include "videoint.h"
+#include "internal.h"
#include "vesa/vesa.h"
+#include "vga/vga.h"
-static vl_driver *drv = &VESA;
-/* card specific: valid forever */
-word32 vl_hw_granularity;
-static unsigned int gran_shift, gran_mask;
+static vl_driver *drv;
/* based upon mode specific data: valid entire session */
int vl_video_selector;
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;
-static int current_width;
@@ -72,38 +73,77 @@ static int _rgb_scale_6[64] = {
226, 230, 234, 238, 242, 246, 250, 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
-void (*vl_clear) (void *buffer, int bytes, int color);
-void (*vl_flip) (void *buffer, int stride, int height);
-int (*vl_mixrgba) (const unsigned char rgba[]);
+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[]);
-void (*vl_putpixel) (void *buffer, int offset, int color);
-void (*vl_getrgba) (void *buffer, int offset, unsigned char rgba[4]);
+int (*vl_mixrgba) (const unsigned char rgba[]);
+void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]);
+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);
-/* vl_rect:
- * Clears a rectange with specified color.
+/* Desc: color composition (w/o ALPHA)
+ *
+ * In : R, G, B
+ * Out : color
+ *
+ * Note: -
*/
-void vl_rect (void *buffer, int x, int y, int width, int height, int color)
+static int vl_mixfix8fake (fixed r, fixed g, fixed b)
{
- int offset = y*current_width + x;
- int delta = current_width - width;
-
- for (y=0; y<height; y++) {
- for (x=0; x<width; x++, offset++) {
- vl_putpixel(buffer, offset, color);
- }
- offset += delta;
- }
+ 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);
}
-/* vl_mixrgba*:
- * Color composition (w/ ALPHA).
+/* 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
@@ -114,9 +154,20 @@ static int vl_mixrgba32 (const unsigned char rgba[])
-/* vl_mixrgb*:
- * Color composition (w/o ALPHA).
+/* Desc: color composition (w/o ALPHA)
+ *
+ * In : array of integers (R, G, B)
+ * Out : color
+ *
+ * Note: -
*/
+static int vl_mixrgb8fake (const unsigned char rgba[])
+{
+ return array_b[rgba[2]]*G_CNT*R_CNT
+ + array_g[rgba[1]]*R_CNT
+ + array_r[rgba[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);
@@ -133,36 +184,57 @@ static int vl_mixrgb32 (const unsigned char rgb[])
-/* v_getrgba*:
- * Color decomposition.
+/* 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_getrgba15 (void *buffer, int offset, unsigned char rgba[4])
+static void v_getrgba8fake6 (unsigned int offset, unsigned char rgba[])
{
- int c = ((word16 *)buffer)[offset];
+ 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;
+}
+static void v_getrgba8fake8 (unsigned int offset, unsigned char rgba[])
+{
+ word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]];
+ rgba[0] = c >> 16;
+ rgba[1] = c >> 8;
+ rgba[2] = c;
+ rgba[3] = c >> 24;
+}
+#define v_getrgba8 v_getrgba8fake6
+static void v_getrgba15 (unsigned int offset, unsigned char rgba[4])
+{
+ word32 c = ((word16 *)vl_current_read_buffer)[offset];
rgba[0] = _rgb_scale_5[(c >> 10) & 0x1F];
rgba[1] = _rgb_scale_5[(c >> 5) & 0x1F];
rgba[2] = _rgb_scale_5[c & 0x1F];
rgba[3] = 255;
}
-static void v_getrgba16 (void *buffer, int offset, unsigned char rgba[4])
+static void v_getrgba16 (unsigned int offset, unsigned char rgba[4])
{
- int c = ((word16 *)buffer)[offset];
+ word32 c = ((word16 *)vl_current_read_buffer)[offset];
rgba[0] = _rgb_scale_5[(c >> 11) & 0x1F];
rgba[1] = _rgb_scale_6[(c >> 5) & 0x3F];
rgba[2] = _rgb_scale_5[c & 0x1F];
rgba[3] = 255;
}
-static void v_getrgba24 (void *buffer, int offset, unsigned char rgba[4])
+static void v_getrgba24 (unsigned int offset, unsigned char rgba[4])
{
- int c = *(word32 *)((long)buffer+offset*3);
+ word32 c = *(word32 *)((long)vl_current_read_buffer+offset*3);
rgba[0] = c >> 16;
rgba[1] = c >> 8;
rgba[2] = c;
rgba[3] = 255;
}
-static void v_getrgba32 (void *buffer, int offset, unsigned char rgba[4])
+static void v_getrgba32 (unsigned int offset, unsigned char rgba[4])
{
- int c = ((word32 *)buffer)[offset];
+ word32 c = ((word32 *)vl_current_read_buffer)[offset];
rgba[0] = c >> 16;
rgba[1] = c >> 8;
rgba[2] = c;
@@ -171,54 +243,158 @@ static void v_getrgba32 (void *buffer, int offset, unsigned char rgba[4])
-/* vl_sync_buffer:
- * Syncs buffer with video hardware. Returns NULL in case of failure.
+/* 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: read pixel from 8bit buffer
+ *
+ * In : pixel offset
+ * Out : pixel read
+ *
+ * Note: used only for CI modes
+ */
+int vl_getCIpixel (unsigned int offset)
+{
+ return ((word8 *)vl_current_read_buffer)[offset];
+}
+
+
+
+/* Desc: set one palette entry
+ *
+ * In : color, R, G, B
+ * Out : -
+ *
+ * Note: color components are in range [0 .. 63]
+ */
+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;
+ }
+}
+
+
+
+/* Desc: sync buffer with video hardware
+ *
+ * In : old buffer, position, size
+ * Out : new buffer
+ *
+ * Note: -
*/
void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)
{
void *newbuf;
- if (width&3) {
+ if (width&7) {
return NULL;
} else {
- if ((newbuf=realloc(buffer, width*height*video_bypp))!=NULL) {
+ if ((newbuf=realloc(buffer, width * height * video_bypp)) != NULL) {
+ 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;
- current_width = width;
- vl_current_delta = video_scanlen - video_bypp * width;
+ vl_current_delta = video_scanlen - vl_current_stride;
}
- return newbuf;
+ return vl_current_draw_buffer = vl_current_read_buffer = newbuf;
}
}
-/* vl_setup_mode:
+/* Desc: retrieve CPU MMX capability
*
- * success: 0
- * failure: -1
+ * In : -
+ * Out : FALSE if CPU cannot do MMX
+ *
+ * Note: -
*/
-static int vl_setup_mode (vl_mode *p)
+int vl_can_mmx (void)
{
- if (p->mode&0x4000) {
- vl_flip = l_dump_virtual;
- } else {
- { int n; for (gran_shift=0, n=p->gran; n; gran_shift++, n>>=1) ; }
- gran_mask = (1<<(--gran_shift)) - 1;
- if ((unsigned)p->gran != (gran_mask+1)) {
- return -1;
- }
- vl_hw_granularity = p->gran;
- vl_flip = b_dump_virtual;
- }
+#ifdef USE_MMX_ASM
+ extern int _mesa_identify_x86_cpu_features (void);
+ int _mesa_x86_cpu_features = _mesa_identify_x86_cpu_features();
+ return (_mesa_x86_cpu_features & 0x00800000);
+#else
+ return 0;
+#endif
+}
+
+
+/* Desc: setup mode
+ *
+ * In : ptr to mode definition
+ * Out : 0 if success
+ *
+ * Note: -
+ */
+static int vl_setup_mode (vl_mode *p)
+{
#define INITPTR(bpp) \
vl_putpixel = v_putpixel##bpp; \
vl_getrgba = v_getrgba##bpp; \
- vl_clear = v_clear##bpp; \
+ vl_rect = v_rect##bpp; \
+ vl_mixfix = vl_mixfix##bpp; \
vl_mixrgb = vl_mixrgb##bpp; \
- vl_mixrgba = vl_mixrgba##bpp;
-
+ vl_mixrgba = vl_mixrgba##bpp; \
+ vl_clear = vl_can_mmx() ? v_clear##bpp##_mmx : v_clear##bpp
+
switch (p->bpp) {
+ case 8:
+ INITPTR(8);
+ break;
case 15:
INITPTR(15);
break;
@@ -246,9 +422,12 @@ static int vl_setup_mode (vl_mode *p)
-/* vl_video_exit:
- * Shutdown the video engine.
- * Restores to the mode prior to first call to `vl_video_init'.
+/* Desc: restore to the mode prior to first call to `vl_video_init'.
+ *
+ * In : -
+ * Out : -
+ *
+ * Note: -
*/
void vl_video_exit (void)
{
@@ -258,20 +437,33 @@ void vl_video_exit (void)
-/* vl_video_init:
- * Enter mode.
+/* Desc: enter mode
*
- * success: 0
- * failure: -1
+ * 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 refresh)
+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;
+ }
+
/* initialize hardware */
- if ((q=drv->getmodes()) == NULL) {
- return -1;
+ drv = &VESA;
+ if ((q=drv->init()) == NULL) {
+ drv = &VGA;
+ if ((q=drv->init()) == NULL) {
+ return 0;
+ }
}
/* search for a mode that fits our request */
@@ -286,9 +478,17 @@ int vl_video_init (int width, int height, int bpp, int refresh)
/* check, setup and enter mode */
if ((p!=NULL) && (vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
- return 0;
+ vl_flip = drv->blit;
+ if (fake) {
+ min = drv->getCIprec();
+ fake_buildpalette(min);
+ if (min == 8) {
+ vl_getrgba = v_getrgba8fake8;
+ }
+ }
+ return bpp;
}
/* abort */
- return -1;
+ return 0;
}
diff --git a/src/mesa/drivers/dos/video.h b/src/mesa/drivers/dos/video.h
index 868007f6fac..3197338e632 100644
--- a/src/mesa/drivers/dos/video.h
+++ b/src/mesa/drivers/dos/video.h
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.1 for Mesa 4.0
+ * DOS/DJGPP device driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -34,19 +34,24 @@
#ifndef VIDEO_H_included
#define VIDEO_H_included
-int vl_video_init (int width, int height, int bpp, int refresh);
-void vl_video_exit (void);
+typedef int fixed;
-void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);
+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) (void *buffer, int bytes, int color);
-void vl_rect (void *buffer, int x, int y, int width, int height, int color);
+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);
-void (*vl_flip) (void *buffer, int stride, int height);
+void vl_setCI (int index, float red, float green, float blue);
+int vl_getCIpixel (unsigned int offset);
-extern int (*vl_mixrgba) (const unsigned char rgba[]);
-extern int (*vl_mixrgb) (const unsigned char rgb[]);
-extern void (*vl_putpixel) (void *buffer, int offset, int color);
-extern void (*vl_getrgba) (void *buffer, int offset, unsigned char rgba[4]);
+void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);
+
+void vl_video_exit (void);
+int vl_video_init (int width, int height, int bpp, int rgb, int refresh);
#endif
diff --git a/src/mesa/drivers/dos/virtual.S b/src/mesa/drivers/dos/virtual.S
index 3633161c982..4dbbbb3e3f8 100644
--- a/src/mesa/drivers/dos/virtual.S
+++ b/src/mesa/drivers/dos/virtual.S
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.1 for Mesa 4.0
+ * DOS/DJGPP device driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -34,60 +34,153 @@
.file "virtual.S"
/*
- * extern word32 vl_hw_granularity;
- * extern int vl_video_selector;
- * extern int vl_current_offset, vl_current_delta;
+ * extern void *vl_current_draw_buffer;
+ * extern int vl_current_width, vl_current_bytes;
*/
.text
-/*
- * void v_clear16 (void *buffer, int bytes, int color);
+/* Desc: void v_clear8 (int color);
+ *
+ * In : color
+ * Out : -
+ *
+ * Note: uses current draw buffer
*/
- .balign 4
+ .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 12(%esp), %eax
+ movl 4(%esp), %eax
pushw %ax
pushw %ax
popl %eax
jmp _v_clear_common
-/*
- * void v_clear32 (void *buffer, int bytes, int color);
+/* Desc: void v_clear32 (int color);
+ *
+ * In : color
+ * Out : -
+ *
+ * Note: uses current draw buffer
*/
- .balign 4
+ .p2align 5,,31
.global _v_clear32
_v_clear32:
- movl 12(%esp), %eax
+ movl 4(%esp), %eax
.balign 4
_v_clear_common:
- movl 8(%esp), %ecx
- movl 4(%esp), %edx
+ movl _vl_current_bytes, %ecx
+ movl _vl_current_draw_buffer, %edx
shrl $2, %ecx
- 0:
.balign 4
+ 0:
movl %eax, (%edx)
addl $4, %edx
decl %ecx
jnz 0b
ret
-/*
- * void v_clear24 (void *buffer, int bytes, int color);
+/* 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:
+ movl 4(%esp), %eax
+ movb %al, %ah
+ pushw %ax
+ pushw %ax
+ pushw %ax
+ pushw %ax
+ jmp _v_clear_common_mmx
+
+/* 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:
+ movl 4(%esp), %eax
+ pushw %ax
+ pushw %ax
+ pushw %ax
+ pushw %ax
+ jmp _v_clear_common_mmx
+
+/* 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:
+ movl 4(%esp), %eax
+ pushl %eax
+ pushl %eax
.balign 4
+_v_clear_common_mmx:
+#ifdef USE_MMX_ASM
+ movl _vl_current_bytes, %ecx
+ movl _vl_current_draw_buffer, %edx
+ movq (%esp), %mm0
+ shrl $3, %ecx
+ .balign 4
+ 0:
+ movq %mm0, (%edx)
+ addl $8, %edx
+ decl %ecx
+ jnz 0b
+ emms
+#endif
+ addl $8, %esp
+ ret
+
+/* Desc: void v_clear24 (int color);
+ *
+ * In : color
+ * Out : -
+ *
+ * Note: uses current draw buffer
+ */
+ .p2align 5,,31
.global _v_clear24
_v_clear24:
- movl 8(%esp), %edx
movl $0xaaaaaaab, %eax
- mull %edx
- movl 12(%esp), %eax
+ mull _vl_current_bytes
+ movl 4(%esp), %eax
movl %edx, %ecx
- movl 4(%esp), %edx
pushl %ebx
+ movl _vl_current_draw_buffer, %edx
shrl %ecx
- movb 18(%esp), %bl
+ movb 10(%esp), %bl
.balign 4
0:
movw %ax, (%edx)
@@ -98,140 +191,304 @@ _v_clear24:
popl %ebx
ret
-/*
- * void b_dump_virtual (void *buffer, int stride, int height);
+/* 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
- .global _b_dump_virtual
-_b_dump_virtual:
- pushl %ebx
+ 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
- pushl %ebp
- movl _vl_video_selector, %fs
- movl 4*4+4+0(%esp), %esi
- movl _vl_hw_granularity, %ebp
- xorl %edx, %edx
- movl _vl_current_offset, %eax
- divl %ebp
- movl %edx, %edi
- pushl %eax
- movl %eax, %edx
- xorl %ebx, %ebx
- movw $0x4f05, %ax
- int $0x10
- movl _vl_current_delta, %ebx
- movl 5*4+4+4(%esp), %ecx
- movl 5*4+4+8(%esp), %edx
- shrl $2, %ecx
+ 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:
- cmpl %ebp, %edi
- jb 2f
- pushl %ebx
- pushl %edx
- incl 12(%esp)
- movw $0x4f05, %ax
- movl 12(%esp), %edx
- xorl %ebx, %ebx
- int $0x10
- popl %edx
+ 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
- subl %ebp, %edi
+ 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:
- movl (%esi), %eax
- addl $4, %esi
- movl %eax, %fs:(%edi)
- addl $4, %edi
+ 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 %ebx, %edi
+ addl %esi, %edi
decl %edx
jnz 0b
- popl %eax
- popl %ebp
+ popl %ebx
popl %edi
popl %esi
- popl %ebx
ret
-/*
- * void l_dump_virtual (void *buffer, int stride, int height);
+/* Desc: void v_rect32 (int color);
+ *
+ * In : color
+ * Out : -
+ *
+ * Note: uses current draw buffer
*/
- .balign 4
- .global _l_dump_virtual
-_l_dump_virtual:
- pushl %ebx
+ .p2align 5,,31
+ .global _v_rect32
+_v_rect32:
pushl %esi
pushl %edi
- movl _vl_video_selector, %fs
- movl 3*4+4+0(%esp), %esi
- movl _vl_current_offset, %edi
- movl 3*4+4+4(%esp), %ecx
- movl 3*4+4+8(%esp), %edx
- movl _vl_current_delta, %ebx
- shrl $2, %ecx
+ 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 (%esi), %eax
- addl $4, %esi
- movl %eax, %fs:(%edi)
+ movl %eax, (%edi)
addl $4, %edi
decl %ecx
jnz 1b
popl %ecx
- addl %ebx, %edi
+ addl %esi, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
- popl %ebx
ret
-/*
- * void v_putpixel16 (void *buffer, int offset, int color);
+/* Desc: void v_putpixel8 (unsigned int offset, int color);
+ *
+ * In : offset within buffer, color
+ * Out : -
+ *
+ * Note: uses current draw buffer
*/
- .balign 4
+ .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), %edx
- shll %edx
- movl 12(%esp), %eax
- addl 4(%esp), %edx
- movw %ax, (%edx)
+ movl 8(%esp), %ecx
+ movl 4(%esp), %edx
+ movl _vl_current_draw_buffer, %eax
+ movw %cx, (%eax,%edx,2)
ret
-/*
- * void v_putpixel24 (void *buffer, int offset, int color);
+/* Desc: void v_putpixel24 (unsigned int offset, int color);
+ *
+ * In : offset within buffer, color
+ * Out : -
+ *
+ * Note: uses current draw buffer
*/
- .balign 4
+ .p2align 5,,31
.global _v_putpixel24
_v_putpixel24:
+ movl 4(%esp), %eax
movl 8(%esp), %edx
- leal (%edx, %edx, 2), %edx
- movl 12(%esp), %eax
- addl 4(%esp), %edx
- movw %ax, (%edx)
- shrl $16, %eax
- movb %al, 2(%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
-/*
- * void v_putpixel32 (void *buffer, int offset, int color);
+/* Desc: void v_putpixel32 (unsigned int offset, int color);
+ *
+ * In : offset within buffer, color
+ * Out : -
+ *
+ * Note: uses current draw buffer
*/
- .balign 4
+ .p2align 5,,31
.global _v_putpixel32
_v_putpixel32:
- movl 8(%esp), %edx
- shll $2, %edx
- movl 12(%esp), %eax
- addl 4(%esp), %edx
- movl %eax, (%edx)
+ movl 8(%esp), %ecx
+ movl 4(%esp), %edx
+ movl _vl_current_draw_buffer, %eax
+ movl %ecx, (%eax,%edx,4)
ret