summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dos
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dos')
-rw-r--r--src/mesa/drivers/dos/dmesa.c58
-rw-r--r--src/mesa/drivers/dos/dpmi.c8
-rw-r--r--src/mesa/drivers/dos/dpmiint.h10
-rw-r--r--src/mesa/drivers/dos/vesa/vesa.c397
-rw-r--r--src/mesa/drivers/dos/vesa/vesa.h43
-rw-r--r--src/mesa/drivers/dos/video.c439
-rw-r--r--src/mesa/drivers/dos/video.h10
-rw-r--r--src/mesa/drivers/dos/videoint.h99
-rw-r--r--src/mesa/drivers/dos/virtual.S237
9 files changed, 881 insertions, 420 deletions
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 5855f04f3e7..148d7402e2e 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.0 for Mesa 4.0
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -38,7 +38,6 @@
#include "context.h"
#include "GL/dmesa.h"
#include "extensions.h"
-#inlcude "imports.h"
#include "macros.h"
#include "matrix.h"
#include "mmath.h"
@@ -80,10 +79,9 @@ struct dmesa_buffer {
GLframebuffer gl_buffer; /* The depth, stencil, accum, etc buffers */
void *the_window; /* your window handle, etc */
- int bypp; /* bytes per pixel */
int xpos, ypos; /* position */
int width, height; /* size in pixels */
- int bwidth, len; /* bytes in a line, then total */
+ int bypp, stride, bytes; /* bytes per pixel, in a line, then total */
};
/*
@@ -413,7 +411,7 @@ static swrast_tri_func dmesa_choose_tri_function (GLcontext *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->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
if (ctx->Light.ShadeModel==GL_SMOOTH
&& swrast->_RasterMask==DEPTH_BIT
@@ -494,7 +492,7 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,
if (*colorMask==0xffffffff) {
if (mask & DD_BACK_LEFT_BIT) {
if (all) {
- vl_clear(b->the_window, b->len, c->ClearColor);
+ vl_clear(b->the_window, b->bytes, c->ClearColor);
} else {
vl_rect(b->the_window, x, y, width, height, c->ClearColor);
}
@@ -512,12 +510,24 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,
/*
* Set the current reading buffer.
*/
-static void set_buffer (GLcontext *ctx, GLframebuffer *buffer, GLenum mode)
+static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer,
+ GLenum mode)
{
+ /*
+ XXX this has to be fixed
+ */
+}
+
+
+
/*
- DMesaContext c = (DMesaContext)ctx->DriverCtx;
- dmesa_update_state(ctx);
-*/
+ * Set the destination/draw buffer.
+ */
+static void set_draw_buffer (GLcontext *ctx, GLenum mode)
+{
+ /*
+ XXX this has to be fixed
+ */
}
@@ -541,7 +551,7 @@ static const GLubyte* get_string (GLcontext *ctx, GLenum name)
{
switch (name) {
case GL_RENDERER:
- return (const GLubyte *)"Mesa DOS\0DJGPP port (c) Borca Daniel 31-mar-2002";
+ return (const GLubyte *)"Mesa DJGPP\0port (c) Borca Daniel 3-sep-2002";
default:
return NULL;
}
@@ -627,7 +637,6 @@ void dmesa_init_pointers (GLcontext *ctx)
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
/* Software texture functions:
*/
@@ -659,6 +668,7 @@ void dmesa_init_pointers (GLcontext *ctx)
/* Statechange callbacks:
*/
+ ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ClearColor = clear_color;
/* Initialize the TNL driver interface:
@@ -686,7 +696,7 @@ static void dmesa_update_state (GLcontext *ctx, GLuint new_state)
_ac_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
- swdd->SetBuffer = set_buffer;
+ swdd->SetReadBuffer = set_read_buffer;
/* RGB(A) span/pixel functions */
swdd->WriteRGBASpan = write_rgba_span;
@@ -717,6 +727,12 @@ DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
DMesaVisual v;
GLint redBits, greenBits, blueBits, alphaBits;
+ int refresh;
+ char *var = getenv("DMESA_REFRESH");
+ if ((var == NULL) || ((refresh=atoi(var)) == 0)) {
+ refresh = 60;
+ }
+
if (!dbFlag) {
return NULL;
}
@@ -743,7 +759,7 @@ DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
return NULL;
}
- if (vl_video_init(width, height, colDepth)!=0) {
+ if (vl_video_init(width, height, colDepth, refresh) != 0) {
return NULL;
}
@@ -776,7 +792,7 @@ DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
void DMesaDestroyVisual (DMesaVisual v)
{
- vl_video_exit(!0);
+ vl_video_exit();
_mesa_destroy_visual(v->gl_visual);
free(v);
}
@@ -825,11 +841,9 @@ DMesaContext DMesaCreateContext (DMesaVisual visual,
GLboolean direct = GL_FALSE;
if ((c=(DMesaContext)calloc(1, sizeof(struct dmesa_context)))!=NULL) {
- __GLimports imports;
- _mesa_init_default_imports( &imports, (void *) c);
c->gl_ctx = _mesa_create_context(visual->gl_visual,
share ? share->gl_ctx : NULL,
- &imports);
+ (void *)c, direct);
_mesa_enable_sw_extensions(c->gl_ctx);
_mesa_enable_1_3_extensions(c->gl_ctx);
@@ -874,8 +888,8 @@ GLboolean DMesaViewport (DMesaBuffer b,
b->ypos = ypos;
b->width = width;
b->height = height;
- b->bwidth = width * b->bypp;
- b->len = b->bwidth * height;
+ b->stride = width * b->bypp;
+ b->bytes = b->stride * height;
return GL_TRUE;
}
}
@@ -913,5 +927,7 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
void DMesaSwapBuffers (DMesaBuffer b)
{
/* copy/swap back buffer to front if applicable */
- vl_flip(b->the_window, b->bwidth, b->height);
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_swapbuffers(ctx);
+ vl_flip(b->the_window, b->stride, b->height);
}
diff --git a/src/mesa/drivers/dos/dpmi.c b/src/mesa/drivers/dos/dpmi.c
index 0cc0a89e64e..60610acddf2 100644
--- a/src/mesa/drivers/dos/dpmi.c
+++ b/src/mesa/drivers/dos/dpmi.c
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.0 for Mesa 4.0
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -37,6 +37,12 @@
+#ifndef MAX
+#define MAX(x, y) (((x)<(y))?(y):(x))
+#endif
+
+
+
/* _create_linear_mapping:
* Maps a physical address range into linear memory.
*/
diff --git a/src/mesa/drivers/dos/dpmiint.h b/src/mesa/drivers/dos/dpmiint.h
index d0171fb1009..c32fadbf002 100644
--- a/src/mesa/drivers/dos/dpmiint.h
+++ b/src/mesa/drivers/dos/dpmiint.h
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.0 for Mesa 4.0
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -34,14 +34,6 @@
#ifndef DPMIINT_H_included
#define DPMIINT_H_included
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef MAX
-#define MAX(x, y) (((x)<(y))?(y):(x))
-#endif
-
int _create_selector (int *segment, unsigned long base, int size);
void _remove_selector (int *segment);
diff --git a/src/mesa/drivers/dos/vesa/vesa.c b/src/mesa/drivers/dos/vesa/vesa.c
new file mode 100644
index 00000000000..c43b6ec4284
--- /dev/null
+++ b/src/mesa/drivers/dos/vesa/vesa.c
@@ -0,0 +1,397 @@
+/*
+ * 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.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : [email protected]
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include <dpmi.h>
+#include <string.h>
+#include <stubinfo.h>
+#include <sys/exceptn.h>
+#include <sys/segments.h>
+#include <sys/farptr.h>
+#include <sys/movedata.h>
+
+#include "vesa.h"
+#include "../dpmiint.h"
+
+
+
+static vl_mode modes[64];
+
+static word16 vesa_ver;
+static int banked_selector, linear_selector;
+static int oldmode = -1;
+
+
+
+/*
+ * 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)
+
+
+
+/* vesa_init:
+ * Attempts to detect VESA, check video modes and create selectors.
+ * Returns 0 if error.
+ */
+static word16 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 vesa_ver;
+ }
+
+ _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 0;
+ }
+
+ 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 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) {
+#if 0
+ *(q+1) = *q++;
+#else
+ vl_mode *q1 = q + 1;
+ *q1 = *q++;
+#endif
+ 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 0;
+ }
+ if (linearfb) {
+ maxsize = ((maxsize+0xfffUL)&~0xfffUL);
+ if (_create_selector(&linear_selector, linearfb, maxsize)) {
+ return 0;
+ }
+ }
+ if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) {
+ _remove_selector(&linear_selector);
+ return 0;
+ }
+
+ for (q=modes; q->mode!=0xffff; q++) {
+ q->sel = (q->mode&0x4000) ? linear_selector : banked_selector;
+ }
+
+ return (vesa_ver = _16_ vesa_info[V_MINOR]);
+}
+
+
+
+/* vesa_finit:
+ * Frees all resources allocated by VESA init code.
+ */
+static void vesa_finit (void)
+{
+ if (vesa_ver) {
+ _remove_selector(&linear_selector);
+ _remove_selector(&banked_selector);
+ }
+}
+
+
+
+/* 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.
+ */
+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;
+}
+
+
+
+/* _crtc_timing:
+ * Calculates CRTC mode timings.
+ */
+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;
+}
+
+
+
+/* vesa_entermode:
+ * Attempts to enter specified video mode.
+ *
+ * success: 0
+ * failure: !0
+ */
+static int vesa_entermode (vl_mode *p, int refresh)
+{
+ __dpmi_regs r;
+
+ 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 ((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);
+
+ return (r.x.ax != 0x004f);
+}
+
+
+
+/* vesa_restore:
+ * Restores to the mode prior to first call to vesa_entermode.
+ */
+static void vesa_restore (void)
+{
+ __dpmi_regs r;
+
+ if (oldmode != -1) {
+ r.x.ax = 0x4f02;
+ r.x.bx = oldmode;
+ __dpmi_int(0x10, &r);
+ }
+}
+
+
+
+/*
+ * the driver
+ */
+vl_driver VESA = {
+ vesa_getmodes,
+ vesa_entermode,
+ vesa_restore,
+ vesa_finit
+};
diff --git a/src/mesa/drivers/dos/vesa/vesa.h b/src/mesa/drivers/dos/vesa/vesa.h
new file mode 100644
index 00000000000..22ecbd538ab
--- /dev/null
+++ b/src/mesa/drivers/dos/vesa/vesa.h
@@ -0,0 +1,43 @@
+/*
+ * 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.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : [email protected]
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef VESA_H_included
+#define VESA_H_included
+
+#include "../videoint.h"
+
+
+
+extern vl_driver VESA;
+
+#endif
diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c
index d31037de616..16e72cf5810 100644
--- a/src/mesa/drivers/dos/video.c
+++ b/src/mesa/drivers/dos/video.c
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.0 for Mesa 4.0
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -31,52 +31,29 @@
*/
-#include <dpmi.h>
#include <stdlib.h>
-#include <string.h>
-#include <stubinfo.h>
-#include <sys/exceptn.h>
-#include <sys/segments.h>
-#include <sys/farptr.h>
#include "video.h"
-#include "dpmiint.h"
+#include "videoint.h"
+#include "vesa/vesa.h"
-typedef unsigned char word8;
-typedef unsigned short word16;
-typedef unsigned long word32;
-
-typedef struct vl_mode {
- int mode;
- int xres, yres;
- int scanlen;
- int bpp;
-} vl_mode;
-
-#define _16_ *(word16 *)&
-#define _32_ *(word32 *)&
-
-static int init;
-
-static vl_mode modes[64];
-
+static vl_driver *drv = &VESA;
/* card specific: valid forever */
-static word16 vesa_ver;
-static word32 hw_granularity, hw_linearfb;
+word32 vl_hw_granularity;
static unsigned int gran_shift, gran_mask;
/* based upon mode specific data: valid entire session */
-static int video_selector, banked_selector, linear_selector;
+int vl_video_selector;
static int video_scanlen, video_bypp;
/* valid until next buffer */
-static int current_offset, current_delta, current_width;
+int vl_current_offset, vl_current_delta;
+static int current_width;
/* lookup table for scaling 5 bit colors up to 8 bits */
-static int _rgb_scale_5[32] =
-{
+static int _rgb_scale_5[32] = {
0, 8, 16, 24, 32, 41, 49, 57,
65, 74, 82, 90, 98, 106, 115, 123,
131, 139, 148, 156, 164, 172, 180, 189,
@@ -84,8 +61,7 @@ static int _rgb_scale_5[32] =
};
/* lookup table for scaling 6 bit colors up to 8 bits */
-static int _rgb_scale_6[64] =
-{
+static int _rgb_scale_6[64] = {
0, 4, 8, 12, 16, 20, 24, 28,
32, 36, 40, 44, 48, 52, 56, 60,
64, 68, 72, 76, 80, 85, 89, 93,
@@ -98,69 +74,17 @@ static int _rgb_scale_6[64] =
-/*
- * virtual clearing
- */
-void (*vl_clear) (void *buffer, int len, int color);
-
-#define v_clear15 v_clear16
-extern void v_clear16 (void *buffer, int len, int color);
-extern void v_clear32 (void *buffer, int len, int color);
-__asm__("\n\
- .text \n\
- .balign 4 \n\
- .global _v_clear16 \n\
-_v_clear16: \n\
- movl 12(%esp), %eax \n\
- pushw %ax \n\
- pushw %ax \n\
- popl %eax \n\
- jmp _v_clear_common \n\
- .balign 4 \n\
- .global _v_clear32 \n\
-_v_clear32: \n\
- movl 12(%esp), %eax \n\
- .balign 4 \n\
-_v_clear_common: \n\
- movl 8(%esp), %ecx \n\
- movl 4(%esp), %edx \n\
- shrl $2, %ecx \n\
- 0: \n\
- .balign 4 \n\
- movl %eax, (%edx) \n\
- addl $4, %edx \n\
- decl %ecx \n\
- jnz 0b \n\
- ret");
-extern void v_clear24 (void *buffer, int len, int color);
-__asm__("\n\
- .text \n\
- .balign 4 \n\
- .global _v_clear24 \n\
-_v_clear24: \n\
- movl 8(%esp), %edx \n\
- movl $0xaaaaaaab, %eax \n\
- mull %edx \n\
- movl 12(%esp), %eax \n\
- movl %edx, %ecx \n\
- movl 4(%esp), %edx \n\
- pushl %ebx \n\
- shrl %ecx \n\
- movb 18(%esp), %bl \n\
- .balign 4 \n\
- 0: \n\
- movw %ax, (%edx) \n\
- movb %bl, 2(%edx) \n\
- addl $3, %edx \n\
- decl %ecx \n\
- jnz 0b \n\
- popl %ebx \n\
- ret");
+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[]);
+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]);
-/*
- * virtual rectangle clearing
+/* vl_rect:
+ * Clears a rectange with specified color.
*/
void vl_rect (void *buffer, int x, int y, int width, int height, int color)
{
@@ -177,114 +101,9 @@ void vl_rect (void *buffer, int x, int y, int width, int height, int color)
-/*
- * virtual dumping:
+/* vl_mixrgba*:
+ * Color composition (w/ ALPHA).
*/
-void (*vl_flip) (void *buffer, int width, int height);
-
-extern void b_dump_virtual (void *buffer, int width, int height);
-__asm__("\n\
- .text \n\
- .balign 4 \n\
- .global _b_dump_virtual \n\
-_b_dump_virtual: \n\
- pushl %ebx \n\
- pushl %esi \n\
- pushl %edi \n\
- pushl %ebp \n\
- movl _video_selector, %fs \n\
- movl 4*4+4+0(%esp), %esi \n\
- movl _hw_granularity, %ebp \n\
- xorl %edx, %edx \n\
- movl _current_offset, %eax \n\
- divl %ebp \n\
- movl %edx, %edi \n\
- pushl %eax \n\
- movl %eax, %edx \n\
- xorl %ebx, %ebx \n\
- movw $0x4f05, %ax \n\
- int $0x10 \n\
- movl _current_delta, %ebx \n\
- movl 5*4+4+4(%esp), %ecx \n\
- movl 5*4+4+8(%esp), %edx \n\
- shrl $2, %ecx \n\
- .balign 4 \n\
- 0: \n\
- pushl %ecx \n\
- .balign 4 \n\
- 1: \n\
- cmpl %ebp, %edi \n\
- jb 2f \n\
- pushl %ebx \n\
- pushl %edx \n\
- incl 12(%esp) \n\
- movw $0x4f05, %ax \n\
- movl 12(%esp), %edx \n\
- xorl %ebx, %ebx \n\
- int $0x10 \n\
- popl %edx \n\
- popl %ebx \n\
- subl %ebp, %edi \n\
- 2: \n\
- movl (%esi), %eax \n\
- addl $4, %esi \n\
- movl %eax, %fs:(%edi) \n\
- addl $4, %edi \n\
- decl %ecx \n\
- jnz 1b \n\
- popl %ecx \n\
- addl %ebx, %edi \n\
- decl %edx \n\
- jnz 0b \n\
- popl %eax \n\
- popl %ebp \n\
- popl %edi \n\
- popl %esi \n\
- popl %ebx \n\
- ret");
-extern void l_dump_virtual (void *buffer, int width, int height);
-__asm__("\n\
- .text \n\
- .balign 4 \n\
- .global _l_dump_virtual \n\
-_l_dump_virtual: \n\
- pushl %ebx \n\
- pushl %esi \n\
- pushl %edi \n\
- movl _video_selector, %fs \n\
- movl 3*4+4+0(%esp), %esi \n\
- movl _current_offset, %edi \n\
- movl 3*4+4+4(%esp), %ecx \n\
- movl 3*4+4+8(%esp), %edx \n\
- movl _current_delta, %ebx \n\
- shrl $2, %ecx \n\
- .balign 4 \n\
- 0: \n\
- pushl %ecx \n\
- .balign 4 \n\
- 1: \n\
- movl (%esi), %eax \n\
- addl $4, %esi \n\
- movl %eax, %fs:(%edi) \n\
- addl $4, %edi \n\
- decl %ecx \n\
- jnz 1b \n\
- popl %ecx \n\
- addl %ebx, %edi \n\
- decl %edx \n\
- jnz 0b \n\
- popl %edi \n\
- popl %esi \n\
- popl %ebx \n\
- ret");
-
-
-
-/*
- * mix RGBA components
- */
-int (*vl_mixrgba) (const unsigned char rgba[]);
-
#define vl_mixrgba15 vl_mixrgb15
#define vl_mixrgba16 vl_mixrgb16
#define vl_mixrgba24 vl_mixrgb24
@@ -295,11 +114,9 @@ static int vl_mixrgba32 (const unsigned char rgba[])
-/*
- * mix RGB components
+/* vl_mixrgb*:
+ * Color composition (w/o ALPHA).
*/
-int (*vl_mixrgb) (const unsigned char rgb[]);
-
static int vl_mixrgb15 (const unsigned char rgb[])
{
return ((rgb[0]>>3)<<10)|((rgb[1]>>3)<<5)|(rgb[2]>>3);
@@ -316,60 +133,8 @@ static int vl_mixrgb32 (const unsigned char rgb[])
-/*
- * vl_putpixel*
- */
-void (*vl_putpixel) (void *buffer, int offset, int color);
-
-#define v_putpixel15 v_putpixel16
-extern void v_putpixel16 (void *buffer, int offset, int color);
-__asm__("\n\
- .text \n\
- .balign 4 \n\
- .global _v_putpixel16 \n\
-_v_putpixel16: \n\
- movl 8(%esp), %edx \n\
- shll %edx \n\
- movl 12(%esp), %eax \n\
- addl 4(%esp), %edx \n\
- movw %ax, (%edx) \n\
- ret");
-extern void v_putpixel24 (void *buffer, int offset, int color);
-__asm__("\n\
- .text \n\
- .balign 4 \n\
- .global _v_putpixel24 \n\
-_v_putpixel24: \n\
- movl 8(%esp), %edx \n\
- leal (%edx, %edx, 2), %edx \n\
- movl 12(%esp), %eax \n\
- addl 4(%esp), %edx \n\
- movw %ax, (%edx) \n\
- shrl $16, %eax \n\
- movb %al, 2(%edx) \n\
- ret");
-extern void v_putpixel32 (void *buffer, int offset, int color);
-__asm__("\n\
- .text \n\
- .balign 4 \n\
- .global _v_putpixel32 \n\
-_v_putpixel32: \n\
- movl 8(%esp), %edx \n\
- shll $2, %edx \n\
- movl 12(%esp), %eax \n\
- addl 4(%esp), %edx \n\
- movl %eax, (%edx) \n\
- ret");
-
-
-
-/*
- * get pixel and decompose R, G, B, A
- */
-void (*vl_getrgba) (void *buffer, int offset, unsigned char rgba[4]);
-
-/*
- * v_getrgba*
+/* v_getrgba*:
+ * Color decomposition.
*/
static void v_getrgba15 (void *buffer, int offset, unsigned char rgba[4])
{
@@ -406,8 +171,8 @@ static void v_getrgba32 (void *buffer, int offset, unsigned char rgba[4])
-/*
- * sync buffer with video hardware
+/* vl_sync_buffer:
+ * Syncs buffer with video hardware. Returns NULL in case of failure.
*/
void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)
{
@@ -417,9 +182,9 @@ void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)
return NULL;
} else {
if ((newbuf=realloc(buffer, width*height*video_bypp))!=NULL) {
- current_offset = video_scanlen * y + video_bypp * x;
+ vl_current_offset = video_scanlen * y + video_bypp * x;
current_width = width;
- current_delta = video_scanlen - video_bypp * width;
+ vl_current_delta = video_scanlen - video_bypp * width;
}
return newbuf;
}
@@ -427,102 +192,22 @@ void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)
-/*
- * attempts to detect VESA and video modes
- */
-static word16 vl_vesa_init (void)
-{
- __dpmi_regs r;
- unsigned short *p;
- vl_mode *q;
- char vesa_info[512], tmp[512];
- int maxsize = 0;
-
- _farpokel(_stubinfo->ds_selector, 0, 0x32454256);
- r.x.ax = 0x4f00;
- r.x.di = 0;
- r.x.es = _stubinfo->ds_segment;
- __dpmi_int(0x10, &r);
- if (r.x.ax==0x004f) {
- movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512);
- if ((_32_ vesa_info[0])==0x41534556) {
- p = (unsigned short *)(((_16_ vesa_info[0x10])<<4) + (_16_ vesa_info[0x0e]));
- 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[0x19]) {
- case 16:
- q->bpp = tmp[0x1f] + tmp[0x21] + tmp[0x23];
- break;
- case 15:
- case 24:
- case 32:
- q->bpp = tmp[0x19];
- break;
- default:
- q->bpp = 0;
- }
- if ((r.x.ax==0x004f)&&((tmp[0]&0x11)==0x11)&&q->bpp) {
- q->xres = _16_ tmp[0x12];
- q->yres = _16_ tmp[0x14];
- q->scanlen = _16_ tmp[0x10];
- hw_granularity = (_16_ tmp[4])<<10;
- if (tmp[0]&0x80) {
- *(q+1) = *q++;
- hw_linearfb = _32_ tmp[0x28];
- q->mode |= 0x4000;
- }
- if (maxsize<(q->scanlen*q->yres)) {
- maxsize = q->scanlen*q->yres;
- }
- q++;
- }
- } while (!0);
-
- if (hw_linearfb) {
- maxsize = ((maxsize+0xfffUL)&~0xfffUL);
- if (_create_selector(&linear_selector, hw_linearfb, maxsize)) {
- return 0;
- }
- }
- if (_create_selector(&banked_selector, 0xa0000, hw_granularity)) {
- _remove_selector(&linear_selector);
- return 0;
- }
-
- return _16_ vesa_info[4];
- }
- }
-
- return 0;
-}
-
-
-
-/*
- * setup mode
+/* vl_setup_mode:
+ *
+ * success: 0
+ * failure: -1
*/
static int vl_setup_mode (vl_mode *p)
{
if (p->mode&0x4000) {
- video_selector = linear_selector;
vl_flip = l_dump_virtual;
} else {
- { int n; for (gran_shift=0, n=hw_granularity; n; gran_shift++, n>>=1) ; }
+ { int n; for (gran_shift=0, n=p->gran; n; gran_shift++, n>>=1) ; }
gran_mask = (1<<(--gran_shift)) - 1;
- if (hw_granularity!=(gran_mask+1)) {
+ if ((unsigned)p->gran != (gran_mask+1)) {
return -1;
}
- video_selector = banked_selector;
+ vl_hw_granularity = p->gran;
vl_flip = b_dump_virtual;
}
@@ -554,56 +239,44 @@ static int vl_setup_mode (vl_mode *p)
video_bypp = (p->bpp+7)/8;
video_scanlen = p->scanlen;
+ vl_video_selector = p->sel;
return 0;
}
-/*
- * shutdown the video engine
+/* vl_video_exit:
+ * Shutdown the video engine.
+ * Restores to the mode prior to first call to `vl_video_init'.
*/
-void vl_video_exit (int textmode)
+void vl_video_exit (void)
{
- if (init) {
- if (textmode) {
- __asm__("movw $0x3, %%ax; int $0x10":::"%eax");
- }
-
- _remove_selector(&linear_selector);
- _remove_selector(&banked_selector);
-
- init = !init;
- }
+ drv->restore();
+ drv->finit();
}
-/*
- * initialize video engine
+/* vl_video_init:
+ * Enter mode.
*
- * success: 0
- * failure: -1
+ * success: 0
+ * failure: -1
*/
-int vl_video_init (int width, int height, int bpp)
+int vl_video_init (int width, int height, int bpp, int refresh)
{
vl_mode *p, *q;
unsigned int min;
- /* check for prior initialization */
- if (init) {
- return 0;
- }
-
/* initialize hardware */
- if (!(vesa_ver=vl_vesa_init())) {
+ if ((q=drv->getmodes()) == NULL) {
return -1;
}
- init = !init;
/* search for a mode that fits our request */
- for (min=-1, p=NULL, q=modes; q->mode!=0xffff; q++) {
- if ((q->xres>=width)&&(q->yres>=height)&&(q->bpp==bpp)) {
+ 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;
@@ -611,13 +284,11 @@ int vl_video_init (int width, int height, int bpp)
}
}
- if (p) {
- vl_setup_mode(p);
- __asm__("movw $0x4f02, %%ax; int $0x10"::"b"(p->mode):"%eax");
+ /* check, setup and enter mode */
+ if ((p!=NULL) && (vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
return 0;
- } else {
- /* no suitable mode found, abort */
- vl_video_exit(0);
- return -1;
}
+
+ /* abort */
+ return -1;
}
diff --git a/src/mesa/drivers/dos/video.h b/src/mesa/drivers/dos/video.h
index 46a1e22d30d..868007f6fac 100644
--- a/src/mesa/drivers/dos/video.h
+++ b/src/mesa/drivers/dos/video.h
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v1.0 for Mesa 4.0
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -34,15 +34,15 @@
#ifndef VIDEO_H_included
#define VIDEO_H_included
-int vl_video_init (int width, int height, int bpp);
-void vl_video_exit (int textmode);
+int vl_video_init (int width, int height, int bpp, int refresh);
+void vl_video_exit (void);
void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);
-extern void (*vl_clear) (void *buffer, int len, int color);
+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);
-void (*vl_flip) (void *buffer, int width, int height);
+void (*vl_flip) (void *buffer, int stride, int height);
extern int (*vl_mixrgba) (const unsigned char rgba[]);
extern int (*vl_mixrgb) (const unsigned char rgb[]);
diff --git a/src/mesa/drivers/dos/videoint.h b/src/mesa/drivers/dos/videoint.h
new file mode 100644
index 00000000000..87aa9837061
--- /dev/null
+++ b/src/mesa/drivers/dos/videoint.h
@@ -0,0 +1,99 @@
+/*
+ * 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.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : [email protected]
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef VIDEOINT_H_included
+#define VIDEOINT_H_included
+
+/*
+ * 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 *(*getmodes) (void);
+ int (*entermode) (vl_mode *p, int refresh);
+ void (*restore) (void);
+ void (*finit) (void);
+} vl_driver;
+
+
+
+/*
+ * asm routines to deal with virtual buffering
+ */
+#define v_clear15 v_clear16
+extern void v_clear16 (void *buffer, int bytes, int color);
+extern void v_clear32 (void *buffer, int bytes, int color);
+extern void v_clear24 (void *buffer, int bytes, int color);
+
+extern void b_dump_virtual (void *buffer, int stride, int height);
+extern void l_dump_virtual (void *buffer, int stride, int height);
+
+#define v_putpixel15 v_putpixel16
+extern void v_putpixel16 (void *buffer, int offset, int color);
+extern void v_putpixel24 (void *buffer, int offset, int color);
+extern void v_putpixel32 (void *buffer, int offset, int color);
+
+#endif
diff --git a/src/mesa/drivers/dos/virtual.S b/src/mesa/drivers/dos/virtual.S
new file mode 100644
index 00000000000..3633161c982
--- /dev/null
+++ b/src/mesa/drivers/dos/virtual.S
@@ -0,0 +1,237 @@
+/*
+ * 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.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : [email protected]
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+ .file "virtual.S"
+
+/*
+ * extern word32 vl_hw_granularity;
+ * extern int vl_video_selector;
+ * extern int vl_current_offset, vl_current_delta;
+ */
+
+ .text
+
+/*
+ * void v_clear16 (void *buffer, int bytes, int color);
+ */
+ .balign 4
+ .global _v_clear16
+_v_clear16:
+ movl 12(%esp), %eax
+ pushw %ax
+ pushw %ax
+ popl %eax
+ jmp _v_clear_common
+
+/*
+ * void v_clear32 (void *buffer, int bytes, int color);
+ */
+ .balign 4
+ .global _v_clear32
+_v_clear32:
+ movl 12(%esp), %eax
+ .balign 4
+_v_clear_common:
+ movl 8(%esp), %ecx
+ movl 4(%esp), %edx
+ shrl $2, %ecx
+ 0:
+ .balign 4
+ movl %eax, (%edx)
+ addl $4, %edx
+ decl %ecx
+ jnz 0b
+ ret
+
+/*
+ * void v_clear24 (void *buffer, int bytes, int color);
+ */
+ .balign 4
+ .global _v_clear24
+_v_clear24:
+ movl 8(%esp), %edx
+ movl $0xaaaaaaab, %eax
+ mull %edx
+ movl 12(%esp), %eax
+ movl %edx, %ecx
+ movl 4(%esp), %edx
+ pushl %ebx
+ shrl %ecx
+ movb 18(%esp), %bl
+ .balign 4
+ 0:
+ movw %ax, (%edx)
+ movb %bl, 2(%edx)
+ addl $3, %edx
+ decl %ecx
+ jnz 0b
+ popl %ebx
+ ret
+
+/*
+ * void b_dump_virtual (void *buffer, int stride, int height);
+ */
+ .balign 4
+ .global _b_dump_virtual
+_b_dump_virtual:
+ pushl %ebx
+ 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
+ .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
+ popl %ebx
+ subl %ebp, %edi
+ 2:
+ movl (%esi), %eax
+ addl $4, %esi
+ movl %eax, %fs:(%edi)
+ addl $4, %edi
+ decl %ecx
+ jnz 1b
+ popl %ecx
+ addl %ebx, %edi
+ decl %edx
+ jnz 0b
+ popl %eax
+ popl %ebp
+ popl %edi
+ popl %esi
+ popl %ebx
+ ret
+
+/*
+ * void l_dump_virtual (void *buffer, int stride, int height);
+ */
+ .balign 4
+ .global _l_dump_virtual
+_l_dump_virtual:
+ pushl %ebx
+ 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
+ .balign 4
+ 0:
+ pushl %ecx
+ .balign 4
+ 1:
+ movl (%esi), %eax
+ addl $4, %esi
+ movl %eax, %fs:(%edi)
+ addl $4, %edi
+ decl %ecx
+ jnz 1b
+ popl %ecx
+ addl %ebx, %edi
+ decl %edx
+ jnz 0b
+ popl %edi
+ popl %esi
+ popl %ebx
+ ret
+
+/*
+ * void v_putpixel16 (void *buffer, int offset, int color);
+ */
+ .balign 4
+ .global _v_putpixel16
+_v_putpixel16:
+ movl 8(%esp), %edx
+ shll %edx
+ movl 12(%esp), %eax
+ addl 4(%esp), %edx
+ movw %ax, (%edx)
+ ret
+
+/*
+ * void v_putpixel24 (void *buffer, int offset, int color);
+ */
+ .balign 4
+ .global _v_putpixel24
+_v_putpixel24:
+ 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)
+ ret
+
+/*
+ * void v_putpixel32 (void *buffer, int offset, int color);
+ */
+ .balign 4
+ .global _v_putpixel32
+_v_putpixel32:
+ movl 8(%esp), %edx
+ shll $2, %edx
+ movl 12(%esp), %eax
+ addl 4(%esp), %edx
+ movl %eax, (%edx)
+ ret