summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-03-23 02:34:07 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-03-23 02:34:07 +0000
commite69bfe74d7f887fb516f300f575d43b9903d9ab3 (patch)
tree87e79df2f9aaaba93074607a084a67ea4c872c05
parent6211144e056954f5b7a2d5c29f5a337154895217 (diff)
DOS/Mesa driver updates (Daniel Borca)
-rw-r--r--docs/README.DJ37
-rw-r--r--src/glu/mesa/Makefile.DJ20
-rw-r--r--src/glut/dos/Makefile.DJ20
-rw-r--r--src/glut/dos/PC_HW/pc_keyb.c13
-rw-r--r--src/glut/dos/PC_HW/pc_mouse.c11
-rw-r--r--src/glut/dos/init.c83
-rw-r--r--src/mesa/drivers/dos/dmesa.c9
-rw-r--r--src/mesa/drivers/dos/video.c8
-rw-r--r--src/mesa/drivers/dos/video.h4
-rw-r--r--src/mesa/main/Makefile.DJ20
10 files changed, 147 insertions, 78 deletions
diff --git a/docs/README.DJ b/docs/README.DJ
index 8b3a0f5998..8b4e6dc5a3 100644
--- a/docs/README.DJ
+++ b/docs/README.DJ
@@ -1,5 +1,5 @@
- Mesa 4.0.1 DOS/DJGPP Port version 0.3
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Mesa 4.0 DOS/DJGPP Port version 0.4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -21,16 +21,29 @@ Installation:
~~~~~~~~~~~~~
Type "make -f Makefile.DJ" to compile the libraries. Long filename support is
-required during compilation. The examples are not built automagically (see
-Pitfalls below).
+required during compilation. Also, you must have the DXE2 package (available
+on SimTel.Net, courtesy of Andrew Zabolotny) installed in order to build the
+dynamic modules; if you encounter errors, you can fetch a patched version from
+my web page.
+The demos are not built automagically (see Pitfalls below). To make them, use
+one of the following rules:
+ Static:
+ gcc -o OUT.exe IN.c -lglut -lglu -lgl
+ Dynamic:
+ gcc -o OUT.exe -include dmesadxe.h IN.c -ligl -liglu -liglut -ldl
+Usage of the dynamic modules requires three things:
+ - include DMESADXE.H in one of the sources, so references inside
+ dynamic modules will get resolved (or use `-include' directive)
+ - link against import libraries (libIgl*.a) and LIBDL.A, which will do
+ the dynamic linkage job for you
+ - put the DXEs somewhere along the library path (LD_LIBRARY_PATH) or
+ in the current directory
Tested on:
CPU: Intel Pentium w/ MMX @166 MHz
Mainboard: ViA Apollo VP2 w/ 128 MB SDRAM
Video card: Matrox Millenium 2064W w/ 2048 kB WRAM, BIOS v3.0
- DJGPP: djdev 2.03
- gcc v3.0.3
- make v3.79
+ DJGPP: djdev 2.03 + gcc v3.0.3 + make v3.79
@@ -76,7 +89,11 @@ My keyboard driver used only scancodes, but since GLUT requires ASCII values
for keys, I borrowed the translation tables (and maybe more) from Allegro.
Ctrl-Alt-Del (plus Ctrl-Alt-End, for Windows users) will shut down the GLUT
engine unconditionally: it will raise SIGINT, which in turn will call the
-destructors (let's hope), thus cleaning up your/my mess ;-)
+destructors (let's hope), thus cleaning up your/my mess ;-) NB: since the
+DJGPP guys ensured signal handlers won't go beyond program's space (and since
+dynamic modules shall) the SIGINT can't be hooked (well, it can, but it is
+useless), therefore you must live with the 'Exiting due to signal SIGINT'
+message...
The mouse driver is far from complete (lack of positioning, drawing, etc),
but is enough to make almost all the demos work.
@@ -90,7 +107,8 @@ but timer B will probably loose precision!
As an addition, stdout and stderr are redirected and dumped upon exit. This
means that printf can be safely called during graphics, but all messages come
in bulk! A bit of a hack, I know, but I think it's better than to miss them
-at all.
+at all. "Borrowed" from RHIDE (Robert Hoehne) or SETEDIT (Salvador Eduardo
+Tropea)... I'm not sure.
Window creating defaults: 640x480x16 at (0,0), 8-bit stencil, 16-bit accum.
However, the video mode is chosen in such a way that first window will fit.
@@ -113,6 +131,7 @@ v0.2 feb-2002 + fast triangle rasterizers
! minor PC_HW corrections
v0.3 mar-2002 - removed FreeBE/AF code
- removed single-buffer modes
+v0.4 mar-2002 + dynamic module support
diff --git a/src/glu/mesa/Makefile.DJ b/src/glu/mesa/Makefile.DJ
index e09780626b..0232fe5592 100644
--- a/src/glu/mesa/Makefile.DJ
+++ b/src/glu/mesa/Makefile.DJ
@@ -20,7 +20,7 @@
# 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 glu makefile v0.1 for Mesa 4.0
+# DOS/DJGPP glu makefile v0.4 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
@@ -36,7 +36,15 @@ AR = ar
ARFLAGS = ruv
LIBDIR = $(TOP)/lib
+ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)
+DXE2GEN =
+else
+DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))
+endif
+
GLU_LIB = libglu.a
+GLU_DXE = glu.dxe
+GLU_IMP = libiglu.a
CORE_SOURCES = \
glu.c \
@@ -58,11 +66,19 @@ OBJECTS = $(SOURCES:.c=.o)
.c.o:
gcc -o $@ -c $(CFLAGS) $<
-all: $(LIBDIR)/$(GLU_LIB)
+all: $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP)
$(LIBDIR)/$(GLU_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLU_LIB) $(OBJECTS)
+$(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP): $(OBJECTS)
+ifeq ($(DXE2GEN),)
+ @echo Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN
+ @echo somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.
+else
+ dxe2gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) $(OBJECTS) -D "Glu" -U
+endif
+
clean:
-$(RM) *.o
diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ
index 7cacd8d009..7a26eb2d0c 100644
--- a/src/glut/dos/Makefile.DJ
+++ b/src/glut/dos/Makefile.DJ
@@ -20,7 +20,7 @@
# 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 glut makefile v0.2 for Mesa 4.0
+# DOS/DJGPP glut makefile v0.4 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
@@ -36,7 +36,15 @@ AR = ar
ARFLAGS = ruv
LIBDIR = $(TOP)/lib
+ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)
+DXE2GEN =
+else
+DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))
+endif
+
GLUT_LIB = libglut.a
+GLUT_DXE = glut.dxe
+GLUT_IMP = libiglut.a
CORE_SOURCES = \
callback.c \
@@ -69,11 +77,19 @@ OBJECTS = $(SOURCES:.c=.o) $(PC_HW_OBJECTS)
.c.o:
gcc -o $@ -c $(CFLAGS) $<
-all: $(LIBDIR)/$(GLUT_LIB)
+all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP)
$(LIBDIR)/$(GLUT_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS)
+$(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
+ifeq ($(DXE2GEN),)
+ @echo Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN
+ @echo somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.
+else
+ dxe2gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) $(OBJECTS) -D "DOS Glut" -U
+endif
+
clean:
-$(RM) *.o
-$(RM) PC_HW\*.o
diff --git a/src/glut/dos/PC_HW/pc_keyb.c b/src/glut/dos/PC_HW/pc_keyb.c
index f5f4bd8e76..d3987d8e34 100644
--- a/src/glut/dos/PC_HW/pc_keyb.c
+++ b/src/glut/dos/PC_HW/pc_keyb.c
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v0.1 for DOS/DJGPP
+ * PC/HW routine collection v0.4 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -32,7 +32,7 @@ static volatile struct {
static volatile int key_enhanced, key_pause_loop, key_shifts;
static int leds_ok = TRUE;
static int in_a_terrupt = FALSE;
-volatile char pc_key[KEY_MAX];
+static volatile char pc_key[KEY_MAX];
@@ -400,6 +400,10 @@ static int keyboard ()
}
if (((temp==0x4F)||(temp==0x53))&&(key_shifts&KB_CTRL_FLAG)&&(key_shifts&KB_ALT_FLAG)) {
+ /* Hack alert:
+ only SIGINT (but not Ctrl-Break)
+ calls the destructors and will safely clean up
+ */
__asm__("\n\
movb $0x79, %%al \n\
call ___djgpp_hw_exception \n\
@@ -436,6 +440,11 @@ int pc_readkey (void)
}
}
+int pc_keydown (int code)
+{
+ return pc_key[code];
+}
+
void pc_remove_keyb (void)
{
if (keyboard_installed) {
diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c
index 2a692eceb6..aa1fbe4da7 100644
--- a/src/glut/dos/PC_HW/pc_mouse.c
+++ b/src/glut/dos/PC_HW/pc_mouse.c
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v0.2 for DOS/DJGPP
+ * PC/HW routine collection v0.4 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -29,7 +29,7 @@ static void *mouse_stack;
static long mouse_callback;
static __dpmi_regs mouse_regs;
-volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b;
+static volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b;
static int minx = 0;
static int maxx = 319;
@@ -205,6 +205,13 @@ void pc_mouse_speed (int xspeed, int yspeed)
ENABLE();
}
+int pc_query_mouse (int *x, int *y)
+{
+ *x = pc_mouse_x;
+ *y = pc_mouse_y;
+ return pc_mouse_b;
+}
+
void pc_show_mouse (void)
{
/* not implemented */
diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c
index 41170e37c9..9cda3a8b5b 100644
--- a/src/glut/dos/init.c
+++ b/src/glut/dos/init.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v0.2 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.4 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -27,30 +27,13 @@
*/
-#include <signal.h>
#include "GL/glut.h"
#include "internal.h"
-static void *old_sig_int = NULL;
-
-
-static void signal_handler (int num)
-{
- signal(SIGINT, old_sig_int);
-
- raise(num);
-}
-
-
void APIENTRY glutInit (int *argcp, char **argv)
{
glutGet(GLUT_ELAPSED_TIME);
- /* Hack alert:
- only SIGINT (but not Ctrl-Break)
- calls the destructors and will safely clean up
- */
- old_sig_int = signal(SIGINT, signal_handler);
}
@@ -133,34 +116,42 @@ void APIENTRY glutMainLoop (void)
}
}
- if (g_mouse && motion_func && ((pc_mouse_x != old_mouse_x) || (pc_mouse_y != old_mouse_y))) {
- idle = GL_FALSE;
- old_mouse_x = pc_mouse_x;
- old_mouse_y = pc_mouse_y;
-
- motion_func(old_mouse_x, old_mouse_y);
- }
-
- if (g_mouse && mouse_func && (pc_mouse_b != old_mouse_b)) {
- int new_mouse_b = pc_mouse_b;
-
- if ((old_mouse_b & 1) && !(new_mouse_b & 1))
- mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);
- else if (!(old_mouse_b & 1) && (new_mouse_b & 1))
- mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);
-
- if ((old_mouse_b & 2) && !(new_mouse_b & 2))
- mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);
- else if (!(old_mouse_b & 2) && (new_mouse_b & 2))
- mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);
-
- if ((old_mouse_b & 4) && !(new_mouse_b & 4))
- mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);
- else if (!(old_mouse_b & 3) && (new_mouse_b & 4))
- mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);
-
- idle = GL_FALSE;
- old_mouse_b = new_mouse_b;
+ if (g_mouse) {
+ int mouse_x;
+ int mouse_y;
+ int mouse_b;
+
+ mouse_b = pc_query_mouse(&mouse_x, &mouse_y);
+
+ if (motion_func && ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y))) {
+ idle = GL_FALSE;
+ old_mouse_x = mouse_x;
+ old_mouse_y = mouse_y;
+
+ motion_func(old_mouse_x, old_mouse_y);
+ }
+
+ if (mouse_func && (mouse_b != old_mouse_b)) {
+ int new_mouse_b = mouse_b;
+
+ if ((old_mouse_b & 1) && !(new_mouse_b & 1))
+ mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, mouse_x, mouse_y);
+ else if (!(old_mouse_b & 1) && (new_mouse_b & 1))
+ mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
+
+ if ((old_mouse_b & 2) && !(new_mouse_b & 2))
+ mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, mouse_x, mouse_y);
+ else if (!(old_mouse_b & 2) && (new_mouse_b & 2))
+ mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
+
+ if ((old_mouse_b & 4) && !(new_mouse_b & 4))
+ mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, mouse_x, mouse_y);
+ else if (!(old_mouse_b & 3) && (new_mouse_b & 4))
+ mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
+
+ idle = GL_FALSE;
+ old_mouse_b = new_mouse_b;
+ }
}
if (idle && idle_func)
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index d150cdca5a..454b891c08 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -540,13 +540,8 @@ static GLboolean set_draw_buffer (GLcontext *ctx, GLenum mode)
* If anything special has to been done when the buffer/window is
* resized, do it now.
*/
-static void get_buffer_size (GLframebuffer *buffer, GLuint *width, GLuint *height)
+static void get_buffer_size (GLcontext *ctx, GLuint *width, GLuint *height)
{
- /* XXX this may not be right. We should query the size of the DOS window
- * associated with <buffer>. This function should work whether or
- * not there is a current context.
- */
- GET_CURRENT_CONTEXT(ctx);
DMesaContext c = (DMesaContext)ctx->DriverCtx;
*width = c->Buffer->width;
@@ -641,7 +636,7 @@ void dmesa_init_pointers (GLcontext *ctx)
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = _swrast_Bitmap;
ctx->Driver.Clear = clear;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c
index 5c2c84a84f..9d50952c52 100644
--- a/src/mesa/drivers/dos/video.c
+++ b/src/mesa/drivers/dos/video.c
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v0.3 for Mesa 4.0
+ * DOS/DJGPP device driver v0.4 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -180,9 +180,9 @@ void vl_rect (void *buffer, int x, int y, int width, int height, int color)
/*
* virtual dumping:
*/
-void *(*vl_flip) (void *buffer, int width, int height);
+void (*vl_flip) (void *buffer, int width, int height);
-extern void *b_dump_virtual (void *buffer, int width, int height);
+extern void b_dump_virtual (void *buffer, int width, int height);
__asm__("\n\
.text \n\
.balign 4 \n\
@@ -242,7 +242,7 @@ _b_dump_virtual: \n\
popl %esi \n\
popl %ebx \n\
ret");
-extern void *l_dump_virtual (void *buffer, int width, int height);
+extern void l_dump_virtual (void *buffer, int width, int height);
__asm__("\n\
.text \n\
.balign 4 \n\
diff --git a/src/mesa/drivers/dos/video.h b/src/mesa/drivers/dos/video.h
index ff81ac9d2e..c806aa7c88 100644
--- a/src/mesa/drivers/dos/video.h
+++ b/src/mesa/drivers/dos/video.h
@@ -23,7 +23,7 @@
*/
/*
- * DOS/DJGPP device driver v0.3 for Mesa 4.0
+ * DOS/DJGPP device driver v0.4 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -42,7 +42,7 @@ void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);
extern void (*vl_clear) (void *buffer, int len, 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 width, int height);
extern int (*vl_mixrgba) (const unsigned char rgba[]);
extern int (*vl_mixrgb) (const unsigned char rgb[]);
diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ
index 214882d1cf..fc540dc60b 100644
--- a/src/mesa/main/Makefile.DJ
+++ b/src/mesa/main/Makefile.DJ
@@ -20,7 +20,7 @@
# 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 core makefile v0.2 for Mesa 4.0
+# DOS/DJGPP core makefile v0.4 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
@@ -36,7 +36,15 @@ AR = ar
ARFLAGS = ruv
LIBDIR = $(TOP)/lib
+ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)
+DXE2GEN =
+else
+DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))
+endif
+
GL_LIB = libgl.a
+GL_DXE = gl.dxe
+GL_IMP = libigl.a
CORE_SOURCES = \
swrast_setup/ss_context.c \
@@ -166,11 +174,19 @@ OBJECTS = $(SOURCES:.c=.o)
.c.o:
gcc -o $@ -c $(CFLAGS) $<
-all: $(LIBDIR)/$(GL_LIB)
+all: $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP)
$(LIBDIR)/$(GL_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GL_LIB) $(OBJECTS)
+$(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP): $(OBJECTS)
+ifeq ($(DXE2GEN),)
+ @echo Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN
+ @echo somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.
+else
+ dxe2gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) $(OBJECTS) -D "DOS Mesa" -U
+endif
+
clean:
-$(RM) *.o
-$(RM) DOS\*.o