- Mesa 4.0 DOS/DJGPP Port v1.0\r
+ Mesa 4.0 DOS/DJGPP Port v1.1\r
~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
\r
\r
Description:\r
~~~~~~~~~~~~\r
\r
-Well, guess what... this is the DOS port of MESA 4.0, for DJGPP fans... Whoa!\r
+Well, guess what... this is the DOS port of Mesa 4.0.3, for DJGPP fans... Whoa!\r
+The driver has its origins in ddsample.c, written by Brian Paul and found by me\r
+in Mesa 3.4.2.\r
\r
\r
\r
Legal:\r
~~~~~~\r
\r
-MESA copyright applies.\r
+Mesa copyright applies, provided this package is used within Mesa. For anything\r
+else, see GPL.\r
\r
\r
\r
Installation:\r
~~~~~~~~~~~~~\r
\r
-Type "make -f Makefile.DJ" to compile the libraries. Make accepts some options\r
-which are passed to compiler: the target cpu (CPU=..., default=`pentium') and\r
-X86 specific options (HAVE_X86=1, HAVE_MMX=1, HAVE_SSE=1, HAVE_3DNOW=1). The\r
-core library (libGL) requires LFN support during compilation. Also, you must\r
-have the DXE2 package (available on SimTel.Net, courtesy of Andrew Zabolotny)\r
-installed in order to build the dynamic modules; if you encounter errors, you\r
-can fetch a patched version from my web page.\r
-The demos are not built automagically (see Pitfalls below). To make them, use\r
-one of the following rules:\r
- Static:\r
- gcc -o OUT.exe IN.c -lglut -lglu -lgl\r
- Dynamic:\r
- gcc -o OUT.exe -include dmesadxe.h IN.c -ligl -liglu -liglut -ldl\r
-Usage of the dynamic modules requires three things:\r
- - include DMESADXE.H in one of the sources, so references inside\r
- dynamic modules will get resolved (or use `-include' directive)\r
- - link against import libraries (libIgl*.a) and LIBDL.A, which will do\r
- the dynamic linkage job for you\r
- - put the DXEs somewhere along the library path (LD_LIBRARY_PATH) or\r
- in the current directory\r
+Unzip and type:\r
+\r
+ make -f Makefile.DJ [OPTIONS...]\r
+\r
+Available options:\r
+\r
+ Environment variables:\r
+ CPU optimize for the given processor.\r
+ default = k6\r
+ BIG_OPT=1 crazy optimizations; not very useful, though...\r
+ default = no\r
+ GLIDE absolute path to Glide library; used with FX.\r
+ default = $(TOP)/include/glide3\r
+ FX=1 build for 3dfx Glide3; use it if you have the Glide\r
+ SDK (designed for your platform), and, of course, a\r
+ 3dfx card... Note that this disables compilation of\r
+ actual DMesa code, as Glide does all the stuff!\r
+ default = no\r
+ HAVE_X86=1 optimize for i386.\r
+ default = no\r
+ HAVE_MMX=1 MMX instructions; use only if you assembler/compiler\r
+ supports MMX instruction set; backwards compatibility\r
+ with older processors is still preserved.\r
+ default = no\r
+ HAVE_SSE=1 (see HAVE_MMX)\r
+ default = no\r
+ HAVE_3DNOW=1 (see HAVE_MMX)\r
+ default = no\r
+\r
+ Targets:\r
+ all: build everything\r
+ libgl: build GL\r
+ libglu: build GLU\r
+ libglut: build GLUT\r
+ clean: remove object files\r
+ realclean: remove all generated files\r
+\r
+\r
\r
Tested on:\r
- CPU: Intel Pentium w/ MMX @166 MHz\r
- Mainboard: ViA Apollo VP2 w/ 128 MB SDRAM\r
- Video card: Matrox Millenium 2064W w/ 2048 kB WRAM, BIOS v3.0\r
- DJGPP: djdev 2.03 + gcc v3.0.3 + make v3.79\r
+ CPU: K6-2 (CXT) @500(412.5) MHz\r
+ Mainboard: ViA Apollo VP2/97 w/ 128 MB SDRAM\r
+ Video card: PowerColor Evil King3 (Voodoo3 3000) w/ 16384 kB SDRAM\r
+ DJGPP: djdev 2.03 + gcc v3.1 + make v3.79.1\r
\r
\r
\r
-libGL (the core):\r
-~~~~~~~~~~~~~~~~~\r
+FAQ:\r
+~~~~\r
\r
-Of course, MESA 4.0 core sources are required. It will probably work with\r
-MESA 3.5, but not a chance with earlier versions due to major changes to the\r
-MESA driver interface and the directory tree. All should compile succesfully.\r
+1. Compilation\r
\r
-The driver has its origins in ddsample.c, written by Brian Paul and found by\r
-me in MESA 3.4.2. I touched almost all the functions, changing the coding\r
-style :-( Sorry!\r
+ Q) I tried to run `make' and it exits because `gcc' complains it cannot find\r
+ some stupid file.\r
+ A) You need LFN support.\r
+ A) If FX is defined, pay attention to Glide path.\r
\r
-Pitfalls:\r
-1. The current version supports only RGB[A] modes, for it made no sense to me\r
- to endorse color-index (aka palette) modes.\r
-2. Single-buffered is not allowed at all. Until I can find a way to use *REAL*\r
- hardware acceleration, it won't get implemented.\r
-3. Another weird "feature" is that buffer width must be multiple of 4 (I'm a\r
- lazy programmer and I found that the easiest way to keep buffer handling at\r
- peak performance ;-).\r
+2. Dynamic modules\r
\r
+ Q) What are you mumbling about dynamic modules?\r
+ A) You must have the DXE2 package (available on SimTel.Net, courtesy of\r
+ Andrew Zabolotny) installed in order to build the dynamic modules.\r
\r
+ Q) I have DXE2, but I couln'd build the `dxe2gen.exe'.\r
+ Q) I built `dxe2gen.exe', but it doesn't do the job right.\r
+ A) There is a patched version on my web page.\r
\r
-libGLU:\r
-~~~~~~~\r
+ Q) DXE2 modules give me headaches...\r
+ A) The DXE2 modules are not compulsory. The static libraries are still built\r
+ and you can use them in the old-fashioned, classic way.\r
\r
-Mesa GLU sources are required.\r
+ Q) Okay, DXE2 modules are built. How can I use them?\r
+ A) Usage of the dynamic modules requires three things:\r
+ - include DMESADXE.H in one of the sources, so references inside\r
+ dynamic modules will get resolved (or use `-include' directive).\r
+ - link against import libraries (libI*.a) and LIBDL.A, which will do\r
+ the dynamic linkage job for you\r
+ - put the DXEs somewhere along the library path (LD_LIBRARY_PATH) or\r
+ in the current directory\r
+ For example:\r
+ gcc -o OUT.exe -include dmesadxe.h IN.c -ligl -liglu -liglut -ldl\r
+\r
+ Q) The application dies with "Abort!" due to unresolved symbols.\r
+ A) This is bad! Extract the unresolved symbol list from this module. For\r
+ example:\r
+ dxe2gen --show-unres gl.dxe > u\r
+ Check DMESADXE.H; the symbols in `u' must either be present here or be\r
+ exported from another module that has to be loaded before your faulting\r
+ one. Then recompile.\r
+\r
+3. Using Mesa for DJGPP\r
+\r
+ Q) Does this build work in Win9x?\r
+ A) Yes.\r
+\r
+ Q) Does it work under NT (W2k, XP) core?\r
+ A) Uh... probably not!\r
+\r
+ Q) I made a simple application and it does nothing. It exits right away. Not\r
+ even a blank screen.\r
+ A) The current version supports only RGB[A] modes, for it made no sense to\r
+ me to endorse color-index (aka palette) modes.\r
+ A) Single-buffered is not allowed at all. Until I can find a way to use\r
+ *REAL* hardware acceleration, it won't get implemented.\r
+ A) Another weird "feature" is that buffer width must be multiple of 4 (I'm a\r
+ lazy programmer and I found that the easiest way to keep buffer handling\r
+ at peak performance ;-).\r
+\r
+ Q) My demo doesn't display text. I know I used the glut font routines!\r
+ A) Then you probably use GLUT as a DXE. Well, there is no direct access to\r
+ variables due to the way DXE works. Read the documentation. The author of\r
+ GLUT took this into account for _WIN32 DLL's only; I don't want to modify\r
+ his headers. The only workaround is to link GLUT the old way :-(\r
+\r
+ Q) The DJGPP port of Mesa is so SLOOOW! The Win32 OpenGL performs so much\r
+ better...\r
+ A) Is that a question? If you have a Voodoo3/Banshee card, you're lucky. The\r
+ Glide port is on my web page. If you haven't, sorry; everything is done\r
+ in software. Suggestions?\r
+\r
+ Q) I have a super/mega/ultra monitor and all you can do is 60Hz? My eyes are\r
+ leaking from the orbits...\r
+ A) If you were compiling for Glide, see Glide info. If not, be aware that\r
+ refresh rate control works only for VESA 3.0. The environment variable\r
+ DMESA_REFRESH sets the default screen refresh. For example:\r
+ set DMESA_REFRESH=75\r
\r
\r
\r
Bernhard Tschirren, Mark Kilgard, Brian Paul and probably others (or probably\r
not ;-). I only changed it to be self-standing (Allegro-free). The keyboard,\r
mouse and timer drivers were inspired from an old project of mine (D3Xl) and\r
-fixed with some Allegro "infusions"; I deeply thank to Shawn Hargreaves et co.\r
+fixed with many Allegro "infusions"; I deeply thank to Shawn Hargreaves et co.\r
\r
My keyboard driver used only scancodes, but since GLUT requires ASCII values\r
for keys, I borrowed the translation tables (and maybe more) from Allegro.\r
~~~~~~~~\r
\r
v1.0 mar-2002 initial release\r
+v1.1 sep-2002 + added 3dfx Glide3 support\r
+ + added refresh rate control\r
+ + added fonts in glut\r
+ * lots of minor changes\r
\r
\r
\r
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
\r
-# DOS/DJGPP glu makefile v1.0 for Mesa 4.0\r
+# DOS/DJGPP glu makefile v1.1 for Mesa 4.0\r
#\r
# Copyright (C) 2002 - Borca Daniel\r
# Email : dborca@yahoo.com\r
# Web : http://www.geocities.com/dborca\r
\r
\r
+#\r
+# Available options:\r
+#\r
+# Environment variables:\r
+# CFLAGS\r
+#\r
+# Targets:\r
+# all: build GLU\r
+# clean: remove object files\r
+#\r
+\r
+\r
+\r
.PHONY: all clean\r
\r
TOP = ..\r
+LIBDIR = $(TOP)/lib\r
+GLU_LIB = libglu.a\r
+GLU_DXE = glu.dxe\r
+GLU_IMP = libiglu.a\r
+\r
CC = gcc\r
-CFLAGS = -I$(TOP)/include -Wall -W -Wno-unused -mcpu=$(CPU) -ffast-math -O2\r
+CFLAGS += -I$(TOP)/include\r
+\r
AR = ar\r
-ARFLAGS = ruv\r
-LIBDIR = $(TOP)/lib\r
+ARFLAGS = ru\r
\r
-ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)\r
-DXE2GEN =\r
-else\r
+ifneq ($(wildcard $(DJDIR)/lib/dxe2.ld),)\r
DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))\r
endif\r
\r
-GLU_LIB = libglu.a\r
-GLU_DXE = glu.dxe\r
-GLU_IMP = libiglu.a\r
+RM = del\r
\r
CORE_SOURCES = \\r
glu.c \\r
OBJECTS = $(SOURCES:.c=.o)\r
\r
.c.o:\r
- gcc -o $@ -c $(CFLAGS) $<\r
+ $(CC) -o $@ -c $(CFLAGS) $<\r
\r
all: $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP)\r
\r
$(warning Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN)\r
$(warning somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.)\r
else\r
- dxe2gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) $(OBJECTS) -D "Mesa DOS GLU" -U\r
+ -dxe2gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) $(OBJECTS) -E djgpp_ -E glu -D "Mesa DJGPP GLU" -U\r
endif\r
\r
clean:\r
- -$(RM) *.o\r
+ -$(RM) $(subst /,\,*.o)\r
\r
-include depend\r
+-include depend\r
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
\r
-# DOS/DJGPP glut makefile v1.0 for Mesa 4.0\r
+# DOS/DJGPP glut makefile v1.1 for Mesa 4.0\r
#\r
# Copyright (C) 2002 - Borca Daniel\r
# Email : dborca@yahoo.com\r
# Web : http://www.geocities.com/dborca\r
\r
\r
+#\r
+# Available options:\r
+#\r
+# Environment variables:\r
+# CFLAGS\r
+#\r
+# GLIDE absolute path to Glide SDK; used with FX.\r
+# default = $(TOP)/include/glide3\r
+# FX=1 build for 3dfx Glide3; use it if you have the glide\r
+# SDK (designed for your platform), and, of course, a\r
+# 3dfx card... Note that this disables compilation of\r
+# actual DMesa code, as Glide does all the stuff!\r
+# default = no\r
+# MARK absolute path to original GLUT.\r
+# default = $(TOP)/src-glut\r
+#\r
+# Targets:\r
+# all: build GLUT\r
+# clean: remove object files\r
+#\r
+\r
+\r
+\r
.PHONY: all clean\r
\r
TOP = ..\r
+GLIDE ?= $(TOP)/include/glide3\r
+MARK ?= $(TOP)/src-glut\r
+LIBDIR = $(TOP)/lib\r
+GLUT_LIB = libglut.a\r
+GLUT_DXE = glut.dxe\r
+GLUT_IMP = libiglut.a\r
+\r
CC = gcc\r
-CFLAGS = -I$(TOP)/include -Wall -W -Wno-unused -mcpu=$(CPU) -ffast-math -O2\r
+CFLAGS += -I$(TOP)/include -I$(MARK)\r
+ifdef FX\r
+CFLAGS += -D__DOS__ -I$(GLIDE) -DFX -DFX_GLIDE3 -DFXMESA_USE_ARGB\r
+endif\r
+\r
AR = ar\r
-ARFLAGS = ruv\r
-LIBDIR = $(TOP)/lib\r
+ARFLAGS = ru\r
\r
-ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)\r
-DXE2GEN =\r
-else\r
+ifneq ($(wildcard $(DJDIR)/lib/dxe2.ld),)\r
DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))\r
endif\r
\r
-GLUT_LIB = libglut.a\r
-GLUT_DXE = glut.dxe\r
-GLUT_IMP = libiglut.a\r
+RM = del\r
\r
CORE_SOURCES = \\r
+ bitmap.c \\r
callback.c \\r
color.c \\r
- font.c \\r
globals.c \\r
init.c \\r
menu.c \\r
PC_HW/pc_timer.c \\r
PC_HW/pc_irq.S\r
\r
-SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES)\r
+MARK_SOURCES = \\r
+ $(MARK)/glut_8x13.c \\r
+ $(MARK)/glut_9x15.c \\r
+ $(MARK)/glut_hel10.c \\r
+ $(MARK)/glut_hel12.c \\r
+ $(MARK)/glut_hel18.c \\r
+ $(MARK)/glut_tr10.c \\r
+ $(MARK)/glut_tr24.c\r
+\r
+SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES) $(MARK_SOURCES)\r
\r
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))\r
\r
.c.o:\r
- gcc -o $@ -c $(CFLAGS) $<\r
+ $(CC) -o $@ -c $(CFLAGS) $<\r
.S.o:\r
- gcc -o $@ -c $(CFLAGS) $<\r
+ $(CC) -o $@ -c $(CFLAGS) $<\r
.s.o:\r
- gcc -o $@ -c $(CFLAGS) $(<:.s=.S)\r
+ $(CC) -o $@ -c $(CFLAGS) -x assembler-with-cpp $<\r
\r
all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP)\r
\r
$(warning Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN)\r
$(warning somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.)\r
else\r
- dxe2gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) $(OBJECTS) -D "Mesa DOS GLUT" -U\r
+ -dxe2gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) $(OBJECTS) -E djgpp_ -E glut -D "Mesa DJGPP GLUT" -U\r
endif\r
\r
clean:\r
- -$(RM) *.o\r
- -$(RM) PC_HW\*.o\r
-\r
-callback.o: callback.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h\r
-color.o: color.c ../include/GL/glut.h\r
-font.o: font.c ../include/GL/glut.h\r
-globals.o: globals.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h\r
-init.o: init.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h\r
-menu.o: menu.c ../include/GL/glut.h\r
-models.o: models.c ../include/GL/glut.h\r
-overlay.o: overlay.c ../include/GL/glut.h\r
-state.o: state.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h\r
-teapot.o: teapot.c ../include/GL/glut.h\r
-window.o: window.c ../include/GL/glut.h ../include/GL/dmesa.h internal.h \\r
- PC_HW/pc_hw.h\r
-\r
-PC_HW/pc_hw.o: PC_HW/pc_hw.c PC_HW/pc_hw.h\r
-PC_HW/pc_keyb.o: PC_HW/pc_keyb.c PC_HW/pc_hw.h\r
-PC_HW/pc_mouse.o: PC_HW/pc_mouse.c PC_HW/pc_hw.h\r
-PC_HW/pc_timer.o: PC_HW/pc_timer.c PC_HW/pc_hw.h\r
-PC_HW/pc_irq.o: PC_HW/pc_irq.S\r
+ -$(RM) $(subst /,\,*.o)\r
+ -$(RM) $(subst /,\,PC_HW/*.o)\r
+ -$(RM) $(subst /,\,$(MARK)/*.o)\r
+\r
+-include depend\r
/*\r
- * PC/HW routine collection v1.0 for DOS/DJGPP\r
+ * PC/HW routine collection v1.1 for DOS/DJGPP\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
/*\r
* IRQ\r
*/\r
-#define ENABLE() __asm__ __volatile__ ("sti")\r
-#define DISABLE() __asm__ __volatile__ ("cli")\r
+#define ENABLE() __asm __volatile ("sti")\r
+#define DISABLE() __asm __volatile ("cli")\r
\r
extern int pc_install_irq (int i, int (*handler) ());\r
extern int pc_remove_irq (int i);\r
/*\r
- * PC/HW routine collection v1.0 for DOS/DJGPP\r
+ * PC/HW routine collection v1.1 for DOS/DJGPP\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
/* kb_wait_for_write_ready:\r
* Wait for the keyboard controller to set the ready-for-write bit.\r
*/\r
-static __inline__ int kb_wait_for_write_ready (void)\r
+static __inline int kb_wait_for_write_ready (void)\r
{\r
int timeout = 4096;\r
\r
/* kb_wait_for_read_ready:\r
* Wait for the keyboard controller to set the ready-for-read bit.\r
*/\r
-static __inline__ int kb_wait_for_read_ready (void)\r
+static __inline int kb_wait_for_read_ready (void)\r
{\r
int timeout = 16384;\r
\r
/* kb_send_data:\r
* Sends a byte to the keyboard controller. Returns 1 if all OK.\r
*/\r
-static __inline__ int kb_send_data (unsigned char data)\r
+static __inline int kb_send_data (unsigned char data)\r
{\r
int resends = 4;\r
int timeout, temp;\r
in_a_terrupt--;\r
} ENDOFUNC(handle_code)\r
\r
-static __inline__ void satisfy (void)\r
+static __inline void satisfy (void)\r
{\r
- __asm__("\n\\r
+ __asm("\n\\r
inb $0x61, %%al \n\\r
movb %%al, %%ah \n\\r
orb $0x80, %%al \n\\r
only SIGINT (but not Ctrl-Break)\r
calls the destructors and will safely clean up\r
*/\r
- __asm__("\n\\r
+ __asm("\n\\r
movb $0x79, %%al \n\\r
call ___djgpp_hw_exception \n\\r
":::"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");\r
/*\r
- * PC/HW routine collection v1.0 for DOS/DJGPP\r
+ * PC/HW routine collection v1.1 for DOS/DJGPP\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
\r
#define CLEAR_MICKEYS() \\r
do { \\r
- __asm__ __volatile__ ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \\r
+ __asm __volatile ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \\r
ox = oy = 0; \\r
} while (0)\r
\r
{\r
if (mouse_callback) {\r
pc_clexit(pc_remove_mouse);\r
- __asm__("\n\\r
+ __asm("\n\\r
movl %%edx, %%ecx \n\\r
shrl $16, %%ecx \n\\r
movw $0x0304, %%ax \n\\r
}\r
\r
/* reset mouse and get status */\r
- __asm__("\n\\r
+ __asm("\n\\r
xorl %%eax, %%eax \n\\r
int $0x33 \n\\r
andl %%ebx, %%eax \n\\r
}\r
\r
/* try to hook a call-back */\r
- __asm__("\n\\r
+ __asm("\n\\r
pushl %%ds \n\\r
pushl %%es \n\\r
movw $0x0303, %%ax \n\\r
/* not implemented */\r
}\r
\r
-__asm__("\n\\r
+__asm("\n\\r
.balign 4 \n\\r
.global _mouse_wrapper \n\\r
_mouse_wrapper: \n\\r
--- /dev/null
+
+/* Copyright (c) Mark J. Kilgard, 1994. */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+#include "glutbitmap.h"
+
+void APIENTRY
+glutBitmapCharacter(GLUTbitmapFont font, int c)
+{
+ const BitmapCharRec *ch;
+ BitmapFontPtr fontinfo;
+ GLint swapbytes, lsbfirst, rowlength;
+ GLint skiprows, skippixels, alignment;
+
+#if defined(_WIN32)
+ fontinfo = (BitmapFontPtr) __glutFont(font);
+#else
+ fontinfo = (BitmapFontPtr) font;
+#endif
+
+ if (c < fontinfo->first ||
+ c >= fontinfo->first + fontinfo->num_chars)
+ return;
+ ch = fontinfo->ch[c - fontinfo->first];
+ if (ch) {
+ /* Save current modes. */
+ glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
+ glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
+ glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
+ glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
+ glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+ /* Little endian machines (DEC Alpha for example) could
+ benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
+ instead of GL_FALSE, but this would require changing the
+ generated bitmaps too. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
+ ch->advance, 0, ch->bitmap);
+ /* Restore saved modes. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+ }
+}
*/\r
\r
/*\r
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP glut driver v1.1 for Mesa 4.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
\r
\r
#include "GL/glut.h"\r
+#ifndef FX\r
#include "GL/dmesa.h"\r
+#else\r
+#include "GL/fxmesa.h"\r
+#endif\r
#include "internal.h"\r
\r
\r
\r
static int window;\r
\r
+#ifndef FX\r
static DMesaVisual visual = NULL;\r
static DMesaContext context = NULL;\r
static DMesaBuffer buffer[MAX_WINDOWS];\r
+#else\r
+static void *visual = NULL;\r
+static fxMesaContext context = NULL;\r
+static int fx_attrib[32];\r
+#endif\r
\r
\r
\r
for (i=0; i<MAX_WINDOWS; i++) {\r
glutDestroyWindow(i+1);\r
}\r
+#ifndef FX\r
if (context) DMesaDestroyContext(context);\r
if (visual) DMesaDestroyVisual(visual);\r
+#else\r
+ if (context) fxMesaDestroyContext(context);\r
+#endif\r
\r
pc_close_stdout();\r
pc_close_stderr();\r
screen_h = 768;\r
}\r
\r
+#ifndef FX\r
if ((visual=DMesaCreateVisual(screen_w, screen_h, DEFAULT_BPP,\r
g_display_mode & GLUT_DOUBLE,\r
g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,\r
DMesaDestroyVisual(visual);\r
return 0;\r
}\r
+#else\r
+ i = 0;\r
+ if (g_display_mode & GLUT_DOUBLE) fx_attrib[i++] = FXMESA_DOUBLEBUFFER;\r
+ if (g_display_mode & GLUT_DEPTH) { fx_attrib[i++] = FXMESA_DEPTH_SIZE; fx_attrib[i++] = DEPTH_SIZE; }\r
+ if (g_display_mode & GLUT_STENCIL) { fx_attrib[i++] = FXMESA_STENCIL_SIZE; fx_attrib[i++] = STENCIL_SIZE; }\r
+ if (g_display_mode & GLUT_ACCUM) { fx_attrib[i++] = FXMESA_ACCUM_SIZE; fx_attrib[i++] = ACCUM_SIZE; }\r
+ fx_attrib[i] = FXMESA_NONE;\r
+ if ((context=fxMesaCreateBestContext(-1, screen_w, screen_h, fx_attrib))==NULL) {\r
+ return 0;\r
+ }\r
+#endif\r
\r
pc_open_stdout();\r
pc_open_stderr();\r
pc_atexit(clean);\r
}\r
\r
+#ifndef FX\r
for (i=0; i<MAX_WINDOWS; i++) {\r
if (!buffer[i]) {\r
DMesaBuffer b;\r
}\r
\r
return 0;\r
+#else\r
+ fxMesaMakeCurrent(context);\r
+\r
+ return 1;\r
+#endif\r
}\r
\r
\r
\r
void APIENTRY glutDestroyWindow (int win)\r
{\r
+#ifndef FX\r
if (buffer[win-1]) {\r
DMesaDestroyBuffer(buffer[win-1]);\r
buffer[win-1] = NULL;\r
}\r
+#endif\r
}\r
\r
\r
void APIENTRY glutSwapBuffers (void)\r
{\r
if (g_mouse) pc_scare_mouse();\r
+#ifndef FX\r
DMesaSwapBuffers(buffer[window]);\r
+#else\r
+ fxMesaSwapBuffers();\r
+#endif\r
if (g_mouse) pc_unscare_mouse();\r
}\r
\r
\r
void APIENTRY glutPositionWindow (int x, int y)\r
{\r
+#ifndef FX\r
if (DMesaViewport(buffer[window], x, y, g_width, g_height)) {\r
g_xpos = x;\r
g_ypos = y;\r
}\r
+#endif\r
}\r
\r
\r
void APIENTRY glutReshapeWindow (int width, int height)\r
{\r
+#ifndef FX\r
if (DMesaViewport(buffer[window], g_xpos, g_ypos, width, height)) {\r
g_width = width;\r
g_height = height;\r
glViewport(0, 0, width, height);\r
}\r
}\r
+#endif\r
}\r
\r
\r
*/\r
\r
/*\r
- * DOS/DJGPP device driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
#include "context.h"\r
#include "GL/dmesa.h"\r
#include "extensions.h"\r
-#inlcude "imports.h"\r
#include "macros.h"\r
#include "matrix.h"\r
#include "mmath.h"\r
GLframebuffer gl_buffer; /* The depth, stencil, accum, etc buffers */\r
void *the_window; /* your window handle, etc */\r
\r
- int bypp; /* bytes per pixel */\r
int xpos, ypos; /* position */\r
int width, height; /* size in pixels */\r
- int bwidth, len; /* bytes in a line, then total */\r
+ int bypp, stride, bytes; /* bytes per pixel, in a line, then total */\r
};\r
\r
/*\r
\r
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;\r
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;\r
- if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;\r
+ if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;\r
\r
if (ctx->Light.ShadeModel==GL_SMOOTH\r
&& swrast->_RasterMask==DEPTH_BIT\r
if (*colorMask==0xffffffff) {\r
if (mask & DD_BACK_LEFT_BIT) {\r
if (all) {\r
- vl_clear(b->the_window, b->len, c->ClearColor);\r
+ vl_clear(b->the_window, b->bytes, c->ClearColor);\r
} else {\r
vl_rect(b->the_window, x, y, width, height, c->ClearColor);\r
}\r
/*\r
* Set the current reading buffer.\r
*/\r
-static void set_buffer (GLcontext *ctx, GLframebuffer *buffer, GLenum mode)\r
+static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer,\r
+ GLenum mode)\r
{\r
+ /*\r
+ XXX this has to be fixed\r
+ */\r
+}\r
+\r
+\r
+\r
/*\r
- DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
- dmesa_update_state(ctx);\r
-*/\r
+ * Set the destination/draw buffer.\r
+ */\r
+static void set_draw_buffer (GLcontext *ctx, GLenum mode)\r
+{\r
+ /*\r
+ XXX this has to be fixed\r
+ */\r
}\r
\r
\r
{\r
switch (name) {\r
case GL_RENDERER:\r
- return (const GLubyte *)"Mesa DOS\0DJGPP port (c) Borca Daniel 31-mar-2002";\r
+ return (const GLubyte *)"Mesa DJGPP\0port (c) Borca Daniel 3-sep-2002";\r
default:\r
return NULL;\r
}\r
ctx->Driver.CopyPixels = _swrast_CopyPixels;\r
ctx->Driver.DrawPixels = _swrast_DrawPixels;\r
ctx->Driver.ReadPixels = _swrast_ReadPixels;\r
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;\r
\r
/* Software texture functions:\r
*/\r
\r
/* Statechange callbacks:\r
*/\r
+ ctx->Driver.SetDrawBuffer = set_draw_buffer;\r
ctx->Driver.ClearColor = clear_color;\r
\r
/* Initialize the TNL driver interface:\r
_ac_InvalidateState(ctx, new_state);\r
_tnl_InvalidateState(ctx, new_state);\r
\r
- swdd->SetBuffer = set_buffer;\r
+ swdd->SetReadBuffer = set_read_buffer;\r
\r
/* RGB(A) span/pixel functions */\r
swdd->WriteRGBASpan = write_rgba_span;\r
DMesaVisual v;\r
GLint redBits, greenBits, blueBits, alphaBits;\r
\r
+ int refresh;\r
+ char *var = getenv("DMESA_REFRESH");\r
+ if ((var == NULL) || ((refresh=atoi(var)) == 0)) {\r
+ refresh = 60;\r
+ }\r
+\r
if (!dbFlag) {\r
return NULL;\r
}\r
return NULL;\r
}\r
\r
- if (vl_video_init(width, height, colDepth)!=0) {\r
+ if (vl_video_init(width, height, colDepth, refresh) != 0) {\r
return NULL;\r
}\r
\r
\r
void DMesaDestroyVisual (DMesaVisual v)\r
{\r
- vl_video_exit(!0);\r
+ vl_video_exit();\r
_mesa_destroy_visual(v->gl_visual);\r
free(v);\r
}\r
GLboolean direct = GL_FALSE;\r
\r
if ((c=(DMesaContext)calloc(1, sizeof(struct dmesa_context)))!=NULL) {\r
- __GLimports imports;\r
- _mesa_init_default_imports( &imports, (void *) c);\r
c->gl_ctx = _mesa_create_context(visual->gl_visual,\r
share ? share->gl_ctx : NULL,\r
- &imports);\r
+ (void *)c, direct);\r
\r
_mesa_enable_sw_extensions(c->gl_ctx);\r
_mesa_enable_1_3_extensions(c->gl_ctx);\r
b->ypos = ypos;\r
b->width = width;\r
b->height = height;\r
- b->bwidth = width * b->bypp;\r
- b->len = b->bwidth * height;\r
+ b->stride = width * b->bypp;\r
+ b->bytes = b->stride * height;\r
return GL_TRUE;\r
}\r
}\r
void DMesaSwapBuffers (DMesaBuffer b)\r
{\r
/* copy/swap back buffer to front if applicable */\r
- vl_flip(b->the_window, b->bwidth, b->height);\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ _mesa_swapbuffers(ctx);\r
+ vl_flip(b->the_window, b->stride, b->height);\r
}\r
*/\r
\r
/*\r
- * DOS/DJGPP device driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
\r
\r
\r
+#ifndef MAX\r
+#define MAX(x, y) (((x)<(y))?(y):(x))\r
+#endif\r
+\r
+\r
+\r
/* _create_linear_mapping:\r
* Maps a physical address range into linear memory.\r
*/\r
*/\r
\r
/*\r
- * DOS/DJGPP device driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
#ifndef DPMIINT_H_included\r
#define DPMIINT_H_included\r
\r
-#ifndef NULL\r
-#define NULL 0\r
-#endif\r
-\r
-#ifndef MAX\r
-#define MAX(x, y) (((x)<(y))?(y):(x))\r
-#endif\r
-\r
int _create_selector (int *segment, unsigned long base, int size);\r
void _remove_selector (int *segment);\r
\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.0\r
+ * \r
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include <dpmi.h>\r
+#include <string.h>\r
+#include <stubinfo.h>\r
+#include <sys/exceptn.h>\r
+#include <sys/segments.h>\r
+#include <sys/farptr.h>\r
+#include <sys/movedata.h>\r
+\r
+#include "vesa.h"\r
+#include "../dpmiint.h"\r
+\r
+\r
+\r
+static vl_mode modes[64];\r
+\r
+static word16 vesa_ver;\r
+static int banked_selector, linear_selector;\r
+static int oldmode = -1;\r
+\r
+\r
+\r
+/*\r
+ * VESA info\r
+ */\r
+#define V_SIGN 0\r
+#define V_MINOR 4\r
+#define V_MAJOR 5\r
+#define V_OEM_OFS 6\r
+#define V_OEM_SEG 8\r
+#define V_MODE_OFS 14\r
+#define V_MODE_SEG 16\r
+#define V_MEMORY 18\r
+\r
+/*\r
+ * mode info\r
+ */\r
+#define M_ATTR 0\r
+#define M_GRAN 4\r
+#define M_SCANLEN 16\r
+#define M_XRES 18\r
+#define M_YRES 20\r
+#define M_BPP 25\r
+#define M_RED 31\r
+#define M_GREEN 33\r
+#define M_BLUE 35\r
+#define M_PHYS_PTR 40\r
+\r
+/*\r
+ * VESA 3.0 CRTC timings structure\r
+ */\r
+typedef struct CRTCInfoBlock {\r
+ unsigned short HorizontalTotal;\r
+ unsigned short HorizontalSyncStart;\r
+ unsigned short HorizontalSyncEnd;\r
+ unsigned short VerticalTotal;\r
+ unsigned short VerticalSyncStart;\r
+ unsigned short VerticalSyncEnd;\r
+ unsigned char Flags;\r
+ unsigned long PixelClock; /* units of Hz */\r
+ unsigned short RefreshRate; /* units of 0.01 Hz */\r
+ unsigned char reserved[40];\r
+} __PACKED__ CRTCInfoBlock;\r
+\r
+#define HNEG (1 << 2)\r
+#define VNEG (1 << 3)\r
+#define DOUBLESCAN (1 << 0)\r
+\r
+\r
+\r
+/* vesa_init:\r
+ * Attempts to detect VESA, check video modes and create selectors.\r
+ * Returns 0 if error.\r
+ */\r
+static word16 vesa_init (void)\r
+{\r
+ __dpmi_regs r;\r
+ word16 *p;\r
+ vl_mode *q;\r
+ char vesa_info[512], tmp[512];\r
+ int maxsize = 0;\r
+ word32 linearfb = 0;\r
+\r
+ if (vesa_ver) {\r
+ return vesa_ver;\r
+ }\r
+\r
+ _farpokel(_stubinfo->ds_selector, 0, 0x32454256);\r
+ r.x.ax = 0x4f00;\r
+ r.x.di = 0;\r
+ r.x.es = _stubinfo->ds_segment;\r
+ __dpmi_int(0x10, &r);\r
+ movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512);\r
+ if ((r.x.ax!=0x004f) || ((_32_ vesa_info[V_SIGN])!=0x41534556)) {\r
+ return 0;\r
+ }\r
+\r
+ p = (word16 *)(((_16_ vesa_info[V_MODE_SEG])<<4) + (_16_ vesa_info[V_MODE_OFS]));\r
+ q = modes;\r
+ do {\r
+ if ((q->mode=_farpeekw(__djgpp_dos_sel, (unsigned long)(p++)))==0xffff) {\r
+ break;\r
+ }\r
+\r
+ r.x.ax = 0x4f01;\r
+ r.x.cx = q->mode;\r
+ r.x.di = 512;\r
+ r.x.es = _stubinfo->ds_segment;\r
+ __dpmi_int(0x10, &r);\r
+ movedata(_stubinfo->ds_selector, 512, _my_ds(), (unsigned)tmp, 256);\r
+ switch (tmp[M_BPP]) {\r
+ case 16:\r
+ q->bpp = tmp[M_RED] + tmp[M_GREEN] + tmp[M_BLUE];\r
+ break;\r
+ case 15:\r
+ case 24:\r
+ case 32:\r
+ q->bpp = tmp[M_BPP];\r
+ break;\r
+ default:\r
+ q->bpp = 0;\r
+ }\r
+ if ((r.x.ax==0x004f) && ((tmp[M_ATTR]&0x11)==0x11) && q->bpp) {\r
+ q->xres = _16_ tmp[M_XRES];\r
+ q->yres = _16_ tmp[M_YRES];\r
+ q->scanlen = _16_ tmp[M_SCANLEN];\r
+ q->gran = (_16_ tmp[M_GRAN])<<10;\r
+ if (tmp[M_ATTR]&0x80) {\r
+#if 0\r
+ *(q+1) = *q++;\r
+#else\r
+ vl_mode *q1 = q + 1;\r
+ *q1 = *q++;\r
+#endif\r
+ linearfb = _32_ tmp[M_PHYS_PTR];\r
+ q->mode |= 0x4000;\r
+ }\r
+ if (maxsize<(q->scanlen*q->yres)) {\r
+ maxsize = q->scanlen*q->yres;\r
+ }\r
+ q++;\r
+ }\r
+ } while (TRUE);\r
+\r
+ if (q==modes) {\r
+ return 0;\r
+ }\r
+ if (linearfb) {\r
+ maxsize = ((maxsize+0xfffUL)&~0xfffUL);\r
+ if (_create_selector(&linear_selector, linearfb, maxsize)) {\r
+ return 0;\r
+ }\r
+ }\r
+ if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) {\r
+ _remove_selector(&linear_selector);\r
+ return 0;\r
+ }\r
+\r
+ for (q=modes; q->mode!=0xffff; q++) {\r
+ q->sel = (q->mode&0x4000) ? linear_selector : banked_selector;\r
+ }\r
+\r
+ return (vesa_ver = _16_ vesa_info[V_MINOR]);\r
+}\r
+\r
+\r
+\r
+/* vesa_finit:\r
+ * Frees all resources allocated by VESA init code.\r
+ */\r
+static void vesa_finit (void)\r
+{\r
+ if (vesa_ver) {\r
+ _remove_selector(&linear_selector);\r
+ _remove_selector(&banked_selector);\r
+ }\r
+}\r
+\r
+\r
+\r
+/* vesa_getmodes:\r
+ * Returns ptr to mode array.\r
+ */\r
+static vl_mode *vesa_getmodes (void)\r
+{\r
+ return (vesa_init() == 0) ? NULL : modes;\r
+}\r
+\r
+\r
+\r
+/* _closest_pixclk:\r
+ * Uses VESA 3.0 function 0x4F0B to find the closest pixel clock to the\r
+ * requested value.\r
+ */\r
+static unsigned long _closest_pixclk (int mode_no, unsigned long vclk)\r
+{\r
+ __dpmi_regs r;\r
+\r
+ r.x.ax = 0x4F0B;\r
+ r.h.bl = 0;\r
+ r.d.ecx = vclk;\r
+ r.x.dx = mode_no;\r
+ __dpmi_int(0x10, &r);\r
+\r
+ return (r.x.ax==0x004f) ? r.d.ecx : 0;\r
+}\r
+\r
+\r
+\r
+/* _crtc_timing:\r
+ * Calculates CRTC mode timings.\r
+ */\r
+static void _crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust, int yadjust)\r
+{\r
+ int HTotal, VTotal;\r
+ int HDisp, VDisp;\r
+ int HSS, VSS;\r
+ int HSE, VSE;\r
+ int HSWidth, VSWidth;\r
+ int SS, SE;\r
+ int doublescan = FALSE;\r
+\r
+ if (yres < 400) {\r
+ doublescan = TRUE;\r
+ yres *= 2;\r
+ }\r
+\r
+ HDisp = xres;\r
+ HTotal = (int)(HDisp * 1.27) & ~0x7;\r
+ HSWidth = (int)((HTotal - HDisp) / 5) & ~0x7;\r
+ HSS = HDisp + 16;\r
+ HSE = HSS + HSWidth;\r
+ VDisp = yres;\r
+ VTotal = VDisp * 1.07;\r
+ VSWidth = (VTotal / 100) + 1;\r
+ VSS = VDisp + ((int)(VTotal - VDisp) / 5) + 1;\r
+ VSE = VSS + VSWidth;\r
+\r
+ SS = HSS + xadjust;\r
+ SE = HSE + xadjust;\r
+\r
+ if (xadjust < 0) {\r
+ if (SS < (HDisp + 8)) {\r
+ SS = HDisp + 8;\r
+ SE = SS + HSWidth;\r
+ }\r
+ } else {\r
+ if ((HTotal - 24) < SE) {\r
+ SE = HTotal - 24;\r
+ SS = SE - HSWidth;\r
+ }\r
+ }\r
+\r
+ HSS = SS;\r
+ HSE = SE;\r
+\r
+ SS = VSS + yadjust;\r
+ SE = VSE + yadjust;\r
+\r
+ if (yadjust < 0) {\r
+ if (SS < (VDisp + 3)) {\r
+ SS = VDisp + 3;\r
+ SE = SS + VSWidth;\r
+ }\r
+ } else {\r
+ if ((VTotal - 4) < SE) {\r
+ SE = VTotal - 4;\r
+ SS = SE - VSWidth;\r
+ }\r
+ }\r
+\r
+ VSS = SS;\r
+ VSE = SE;\r
+\r
+ crtc->HorizontalTotal = HTotal;\r
+ crtc->HorizontalSyncStart = HSS;\r
+ crtc->HorizontalSyncEnd = HSE;\r
+ crtc->VerticalTotal = VTotal;\r
+ crtc->VerticalSyncStart = VSS;\r
+ crtc->VerticalSyncEnd = VSE;\r
+ crtc->Flags = HNEG | VNEG;\r
+\r
+ if (doublescan)\r
+ crtc->Flags |= DOUBLESCAN;\r
+}\r
+\r
+\r
+\r
+/* vesa_entermode:\r
+ * Attempts to enter specified video mode.\r
+ *\r
+ * success: 0\r
+ * failure: !0\r
+ */\r
+static int vesa_entermode (vl_mode *p, int refresh)\r
+{\r
+ __dpmi_regs r;\r
+\r
+ if (oldmode == -1) {\r
+ r.x.ax = 0x4f03;\r
+ __dpmi_int(0x10, &r);\r
+ oldmode = r.x.bx;\r
+ }\r
+\r
+ r.x.ax = 0x4f02;\r
+ r.x.bx = p->mode;\r
+\r
+ if ((vesa_ver>>8) >= 3) {\r
+ /* VESA 3.0 stuff for controlling the refresh rate */\r
+ CRTCInfoBlock crtc;\r
+ unsigned long vclk;\r
+ double f0;\r
+\r
+ _crtc_timing(&crtc, p->xres, p->yres, 0, 0);\r
+\r
+ vclk = (double)crtc.HorizontalTotal * crtc.VerticalTotal * refresh;\r
+ vclk = _closest_pixclk(p->mode, vclk);\r
+\r
+ if (vclk != 0) {\r
+ f0 = (double)vclk / (crtc.HorizontalTotal * crtc.VerticalTotal);\r
+ /*_current_refresh_rate = (int)(f0 + 0.5);*/\r
+\r
+ crtc.PixelClock = vclk;\r
+ crtc.RefreshRate = refresh * 100;\r
+\r
+ movedata(_my_ds(), (unsigned)&crtc, _stubinfo->ds_selector, 0, sizeof(crtc));\r
+\r
+ r.x.di = 0;\r
+ r.x.es = _stubinfo->ds_segment;\r
+ r.x.bx |= 0x0800;\r
+ }\r
+ }\r
+\r
+ __dpmi_int(0x10, &r);\r
+\r
+ return (r.x.ax != 0x004f);\r
+}\r
+\r
+\r
+\r
+/* vesa_restore:\r
+ * Restores to the mode prior to first call to vesa_entermode.\r
+ */\r
+static void vesa_restore (void)\r
+{\r
+ __dpmi_regs r;\r
+\r
+ if (oldmode != -1) {\r
+ r.x.ax = 0x4f02;\r
+ r.x.bx = oldmode;\r
+ __dpmi_int(0x10, &r);\r
+ }\r
+}\r
+\r
+\r
+\r
+/*\r
+ * the driver\r
+ */\r
+vl_driver VESA = {\r
+ vesa_getmodes,\r
+ vesa_entermode,\r
+ vesa_restore,\r
+ vesa_finit\r
+};\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.0\r
+ * \r
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#ifndef VESA_H_included\r
+#define VESA_H_included\r
+\r
+#include "../videoint.h"\r
+\r
+\r
+\r
+extern vl_driver VESA;\r
+\r
+#endif\r
*/\r
\r
/*\r
- * DOS/DJGPP device driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
*/\r
\r
\r
-#include <dpmi.h>\r
#include <stdlib.h>\r
-#include <string.h>\r
-#include <stubinfo.h>\r
-#include <sys/exceptn.h>\r
-#include <sys/segments.h>\r
-#include <sys/farptr.h>\r
\r
#include "video.h"\r
-#include "dpmiint.h"\r
+#include "videoint.h"\r
+#include "vesa/vesa.h"\r
\r
\r
\r
-typedef unsigned char word8;\r
-typedef unsigned short word16;\r
-typedef unsigned long word32;\r
-\r
-typedef struct vl_mode {\r
- int mode;\r
- int xres, yres;\r
- int scanlen;\r
- int bpp;\r
-} vl_mode;\r
-\r
-#define _16_ *(word16 *)&\r
-#define _32_ *(word32 *)&\r
-\r
-static int init;\r
-\r
-static vl_mode modes[64];\r
-\r
+static vl_driver *drv = &VESA;\r
/* card specific: valid forever */\r
-static word16 vesa_ver;\r
-static word32 hw_granularity, hw_linearfb;\r
+word32 vl_hw_granularity;\r
static unsigned int gran_shift, gran_mask;\r
/* based upon mode specific data: valid entire session */\r
-static int video_selector, banked_selector, linear_selector;\r
+int vl_video_selector;\r
static int video_scanlen, video_bypp;\r
/* valid until next buffer */\r
-static int current_offset, current_delta, current_width;\r
+int vl_current_offset, vl_current_delta;\r
+static int current_width;\r
\r
\r
\r
/* lookup table for scaling 5 bit colors up to 8 bits */\r
-static int _rgb_scale_5[32] =\r
-{\r
+static int _rgb_scale_5[32] = {\r
0, 8, 16, 24, 32, 41, 49, 57,\r
65, 74, 82, 90, 98, 106, 115, 123,\r
131, 139, 148, 156, 164, 172, 180, 189,\r
};\r
\r
/* lookup table for scaling 6 bit colors up to 8 bits */\r
-static int _rgb_scale_6[64] =\r
-{\r
+static int _rgb_scale_6[64] = {\r
0, 4, 8, 12, 16, 20, 24, 28,\r
32, 36, 40, 44, 48, 52, 56, 60,\r
64, 68, 72, 76, 80, 85, 89, 93,\r
\r
\r
\r
-/*\r
- * virtual clearing\r
- */\r
-void (*vl_clear) (void *buffer, int len, int color);\r
-\r
-#define v_clear15 v_clear16\r
-extern void v_clear16 (void *buffer, int len, int color);\r
-extern void v_clear32 (void *buffer, int len, int color);\r
-__asm__("\n\\r
- .text \n\\r
- .balign 4 \n\\r
- .global _v_clear16 \n\\r
-_v_clear16: \n\\r
- movl 12(%esp), %eax \n\\r
- pushw %ax \n\\r
- pushw %ax \n\\r
- popl %eax \n\\r
- jmp _v_clear_common \n\\r
- .balign 4 \n\\r
- .global _v_clear32 \n\\r
-_v_clear32: \n\\r
- movl 12(%esp), %eax \n\\r
- .balign 4 \n\\r
-_v_clear_common: \n\\r
- movl 8(%esp), %ecx \n\\r
- movl 4(%esp), %edx \n\\r
- shrl $2, %ecx \n\\r
- 0: \n\\r
- .balign 4 \n\\r
- movl %eax, (%edx) \n\\r
- addl $4, %edx \n\\r
- decl %ecx \n\\r
- jnz 0b \n\\r
- ret");\r
-extern void v_clear24 (void *buffer, int len, int color);\r
-__asm__("\n\\r
- .text \n\\r
- .balign 4 \n\\r
- .global _v_clear24 \n\\r
-_v_clear24: \n\\r
- movl 8(%esp), %edx \n\\r
- movl $0xaaaaaaab, %eax \n\\r
- mull %edx \n\\r
- movl 12(%esp), %eax \n\\r
- movl %edx, %ecx \n\\r
- movl 4(%esp), %edx \n\\r
- pushl %ebx \n\\r
- shrl %ecx \n\\r
- movb 18(%esp), %bl \n\\r
- .balign 4 \n\\r
- 0: \n\\r
- movw %ax, (%edx) \n\\r
- movb %bl, 2(%edx) \n\\r
- addl $3, %edx \n\\r
- decl %ecx \n\\r
- jnz 0b \n\\r
- popl %ebx \n\\r
- ret");\r
+void (*vl_clear) (void *buffer, int bytes, int color);\r
+void (*vl_flip) (void *buffer, int stride, int height);\r
+int (*vl_mixrgba) (const unsigned char rgba[]);\r
+int (*vl_mixrgb) (const unsigned char rgb[]);\r
+void (*vl_putpixel) (void *buffer, int offset, int color);\r
+void (*vl_getrgba) (void *buffer, int offset, unsigned char rgba[4]);\r
\r
\r
\r
-/*\r
- * virtual rectangle clearing\r
+/* vl_rect:\r
+ * Clears a rectange with specified color.\r
*/\r
void vl_rect (void *buffer, int x, int y, int width, int height, int color)\r
{\r
\r
\r
\r
-/*\r
- * virtual dumping:\r
+/* vl_mixrgba*:\r
+ * Color composition (w/ ALPHA).\r
*/\r
-void (*vl_flip) (void *buffer, int width, int height);\r
-\r
-extern void b_dump_virtual (void *buffer, int width, int height);\r
-__asm__("\n\\r
- .text \n\\r
- .balign 4 \n\\r
- .global _b_dump_virtual \n\\r
-_b_dump_virtual: \n\\r
- pushl %ebx \n\\r
- pushl %esi \n\\r
- pushl %edi \n\\r
- pushl %ebp \n\\r
- movl _video_selector, %fs \n\\r
- movl 4*4+4+0(%esp), %esi \n\\r
- movl _hw_granularity, %ebp \n\\r
- xorl %edx, %edx \n\\r
- movl _current_offset, %eax \n\\r
- divl %ebp \n\\r
- movl %edx, %edi \n\\r
- pushl %eax \n\\r
- movl %eax, %edx \n\\r
- xorl %ebx, %ebx \n\\r
- movw $0x4f05, %ax \n\\r
- int $0x10 \n\\r
- movl _current_delta, %ebx \n\\r
- movl 5*4+4+4(%esp), %ecx \n\\r
- movl 5*4+4+8(%esp), %edx \n\\r
- shrl $2, %ecx \n\\r
- .balign 4 \n\\r
- 0: \n\\r
- pushl %ecx \n\\r
- .balign 4 \n\\r
- 1: \n\\r
- cmpl %ebp, %edi \n\\r
- jb 2f \n\\r
- pushl %ebx \n\\r
- pushl %edx \n\\r
- incl 12(%esp) \n\\r
- movw $0x4f05, %ax \n\\r
- movl 12(%esp), %edx \n\\r
- xorl %ebx, %ebx \n\\r
- int $0x10 \n\\r
- popl %edx \n\\r
- popl %ebx \n\\r
- subl %ebp, %edi \n\\r
- 2: \n\\r
- movl (%esi), %eax \n\\r
- addl $4, %esi \n\\r
- movl %eax, %fs:(%edi) \n\\r
- addl $4, %edi \n\\r
- decl %ecx \n\\r
- jnz 1b \n\\r
- popl %ecx \n\\r
- addl %ebx, %edi \n\\r
- decl %edx \n\\r
- jnz 0b \n\\r
- popl %eax \n\\r
- popl %ebp \n\\r
- popl %edi \n\\r
- popl %esi \n\\r
- popl %ebx \n\\r
- ret");\r
-extern void l_dump_virtual (void *buffer, int width, int height);\r
-__asm__("\n\\r
- .text \n\\r
- .balign 4 \n\\r
- .global _l_dump_virtual \n\\r
-_l_dump_virtual: \n\\r
- pushl %ebx \n\\r
- pushl %esi \n\\r
- pushl %edi \n\\r
- movl _video_selector, %fs \n\\r
- movl 3*4+4+0(%esp), %esi \n\\r
- movl _current_offset, %edi \n\\r
- movl 3*4+4+4(%esp), %ecx \n\\r
- movl 3*4+4+8(%esp), %edx \n\\r
- movl _current_delta, %ebx \n\\r
- shrl $2, %ecx \n\\r
- .balign 4 \n\\r
- 0: \n\\r
- pushl %ecx \n\\r
- .balign 4 \n\\r
- 1: \n\\r
- movl (%esi), %eax \n\\r
- addl $4, %esi \n\\r
- movl %eax, %fs:(%edi) \n\\r
- addl $4, %edi \n\\r
- decl %ecx \n\\r
- jnz 1b \n\\r
- popl %ecx \n\\r
- addl %ebx, %edi \n\\r
- decl %edx \n\\r
- jnz 0b \n\\r
- popl %edi \n\\r
- popl %esi \n\\r
- popl %ebx \n\\r
- ret");\r
-\r
-\r
-\r
-/*\r
- * mix RGBA components\r
- */\r
-int (*vl_mixrgba) (const unsigned char rgba[]);\r
- \r
#define vl_mixrgba15 vl_mixrgb15\r
#define vl_mixrgba16 vl_mixrgb16\r
#define vl_mixrgba24 vl_mixrgb24\r
\r
\r
\r
-/*\r
- * mix RGB components\r
+/* vl_mixrgb*:\r
+ * Color composition (w/o ALPHA).\r
*/\r
-int (*vl_mixrgb) (const unsigned char rgb[]);\r
- \r
static int vl_mixrgb15 (const unsigned char rgb[])\r
{\r
return ((rgb[0]>>3)<<10)|((rgb[1]>>3)<<5)|(rgb[2]>>3);\r
\r
\r
\r
-/*\r
- * vl_putpixel*\r
- */\r
-void (*vl_putpixel) (void *buffer, int offset, int color);\r
- \r
-#define v_putpixel15 v_putpixel16\r
-extern void v_putpixel16 (void *buffer, int offset, int color);\r
-__asm__("\n\\r
- .text \n\\r
- .balign 4 \n\\r
- .global _v_putpixel16 \n\\r
-_v_putpixel16: \n\\r
- movl 8(%esp), %edx \n\\r
- shll %edx \n\\r
- movl 12(%esp), %eax \n\\r
- addl 4(%esp), %edx \n\\r
- movw %ax, (%edx) \n\\r
- ret");\r
-extern void v_putpixel24 (void *buffer, int offset, int color);\r
-__asm__("\n\\r
- .text \n\\r
- .balign 4 \n\\r
- .global _v_putpixel24 \n\\r
-_v_putpixel24: \n\\r
- movl 8(%esp), %edx \n\\r
- leal (%edx, %edx, 2), %edx \n\\r
- movl 12(%esp), %eax \n\\r
- addl 4(%esp), %edx \n\\r
- movw %ax, (%edx) \n\\r
- shrl $16, %eax \n\\r
- movb %al, 2(%edx) \n\\r
- ret");\r
-extern void v_putpixel32 (void *buffer, int offset, int color);\r
-__asm__("\n\\r
- .text \n\\r
- .balign 4 \n\\r
- .global _v_putpixel32 \n\\r
-_v_putpixel32: \n\\r
- movl 8(%esp), %edx \n\\r
- shll $2, %edx \n\\r
- movl 12(%esp), %eax \n\\r
- addl 4(%esp), %edx \n\\r
- movl %eax, (%edx) \n\\r
- ret");\r
-\r
-\r
-\r
-/*\r
- * get pixel and decompose R, G, B, A\r
- */\r
-void (*vl_getrgba) (void *buffer, int offset, unsigned char rgba[4]);\r
-\r
-/*\r
- * v_getrgba*\r
+/* v_getrgba*:\r
+ * Color decomposition.\r
*/\r
static void v_getrgba15 (void *buffer, int offset, unsigned char rgba[4])\r
{\r
\r
\r
\r
-/*\r
- * sync buffer with video hardware\r
+/* vl_sync_buffer:\r
+ * Syncs buffer with video hardware. Returns NULL in case of failure.\r
*/\r
void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)\r
{\r
return NULL;\r
} else {\r
if ((newbuf=realloc(buffer, width*height*video_bypp))!=NULL) {\r
- current_offset = video_scanlen * y + video_bypp * x;\r
+ vl_current_offset = video_scanlen * y + video_bypp * x;\r
current_width = width;\r
- current_delta = video_scanlen - video_bypp * width;\r
+ vl_current_delta = video_scanlen - video_bypp * width;\r
}\r
return newbuf;\r
}\r
\r
\r
\r
-/*\r
- * attempts to detect VESA and video modes\r
- */\r
-static word16 vl_vesa_init (void)\r
-{\r
- __dpmi_regs r;\r
- unsigned short *p;\r
- vl_mode *q;\r
- char vesa_info[512], tmp[512];\r
- int maxsize = 0;\r
-\r
- _farpokel(_stubinfo->ds_selector, 0, 0x32454256);\r
- r.x.ax = 0x4f00;\r
- r.x.di = 0;\r
- r.x.es = _stubinfo->ds_segment;\r
- __dpmi_int(0x10, &r);\r
- if (r.x.ax==0x004f) {\r
- movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512);\r
- if ((_32_ vesa_info[0])==0x41534556) {\r
- p = (unsigned short *)(((_16_ vesa_info[0x10])<<4) + (_16_ vesa_info[0x0e]));\r
- q = modes;\r
- do {\r
- if ((q->mode=_farpeekw(__djgpp_dos_sel, (unsigned long)(p++)))==0xffff) {\r
- break;\r
- }\r
-\r
- r.x.ax = 0x4f01;\r
- r.x.cx = q->mode;\r
- r.x.di = 512;\r
- r.x.es = _stubinfo->ds_segment;\r
- __dpmi_int(0x10, &r);\r
- movedata(_stubinfo->ds_selector, 512, _my_ds(), (unsigned)tmp, 256);\r
- switch (tmp[0x19]) {\r
- case 16:\r
- q->bpp = tmp[0x1f] + tmp[0x21] + tmp[0x23];\r
- break;\r
- case 15:\r
- case 24:\r
- case 32:\r
- q->bpp = tmp[0x19];\r
- break;\r
- default:\r
- q->bpp = 0;\r
- }\r
- if ((r.x.ax==0x004f)&&((tmp[0]&0x11)==0x11)&&q->bpp) {\r
- q->xres = _16_ tmp[0x12];\r
- q->yres = _16_ tmp[0x14];\r
- q->scanlen = _16_ tmp[0x10];\r
- hw_granularity = (_16_ tmp[4])<<10;\r
- if (tmp[0]&0x80) {\r
- *(q+1) = *q++;\r
- hw_linearfb = _32_ tmp[0x28];\r
- q->mode |= 0x4000;\r
- }\r
- if (maxsize<(q->scanlen*q->yres)) {\r
- maxsize = q->scanlen*q->yres;\r
- }\r
- q++;\r
- }\r
- } while (!0);\r
-\r
- if (hw_linearfb) {\r
- maxsize = ((maxsize+0xfffUL)&~0xfffUL);\r
- if (_create_selector(&linear_selector, hw_linearfb, maxsize)) {\r
- return 0;\r
- }\r
- }\r
- if (_create_selector(&banked_selector, 0xa0000, hw_granularity)) {\r
- _remove_selector(&linear_selector);\r
- return 0;\r
- }\r
-\r
- return _16_ vesa_info[4];\r
- }\r
- }\r
-\r
- return 0;\r
-}\r
-\r
-\r
-\r
-/*\r
- * setup mode\r
+/* vl_setup_mode:\r
+ *\r
+ * success: 0\r
+ * failure: -1\r
*/\r
static int vl_setup_mode (vl_mode *p)\r
{\r
if (p->mode&0x4000) {\r
- video_selector = linear_selector;\r
vl_flip = l_dump_virtual;\r
} else {\r
- { int n; for (gran_shift=0, n=hw_granularity; n; gran_shift++, n>>=1) ; }\r
+ { int n; for (gran_shift=0, n=p->gran; n; gran_shift++, n>>=1) ; }\r
gran_mask = (1<<(--gran_shift)) - 1;\r
- if (hw_granularity!=(gran_mask+1)) {\r
+ if ((unsigned)p->gran != (gran_mask+1)) {\r
return -1;\r
}\r
- video_selector = banked_selector;\r
+ vl_hw_granularity = p->gran;\r
vl_flip = b_dump_virtual;\r
}\r
\r
\r
video_bypp = (p->bpp+7)/8;\r
video_scanlen = p->scanlen;\r
+ vl_video_selector = p->sel;\r
\r
return 0;\r
}\r
\r
\r
\r
-/*\r
- * shutdown the video engine\r
+/* vl_video_exit:\r
+ * Shutdown the video engine.\r
+ * Restores to the mode prior to first call to `vl_video_init'.\r
*/\r
-void vl_video_exit (int textmode)\r
+void vl_video_exit (void)\r
{\r
- if (init) {\r
- if (textmode) {\r
- __asm__("movw $0x3, %%ax; int $0x10":::"%eax");\r
- }\r
- \r
- _remove_selector(&linear_selector);\r
- _remove_selector(&banked_selector);\r
- \r
- init = !init;\r
- }\r
+ drv->restore();\r
+ drv->finit();\r
}\r
\r
\r
\r
-/*\r
- * initialize video engine\r
+/* vl_video_init:\r
+ * Enter mode.\r
*\r
- * success: 0\r
- * failure: -1\r
+ * success: 0\r
+ * failure: -1\r
*/\r
-int vl_video_init (int width, int height, int bpp)\r
+int vl_video_init (int width, int height, int bpp, int refresh)\r
{\r
vl_mode *p, *q;\r
unsigned int min;\r
\r
- /* check for prior initialization */\r
- if (init) {\r
- return 0;\r
- }\r
-\r
/* initialize hardware */\r
- if (!(vesa_ver=vl_vesa_init())) {\r
+ if ((q=drv->getmodes()) == NULL) {\r
return -1;\r
}\r
- init = !init;\r
\r
/* search for a mode that fits our request */\r
- for (min=-1, p=NULL, q=modes; q->mode!=0xffff; q++) {\r
- if ((q->xres>=width)&&(q->yres>=height)&&(q->bpp==bpp)) {\r
+ for (min=-1, p=NULL; q->mode!=0xffff; q++) {\r
+ if ((q->xres>=width) && (q->yres>=height) && (q->bpp==bpp)) {\r
if (min>=(unsigned)(q->xres*q->yres)) {\r
min = q->xres*q->yres;\r
p = q;\r
}\r
}\r
\r
- if (p) {\r
- vl_setup_mode(p);\r
- __asm__("movw $0x4f02, %%ax; int $0x10"::"b"(p->mode):"%eax");\r
+ /* check, setup and enter mode */\r
+ if ((p!=NULL) && (vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {\r
return 0;\r
- } else {\r
- /* no suitable mode found, abort */\r
- vl_video_exit(0);\r
- return -1;\r
}\r
+\r
+ /* abort */\r
+ return -1;\r
}\r
*/\r
\r
/*\r
- * DOS/DJGPP device driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
#ifndef VIDEO_H_included\r
#define VIDEO_H_included\r
\r
-int vl_video_init (int width, int height, int bpp);\r
-void vl_video_exit (int textmode);\r
+int vl_video_init (int width, int height, int bpp, int refresh);\r
+void vl_video_exit (void);\r
\r
void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);\r
\r
-extern void (*vl_clear) (void *buffer, int len, int color);\r
+extern void (*vl_clear) (void *buffer, int bytes, int color);\r
void vl_rect (void *buffer, int x, int y, int width, int height, int color);\r
\r
-void (*vl_flip) (void *buffer, int width, int height);\r
+void (*vl_flip) (void *buffer, int stride, int height);\r
\r
extern int (*vl_mixrgba) (const unsigned char rgba[]);\r
extern int (*vl_mixrgb) (const unsigned char rgb[]);\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.0\r
+ * \r
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#ifndef VIDEOINT_H_included\r
+#define VIDEOINT_H_included\r
+\r
+/*\r
+ * general purpose defines, etc.\r
+ */\r
+#ifndef FALSE\r
+#define FALSE 0\r
+#define TRUE !FALSE\r
+#endif\r
+\r
+#define __PACKED__ __attribute__((packed))\r
+\r
+typedef unsigned char word8;\r
+typedef unsigned short word16;\r
+typedef unsigned long word32;\r
+\r
+#define _16_ *(word16 *)&\r
+#define _32_ *(word32 *)&\r
+\r
+\r
+\r
+/*\r
+ * video mode structure\r
+ */\r
+typedef struct vl_mode {\r
+ int mode;\r
+ int xres, yres;\r
+ int scanlen;\r
+ int bpp;\r
+\r
+ int sel;\r
+ int gran;\r
+} vl_mode;\r
+\r
+\r
+\r
+/*\r
+ * video driver structure\r
+ */\r
+typedef struct {\r
+ vl_mode *(*getmodes) (void);\r
+ int (*entermode) (vl_mode *p, int refresh);\r
+ void (*restore) (void);\r
+ void (*finit) (void);\r
+} vl_driver;\r
+\r
+\r
+\r
+/*\r
+ * asm routines to deal with virtual buffering\r
+ */\r
+#define v_clear15 v_clear16\r
+extern void v_clear16 (void *buffer, int bytes, int color);\r
+extern void v_clear32 (void *buffer, int bytes, int color);\r
+extern void v_clear24 (void *buffer, int bytes, int color);\r
+\r
+extern void b_dump_virtual (void *buffer, int stride, int height);\r
+extern void l_dump_virtual (void *buffer, int stride, int height);\r
+\r
+#define v_putpixel15 v_putpixel16\r
+extern void v_putpixel16 (void *buffer, int offset, int color);\r
+extern void v_putpixel24 (void *buffer, int offset, int color);\r
+extern void v_putpixel32 (void *buffer, int offset, int color);\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.0\r
+ * \r
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP device driver v1.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+ .file "virtual.S"\r
+\r
+/*\r
+ * extern word32 vl_hw_granularity;\r
+ * extern int vl_video_selector;\r
+ * extern int vl_current_offset, vl_current_delta;\r
+ */\r
+\r
+ .text\r
+\r
+/*\r
+ * void v_clear16 (void *buffer, int bytes, int color);\r
+ */\r
+ .balign 4\r
+ .global _v_clear16\r
+_v_clear16:\r
+ movl 12(%esp), %eax\r
+ pushw %ax\r
+ pushw %ax\r
+ popl %eax\r
+ jmp _v_clear_common\r
+\r
+/*\r
+ * void v_clear32 (void *buffer, int bytes, int color);\r
+ */\r
+ .balign 4\r
+ .global _v_clear32\r
+_v_clear32:\r
+ movl 12(%esp), %eax\r
+ .balign 4\r
+_v_clear_common:\r
+ movl 8(%esp), %ecx\r
+ movl 4(%esp), %edx\r
+ shrl $2, %ecx\r
+ 0:\r
+ .balign 4\r
+ movl %eax, (%edx)\r
+ addl $4, %edx\r
+ decl %ecx\r
+ jnz 0b\r
+ ret\r
+\r
+/*\r
+ * void v_clear24 (void *buffer, int bytes, int color);\r
+ */\r
+ .balign 4\r
+ .global _v_clear24\r
+_v_clear24:\r
+ movl 8(%esp), %edx\r
+ movl $0xaaaaaaab, %eax\r
+ mull %edx\r
+ movl 12(%esp), %eax\r
+ movl %edx, %ecx\r
+ movl 4(%esp), %edx\r
+ pushl %ebx\r
+ shrl %ecx\r
+ movb 18(%esp), %bl\r
+ .balign 4\r
+ 0:\r
+ movw %ax, (%edx)\r
+ movb %bl, 2(%edx)\r
+ addl $3, %edx\r
+ decl %ecx\r
+ jnz 0b\r
+ popl %ebx\r
+ ret\r
+\r
+/*\r
+ * void b_dump_virtual (void *buffer, int stride, int height);\r
+ */\r
+ .balign 4\r
+ .global _b_dump_virtual\r
+_b_dump_virtual:\r
+ pushl %ebx\r
+ pushl %esi\r
+ pushl %edi\r
+ pushl %ebp\r
+ movl _vl_video_selector, %fs\r
+ movl 4*4+4+0(%esp), %esi\r
+ movl _vl_hw_granularity, %ebp\r
+ xorl %edx, %edx\r
+ movl _vl_current_offset, %eax\r
+ divl %ebp\r
+ movl %edx, %edi\r
+ pushl %eax\r
+ movl %eax, %edx\r
+ xorl %ebx, %ebx\r
+ movw $0x4f05, %ax\r
+ int $0x10\r
+ movl _vl_current_delta, %ebx\r
+ movl 5*4+4+4(%esp), %ecx\r
+ movl 5*4+4+8(%esp), %edx\r
+ shrl $2, %ecx\r
+ .balign 4\r
+ 0:\r
+ pushl %ecx\r
+ .balign 4\r
+ 1:\r
+ cmpl %ebp, %edi\r
+ jb 2f\r
+ pushl %ebx\r
+ pushl %edx\r
+ incl 12(%esp)\r
+ movw $0x4f05, %ax\r
+ movl 12(%esp), %edx\r
+ xorl %ebx, %ebx\r
+ int $0x10\r
+ popl %edx\r
+ popl %ebx\r
+ subl %ebp, %edi\r
+ 2:\r
+ movl (%esi), %eax\r
+ addl $4, %esi\r
+ movl %eax, %fs:(%edi)\r
+ addl $4, %edi\r
+ decl %ecx\r
+ jnz 1b\r
+ popl %ecx\r
+ addl %ebx, %edi\r
+ decl %edx\r
+ jnz 0b\r
+ popl %eax\r
+ popl %ebp\r
+ popl %edi\r
+ popl %esi\r
+ popl %ebx\r
+ ret\r
+\r
+/*\r
+ * void l_dump_virtual (void *buffer, int stride, int height);\r
+ */\r
+ .balign 4\r
+ .global _l_dump_virtual\r
+_l_dump_virtual:\r
+ pushl %ebx\r
+ pushl %esi\r
+ pushl %edi\r
+ movl _vl_video_selector, %fs\r
+ movl 3*4+4+0(%esp), %esi\r
+ movl _vl_current_offset, %edi\r
+ movl 3*4+4+4(%esp), %ecx\r
+ movl 3*4+4+8(%esp), %edx\r
+ movl _vl_current_delta, %ebx\r
+ shrl $2, %ecx\r
+ .balign 4\r
+ 0:\r
+ pushl %ecx\r
+ .balign 4\r
+ 1:\r
+ movl (%esi), %eax\r
+ addl $4, %esi\r
+ movl %eax, %fs:(%edi)\r
+ addl $4, %edi\r
+ decl %ecx\r
+ jnz 1b\r
+ popl %ecx\r
+ addl %ebx, %edi\r
+ decl %edx\r
+ jnz 0b\r
+ popl %edi\r
+ popl %esi\r
+ popl %ebx\r
+ ret\r
+\r
+/*\r
+ * void v_putpixel16 (void *buffer, int offset, int color);\r
+ */\r
+ .balign 4\r
+ .global _v_putpixel16\r
+_v_putpixel16:\r
+ movl 8(%esp), %edx\r
+ shll %edx\r
+ movl 12(%esp), %eax\r
+ addl 4(%esp), %edx\r
+ movw %ax, (%edx)\r
+ ret\r
+\r
+/*\r
+ * void v_putpixel24 (void *buffer, int offset, int color);\r
+ */\r
+ .balign 4\r
+ .global _v_putpixel24\r
+_v_putpixel24:\r
+ movl 8(%esp), %edx\r
+ leal (%edx, %edx, 2), %edx\r
+ movl 12(%esp), %eax\r
+ addl 4(%esp), %edx\r
+ movw %ax, (%edx)\r
+ shrl $16, %eax\r
+ movb %al, 2(%edx)\r
+ ret\r
+\r
+/*\r
+ * void v_putpixel32 (void *buffer, int offset, int color);\r
+ */\r
+ .balign 4\r
+ .global _v_putpixel32\r
+_v_putpixel32:\r
+ movl 8(%esp), %edx\r
+ shll $2, %edx\r
+ movl 12(%esp), %eax\r
+ addl 4(%esp), %edx\r
+ movl %eax, (%edx)\r
+ ret\r
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
\r
-# DOS/DJGPP core makefile v1.0 for Mesa 4.0\r
+# DOS/DJGPP core makefile v1.1 for Mesa 4.0\r
#\r
# Copyright (C) 2002 - Borca Daniel\r
# Email : dborca@yahoo.com\r
# Web : http://www.geocities.com/dborca\r
\r
\r
+#\r
+# Available options:\r
+#\r
+# Environment variables:\r
+# CFLAGS\r
+#\r
+# GLIDE absolute path to Glide SDK; used with FX.\r
+# default = $(TOP)/include/glide3\r
+# FX=1 build for 3dfx Glide3; use it if you have the glide\r
+# SDK (designed for your platform), and, of course, a\r
+# 3dfx card... Note that this disables compilation of\r
+# actual DMesa code, as Glide does all the stuff!\r
+# default = no\r
+# HAVE_X86=1 optimize for i386.\r
+# default = no\r
+# HAVE_MMX=1 MMX instructions; use only if you assembler/compiler\r
+# supports MMX instruction set; backwards compatibility\r
+# with older processors is still preserved.\r
+# default = no\r
+# HAVE_SSE=1 (see HAVE_MMX)\r
+# default = no\r
+# HAVE_3DNOW=1 (see HAVE_MMX)\r
+# default = no\r
+#\r
+# Targets:\r
+# all: build GL\r
+# clean: remove object files\r
+#\r
+\r
+\r
+\r
.PHONY: all clean\r
\r
TOP = ..\r
+GLIDE ?= $(TOP)/include/glide3\r
+LIBDIR = $(TOP)/lib\r
+GL_LIB = libgl.a\r
+GL_DXE = gl.dxe\r
+GL_IMP = libigl.a\r
+\r
CC = gcc\r
-CFLAGS = -I$(TOP)/include -I. -Wall -W -Wno-unused -mcpu=$(CPU) -ffast-math -O2\r
+CFLAGS += -I$(TOP)/include -I.\r
+ifdef FX\r
+CFLAGS += -D__DOS__ -I$(GLIDE) -DFX -DFX_GLIDE3 -DFXMESA_USE_ARGB\r
+endif\r
+\r
AR = ar\r
-ARFLAGS = ruv\r
-LIBDIR = $(TOP)/lib\r
+ARFLAGS = ru\r
\r
-ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)\r
-DXE2GEN =\r
-else\r
+ifneq ($(wildcard $(DJDIR)/lib/dxe2.ld),)\r
DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))\r
endif\r
\r
-GL_LIB = libgl.a\r
-GL_DXE = gl.dxe\r
-GL_IMP = libigl.a\r
+RM = del\r
\r
CORE_SOURCES = \\r
swrast_setup/ss_context.c \\r
buffers.c \\r
clip.c \\r
colortab.c \\r
+ config.c \\r
context.c \\r
convolve.c \\r
debug.c \\r
X86/x86_vertex.S \\r
X86/x86_cliptest.S\r
\r
-MMX_SOURCES =\r
+MMX_SOURCES = \\r
+ X86/mmx_blend.S\r
\r
SSE_SOURCES = \\r
X86/sse.c \\r
X86/sse_vertex.S \\r
X86/sse_normal.S\r
\r
-D3NOW_SOURCES = \\r
+K3D_SOURCES = \\r
X86/3dnow.c \\r
X86/3dnow_xform2.S \\r
X86/3dnow_xform3.S \\r
HAVE_X86 = 1\r
endif\r
ifdef HAVE_3DNOW\r
-X86_SOURCES += $(D3NOW_SOURCES)\r
+X86_SOURCES += $(K3D_SOURCES)\r
CFLAGS += -DUSE_3DNOW_ASM\r
HAVE_X86 = 1\r
endif\r
X86_SOURCES =\r
endif\r
\r
-DRIVER_SOURCES = DOS/dmesa.c DOS/video.c DOS/dpmi.c\r
+ifndef FX\r
+DRIVER_SOURCES = \\r
+ DOS/dmesa.c \\r
+ DOS/video.c \\r
+ DOS/virtual.S \\r
+ DOS/vesa/vesa.c \\r
+ DOS/dpmi.c\r
+else\r
+DRIVER_SOURCES = \\r
+ FX/fxapi.c \\r
+ FX/fxdd.c \\r
+ FX/fxddspan.c \\r
+ FX/fxddtex.c \\r
+ FX/fxsetup.c \\r
+ FX/fxtexman.c \\r
+ FX/fxtris.c \\r
+ FX/fxvb.c \\r
+ FX/fxglidew.c\r
+endif\r
\r
SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES)\r
\r
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))\r
\r
.c.o:\r
- gcc -o $@ -c $(CFLAGS) $<\r
+ $(CC) -o $@ -c $(CFLAGS) $<\r
.S.o:\r
- gcc -o $@ -c $(CFLAGS) $<\r
+ $(CC) -o $@ -c $(CFLAGS) $<\r
+.s.o:\r
+ $(CC) -o $@ -c $(CFLAGS) -x assembler-with-cpp $<\r
\r
all: $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP)\r
\r
$(warning Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN)\r
$(warning somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.)\r
else\r
- dxe2gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) $(OBJECTS) -D "Mesa DOS GL" -U\r
+ -dxe2gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) $(OBJECTS) -E djgpp_ -E gl -E DMesa -E fxMesa -D "Mesa DJGPP GL" -U\r
endif\r
\r
clean:\r
- -$(RM) *.o\r
-ifdef HAVE_X86\r
- -$(RM) X86\*.o\r
-endif\r
- -$(RM) DOS\*.o\r
-\r
-include depend\r
+ -$(RM) $(subst /,\,*.o)\r
+ -$(RM) $(subst /,\,array_cache/*.o)\r
+ -$(RM) $(subst /,\,math/*.o)\r
+ -$(RM) $(subst /,\,swrast/*.o)\r
+ -$(RM) $(subst /,\,swrast_setup/*.o)\r
+ -$(RM) $(subst /,\,tnl/*.o)\r
+ -$(RM) $(subst /,\,X86/*.o)\r
+ -$(RM) $(subst /,\,DOS/*.o)\r
+ -$(RM) $(subst /,\,DOS/vesa/*.o)\r
+ -$(RM) $(subst /,\,FX/*.o)\r
\r
-DOS/dmesa.o: DOS/dmesa.c glheader.h ../include/GL/gl.h context.h glapi.h \\r
- mtypes.h config.h glapitable.h glthread.h math/m_matrix.h dd.h macros.h \\r
- ../include/GL/dmesa.h extensions.h matrix.h mmath.h texformat.h \\r
- texstore.h array_cache/acache.h swrast/s_context.h swrast/swrast.h \\r
- swrast/s_depth.h swrast/s_lines.h swrast/s_triangle.h swrast/s_trispan.h \\r
- swrast_setup/swrast_setup.h tnl/tnl.h tnl/t_context.h math/m_vector.h \\r
- math/m_xform.h tnl/t_pipeline.h DOS/video.h swrast/s_tritemp.h\r
-DOS/dpmi.o: DOS/dpmi.c DOS/dpmiint.h\r
-DOS/video.o: DOS/video.c DOS/video.h DOS/dpmiint.h\r
+-include depend\r