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