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.c81
-rw-r--r--src/mesa/drivers/dos/vesa/vesa.c33
-rw-r--r--src/mesa/drivers/dos/vga/vga.c33
-rw-r--r--src/mesa/drivers/dos/video.c109
-rw-r--r--src/mesa/drivers/dos/video.h5
-rw-r--r--src/mesa/drivers/dos/virtual.S29
6 files changed, 194 insertions, 96 deletions
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 4541559e2ca..ec9f3b22242 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -356,7 +356,7 @@ static void read_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
offset = c->Buffer->width * FLIP(y) + x;
/* read all pixels */
for (i=0; i<n; i++, offset++) {
- index[i] = vl_getCIpixel(offset);
+ index[i] = vl_getpixel(offset);
}
}
@@ -421,13 +421,13 @@ static void read_index_pixels (const GLcontext *ctx,
/* read some pixels */
for (i=0; i<n; i++) {
if (mask[i]) {
- index[i] = vl_getCIpixel(FLIP2(y[i])*w + x[i]);
+ index[i] = vl_getpixel(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]);
+ index[i] = vl_getpixel(FLIP2(y[i])*w + x[i]);
}
}
}
@@ -1074,19 +1074,37 @@ void DMesaDestroyContext (DMesaContext c)
-GLboolean DMesaViewport (DMesaBuffer b,
- GLint xpos, GLint ypos,
- GLint width, GLint height)
+GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos)
{
#ifndef FX
- void *new_window;
+ GET_CURRENT_CONTEXT(ctx);
+ DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer;
- if ((new_window=vl_sync_buffer(b->the_window, xpos, ypos, width, height)) == NULL) {
+ if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) != 0) {
return GL_FALSE;
} else {
- b->the_window = new_window;
b->xpos = xpos;
b->ypos = ypos;
+ return GL_TRUE;
+ }
+
+#else
+
+ return GL_FALSE;
+#endif
+}
+
+
+
+GLboolean DMesaResizeBuffer (GLint width, GLint height)
+{
+#ifndef FX
+ GET_CURRENT_CONTEXT(ctx);
+ DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer;
+
+ if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) != 0) {
+ return GL_FALSE;
+ } else {
b->width = width;
b->height = height;
return GL_TRUE;
@@ -1107,7 +1125,7 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
{
#ifndef FX
if ((c != NULL) && (b != NULL)) {
- if (!DMesaViewport(b, b->xpos, b->ypos, b->width, b->height)) {
+ if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, b->width, b->height) != 0) {
return GL_FALSE;
}
@@ -1153,3 +1171,46 @@ void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue)
vl_setCI(ndx, red, green, blue);
#endif
}
+
+
+
+void DMesaGetIntegerv (GLenum pname, GLint *params)
+{
+#ifndef FX
+ GET_CURRENT_CONTEXT(ctx);
+ const DMesaContext c = (ctx == NULL) ? NULL : (DMesaContext)ctx->DriverCtx;
+#else
+ const fxMesaContext c = fxMesaGetCurrentContext();
+#endif
+
+ if (c == NULL) {
+ return;
+ }
+
+ switch (pname) {
+ case DMESA_Y_ORIGIN:
+ #ifndef FX
+ params[0] = GL_FALSE;
+ #else
+ params[0] = GL_TRUE;
+ #endif
+ break;
+ case DMESA_SCREEN_SIZE:
+ #ifndef FX
+ vl_get_screen_size(&params[0], &params[1]);
+ #else
+ params[0] = c->screen_width;
+ params[1] = c->screen_height;
+ #endif
+ break;
+ case DMESA_ARGB_ORDER:
+ #ifndef FX
+ params[0] = GL_FALSE;
+ #else
+ params[0] = !c->bgrOrder;
+ #endif
+ break;
+ default:
+ break;
+ }
+}
diff --git a/src/mesa/drivers/dos/vesa/vesa.c b/src/mesa/drivers/dos/vesa/vesa.c
index 26c474317fe..1f3de844d7d 100644
--- a/src/mesa/drivers/dos/vesa/vesa.c
+++ b/src/mesa/drivers/dos/vesa/vesa.c
@@ -32,6 +32,7 @@
#include <dpmi.h>
+#include <pc.h>
#include <stdlib.h>
#include <stubinfo.h>
#include <sys/exceptn.h>
@@ -454,22 +455,23 @@ static void vesa_restore (void)
* In : color index, R, G, B
* Out : -
*
- * Note: uses normalized values
+ * Note: uses integer values
*/
-static void vesa_setCI_f (int index, float red, float green, float blue)
+static void vesa_setCI_i (int index, int red, int green, int blue)
{
- float max = (1 << vesa_color_precision) - 1;
-
- int _red = red * max;
- int _green = green * max;
- int _blue = blue * max;
-
+#if 0
__asm("\n\
movw $0x1010, %%ax \n\
movb %1, %%dh \n\
movb %2, %%ch \n\
int $0x10 \n\
-"::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx");
+ "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
+#else
+ outportb(0x03C8, index);
+ outportb(0x03C9, red);
+ outportb(0x03C9, green);
+ outportb(0x03C9, blue);
+#endif
}
@@ -479,16 +481,13 @@ static void vesa_setCI_f (int index, float red, float green, float blue)
* In : color index, R, G, B
* Out : -
*
- * Note: uses integer values
+ * Note: uses normalized values
*/
-static void vesa_setCI_i (int index, int red, int green, int blue)
+static void vesa_setCI_f (int index, float red, float green, float 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");
+ float max = (1 << vesa_color_precision) - 1;
+
+ vesa_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
}
diff --git a/src/mesa/drivers/dos/vga/vga.c b/src/mesa/drivers/dos/vga/vga.c
index 1888d989475..d1d2db51b5e 100644
--- a/src/mesa/drivers/dos/vga/vga.c
+++ b/src/mesa/drivers/dos/vga/vga.c
@@ -31,6 +31,7 @@
*/
+#include <pc.h>
#include <stdlib.h>
#include "vga.h"
@@ -158,22 +159,23 @@ static void vga_restore (void)
* In : color index, R, G, B
* Out : -
*
- * Note: uses normalized values
+ * Note: uses integer values
*/
-static void vga_setCI_f (int index, float red, float green, float blue)
+static void vga_setCI_i (int index, int red, int green, int blue)
{
- float max = (1 << vga_color_precision) - 1;
-
- int _red = red * max;
- int _green = green * max;
- int _blue = blue * max;
-
+#if 0
__asm("\n\
movw $0x1010, %%ax \n\
movb %1, %%dh \n\
movb %2, %%ch \n\
int $0x10 \n\
- "::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx");
+ "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
+#else
+ outportb(0x03C8, index);
+ outportb(0x03C9, red);
+ outportb(0x03C9, green);
+ outportb(0x03C9, blue);
+#endif
}
@@ -183,16 +185,13 @@ static void vga_setCI_f (int index, float red, float green, float blue)
* In : color index, R, G, B
* Out : -
*
- * Note: uses integer values
+ * Note: uses normalized values
*/
-static void vga_setCI_i (int index, int red, int green, int blue)
+static void vga_setCI_f (int index, float red, float green, float 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");
+ float max = (1 << vga_color_precision) - 1;
+
+ vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
}
diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c
index 5f4d9d5bedb..aba99ac5428 100644
--- a/src/mesa/drivers/dos/video.c
+++ b/src/mesa/drivers/dos/video.c
@@ -45,6 +45,7 @@
static vl_driver *drv;
/* based upon mode specific data: valid entire session */
int vl_video_selector;
+static vl_mode *video_mode;
static int video_scanlen, video_bypp;
/* valid until next buffer */
void *vl_current_draw_buffer, *vl_current_read_buffer;
@@ -93,6 +94,7 @@ int (*vl_mixfix) (fixed r, fixed g, fixed b);
int (*vl_mixrgb) (const unsigned char rgb[]);
int (*vl_mixrgba) (const unsigned char rgba[]);
void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]);
+int (*vl_getpixel) (unsigned int offset);
void (*vl_clear) (int color);
void (*vl_rect) (int x, int y, int width, int height, int color);
void (*vl_flip) (void);
@@ -243,30 +245,43 @@ static void v_getrgba32 (unsigned int offset, unsigned char rgba[4])
-/* Desc: set one palette entry
+/* Desc: pixel retrieval
*
- * In : index, R, G, B
- * Out : -
+ * In : pixel offset
+ * Out : pixel value
*
- * Note: color components are in range [0.0 .. 1.0]
+ * Note: uses current read buffer
*/
-void vl_setCI (int index, float red, float green, float blue)
+static int v_getpixel8 (unsigned int offset)
{
- drv->setCI_f(index, red, green, blue);
+ return ((word8 *)vl_current_read_buffer)[offset];
+}
+#define v_getpixel15 v_getpixel16
+static int v_getpixel16 (unsigned int offset)
+{
+ return ((word16 *)vl_current_read_buffer)[offset];
+}
+static int v_getpixel24 (unsigned int offset)
+{
+ return *(word32 *)((long)vl_current_read_buffer+offset*3);
+}
+static int v_getpixel32 (unsigned int offset)
+{
+ return ((word32 *)vl_current_read_buffer)[offset];
}
-/* Desc: read pixel from 8bit buffer
+/* Desc: set one palette entry
*
- * In : pixel offset
- * Out : pixel read
+ * In : index, R, G, B
+ * Out : -
*
- * Note: used only for CI modes
+ * Note: color components are in range [0.0 .. 1.0]
*/
-int vl_getCIpixel (unsigned int offset)
+void vl_setCI (int index, float red, float green, float blue)
{
- return ((word8 *)vl_current_read_buffer)[offset];
+ drv->setCI_f(index, red, green, blue);
}
@@ -276,7 +291,7 @@ int vl_getCIpixel (unsigned int offset)
* In : color, R, G, B
* Out : -
*
- * Note: color components are in range [0 .. 63]
+ * Note: -
*/
static void fake_setcolor (int c, int r, int g, int b)
{
@@ -326,33 +341,56 @@ static void fake_buildpalette (int bits)
/* Desc: sync buffer with video hardware
*
- * In : old buffer, position, size
- * Out : new buffer
+ * In : ptr to old buffer, position, size
+ * Out : 0 if success
*
* Note: -
*/
-void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)
+int vl_sync_buffer (void **buffer, int x, int y, int width, int height)
{
- void *newbuf;
-
- if (width&7) {
- return NULL;
+ if ((width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) {
+ return -1;
} else {
- 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;
- vl_current_delta = video_scanlen - vl_current_stride;
+ void *newbuf = *buffer;
+
+ if ((newbuf == NULL) || (vl_current_width != width) || (vl_current_height != height)) {
+ newbuf = realloc(newbuf, width * height * video_bypp);
}
- return vl_current_draw_buffer = vl_current_read_buffer = newbuf;
+
+ if (newbuf == NULL) {
+ return -2;
+ }
+
+ vl_current_width = width;
+ vl_current_height = height;
+ vl_current_stride = vl_current_width * video_bypp;
+ vl_current_bytes = vl_current_stride * height;
+
+ vl_current_offset = video_scanlen * y + video_bypp * x;
+ vl_current_delta = video_scanlen - vl_current_stride;
+
+ vl_current_draw_buffer = vl_current_read_buffer = *buffer = newbuf;
+ return 0;
}
}
+/* Desc: get screen geometry
+ *
+ * In : ptr to WIDTH, ptr to HEIGHT
+ * Out : -
+ *
+ * Note: -
+ */
+void vl_get_screen_size (int *width, int *height)
+{
+ *width = video_mode->xres;
+ *height = video_mode->yres;
+}
+
+
+
/* Desc: retrieve CPU MMX capability
*
* In : -
@@ -364,8 +402,7 @@ int vl_can_mmx (void)
{
#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);
+ return (_mesa_identify_x86_cpu_features() & 0x00800000);
#else
return 0;
#endif
@@ -382,9 +419,14 @@ int vl_can_mmx (void)
*/
static int vl_setup_mode (vl_mode *p)
{
+ if (p == NULL) {
+ return -1;
+ }
+
#define INITPTR(bpp) \
vl_putpixel = v_putpixel##bpp; \
vl_getrgba = v_getrgba##bpp; \
+ vl_getpixel = v_getpixel##bpp; \
vl_rect = v_rect##bpp; \
vl_mixfix = vl_mixfix##bpp; \
vl_mixrgb = vl_mixrgb##bpp; \
@@ -413,6 +455,7 @@ static int vl_setup_mode (vl_mode *p)
#undef INITPTR
+ video_mode = p;
video_bypp = (p->bpp+7)/8;
video_scanlen = p->scanlen;
vl_video_selector = p->sel;
@@ -476,8 +519,8 @@ int vl_video_init (int width, int height, int bpp, int rgb, int refresh)
}
}
- /* check, setup and enter mode */
- if ((p!=NULL) && (vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
+ /* setup and enter mode */
+ if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
vl_flip = drv->blit;
if (fake) {
min = drv->getCIprec();
diff --git a/src/mesa/drivers/dos/video.h b/src/mesa/drivers/dos/video.h
index 3197338e632..8dfb9a91766 100644
--- a/src/mesa/drivers/dos/video.h
+++ b/src/mesa/drivers/dos/video.h
@@ -45,11 +45,12 @@ extern void (*vl_clear) (int color);
extern void (*vl_rect) (int x, int y, int width, int height, int color);
extern void (*vl_flip) (void);
extern void (*vl_putpixel) (unsigned int offset, int color);
+extern int (*vl_getpixel) (unsigned int offset);
void vl_setCI (int index, float red, float green, float blue);
-int vl_getCIpixel (unsigned int offset);
-void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);
+int vl_sync_buffer (void **buffer, int x, int y, int width, int height);
+void vl_get_screen_size (int *width, int *height);
void vl_video_exit (void);
int vl_video_init (int width, int height, int bpp, int rgb, int refresh);
diff --git a/src/mesa/drivers/dos/virtual.S b/src/mesa/drivers/dos/virtual.S
index 4dbbbb3e3f8..c5a72975feb 100644
--- a/src/mesa/drivers/dos/virtual.S
+++ b/src/mesa/drivers/dos/virtual.S
@@ -107,13 +107,12 @@ _v_clear_common:
.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
+#ifdef USE_MMX_ASM
+ movq 4(%esp), %mm0
+ punpcklbw %mm0, %mm0
+ punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
+#endif
/* Desc: void v_clear16_mmx (int color);
*
@@ -125,12 +124,11 @@ _v_clear8_mmx:
.p2align 5,,31
.global _v_clear16_mmx
_v_clear16_mmx:
- movl 4(%esp), %eax
- pushw %ax
- pushw %ax
- pushw %ax
- pushw %ax
+#ifdef USE_MMX_ASM
+ movq 4(%esp), %mm0
+ punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
+#endif
/* Desc: void v_clear32_mmx (int color);
*
@@ -142,15 +140,13 @@ _v_clear16_mmx:
.p2align 5,,31
.global _v_clear32_mmx
_v_clear32_mmx:
- movl 4(%esp), %eax
- pushl %eax
- pushl %eax
+#ifdef USE_MMX_ASM
+ movq 4(%esp), %mm0
.balign 4
_v_clear_common_mmx:
-#ifdef USE_MMX_ASM
+ punpckldq %mm0, %mm0
movl _vl_current_bytes, %ecx
movl _vl_current_draw_buffer, %edx
- movq (%esp), %mm0
shrl $3, %ecx
.balign 4
0:
@@ -160,7 +156,6 @@ _v_clear_common_mmx:
jnz 0b
emms
#endif
- addl $8, %esp
ret
/* Desc: void v_clear24 (int color);