DOS updates for new tree (Daniel Borca)

This commit is contained in:
Brian Paul 2003-06-16 14:32:44 +00:00
parent 710207c46f
commit 642699a19f
44 changed files with 11794 additions and 11606 deletions

108
Makefile.DJ Normal file
View file

@ -0,0 +1,108 @@
# 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 makefile v1.4 for Mesa
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
#
# Available options:
#
# Environment variables:
# CPU optimize for the given processor.
# default = k6
# GLU=[mesa|sgi] specify GLU directory; can be `sgi' (requires GNU/C++)
# or `mesa'.
# default = mesa
# GLIDE path to Glide3 SDK include files; used with FX.
# default = $(TOP)/include/glide3
# FX=1 build for 3dfx Glide3. Note that this disables
# compilation of most DMesa code and requires fxMesa.
# As a consequence, you'll need the DJGPP Glide3
# library to build any application.
# default = no
# MATROX=1 build for Matrox Millennium I (MGA2064W) cards.
# This is experimental and not intensively tested.
# default = no
# HAVE_X86=1 optimize for i386.
# default = no
# HAVE_MMX=1 allow MMX specializations, provided your assembler
# supports MMX instruction set. However, the true CPU
# capabilities are checked at run-time to avoid crashes.
# 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
#
.PHONY : all libgl libglu libglut clean realclean
CPU ?= k6
GLU ?= mesa
CFLAGS = -Wall -W -pedantic
CFLAGS += -O2 -ffast-math -mcpu=$(CPU)
export CFLAGS
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
all: libgl libglu libglut
libgl: lib
$(MAKE) -f Makefile.DJ -C src/mesa
libglu: lib
$(MAKE) -f Makefile.DJ -C src/glu/$(GLU)
libglut: lib
$(MAKE) -f Makefile.DJ -C src/glut/dos
lib:
mkdir lib
clean:
$(MAKE) -f Makefile.DJ clean -C src/mesa
$(MAKE) -f Makefile.DJ clean -C src/glu/mesa
$(MAKE) -f Makefile.DJ clean -C src/glu/sgi
$(MAKE) -f Makefile.DJ clean -C src/glut/dos
realclean: clean
-$(call UNLINK,lib/*.a)
-$(call UNLINK,lib/*.dxe)

View file

@ -1,225 +1,226 @@
Mesa 5.0.1 DOS/DJGPP Port v1.3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Description:
~~~~~~~~~~~~
Well, guess what... this is the DOS port of Mesa 5.0.1, 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, provided this package is used within Mesa. For anything
else, see GPL.
Installation:
~~~~~~~~~~~~~
Unzip and type:
make -f Makefile.DJ [OPTIONS...]
Available options:
Environment variables:
CPU optimize for the given processor.
default = k6
GLU=[src|si] specify GLU directory; can be `src' (src-glu = Mesa)
or `si' (si-glu = SGI's GLU -- requires GNU/C++).
default = src
GLIDE path to Glide3 SDK include files; used with FX.
default = $(TOP)/include/glide3
FX=1 build for 3dfx Glide3. Note that this disables
compilation of most DMesa code and requires fxMesa.
As a consequence, you'll need the DJGPP Glide3
library to build any application.
default = no
MATROX=1 build for Matrox Millennium I (MGA2064W) cards.
This is experimental and not intensively tested.
default = no
HAVE_X86=1 optimize for i386.
default = no
HAVE_MMX=1 allow MMX specializations, provided your assembler
supports MMX instruction set. However, the true CPU
capabilities are checked at run-time to avoid crashes.
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: K6-2 (CXT) @500(412.5) MHz
Mainboard: ViA Apollo VP2/97 w/ 128 MB SDRAM
Video card: PowerColor EvilKing3 (Voodoo3 3000 PCI) w/ 16 MB SDRAM
DJGPP: djdev 2.04 + gcc v3.2.2 + make v3.79.1
OS: DOS and Win9x
FAQ:
~~~~
1. Compilation
Q) I tried to run `make' and it exits because `gcc' complains it cannot find
some stupid file.
A) You need LFN support.
A) When compiling for Glide (FX=1), pay attention to Glide path.
Q) Libraries built OK, but linker complains about `vsnprintf' every time I
compile some demo.
A) Upgrade to DJGPP 2.04.
A) Add `vsnprintf.c' to the CORE_SOURCES in `src/Makefile.DJ' (untested!).
A) The following hack should be safe in 90% of the cases, but if anything
goes wrong, don't come back to me crying. Anyway, patch `src/imports.c'
with the following line:
#define vsnprintf(buf, max, fmt, arg) vsprintf(buf, fmt, arg)
Q) `make' complains about DXE3 or something, yet it builds the libraries.
A) DXE3 refers to the DJGPP dynamic modules. You'll need either the latest
DJGPP distro, or download the separate package from my web page. Read the
DXE3 documentation on how to use them. Hint: build your export object
file; then link it with your application. For example:
dxe3res -o dxe3tbl.c gl.dxe glu.dxe glut.dxe
gcc -o dxe3tbl.o -c dxe3tbl.c
gcc -o OUT.exe dxe3tbl.o IN.c -liglut -liglu -ligl -ldl
2. Using Mesa for DJGPP
Q) DMesa 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 have a Matrox Millennium I card,
you just MIGHT be lucky... If you haven't, sorry; everything is done in
software. Suggestions?
Q) I tried to set refresh rate w/ DMesa, but without success.
A) Refresh rate control works only for VESA 3.0. If you were compiling for
Glide, see Glide info. If not, sorry!
Q) I made a simple application and it does nothing. It exits right away. Not
even a blank screen.
A) The pure software drivers (VESA/VGA) support only double-buffered modes.
A) Another weird "feature" is that buffer width must be multiple of 8 (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 GLUT is incomplete.
A) See below.
libGLUT (the toolkit):
~~~~~~~~~~~~~~~~~~~~~~
Well, this "skeletal" GLUT implementation was taken from AllegGL project and
heavily changed. Thanks should go to Bernhard Tschirren, Mark Kilgard, Brian
Paul and probably others (or probably not ;-). GLUT functionality will be
extended only on an "as needed" basis.
GLUT talks to hardware via PC_HW package which was put together from various
pieces I wrote long time ago. It consists from the keyboard, mouse and timer
drivers.
My keyboard driver used only scancodes; as GLUT requires ASCII values for keys,
I borrowed the translation tables (and maybe more) from Allegro -- many thanks
to Shawn Hargreaves et co. Ctrl-Alt-Del (plus Ctrl-Alt-End, for Windows users)
will shut down the GLUT engine unconditionally: it will raise SIGINT, which in
turn will (hopefully) call the destructors, thus cleaning up your/my mess ;-)
NB: since the DJGPP guys ensured signal handlers won't go beyond program's
space (and since dynamic modules shall) the SIGINT can't be hooked (well, it
can, but it is useless), therefore you must live with the 'Exiting due to
signal SIGINT' message...
The mouse driver is far from complete (lack of drawing, etc), but is enough to
make almost all the demos work. Supports the CuteMouse WheelAPI.
The timer is pretty versatile for it supports multiple timers with different
frequencies. While not being the most accurate timer in the known universe, I
think it's OK. Take this example: you have timer A with a very high rate, and
then you have timer B with very low rate compared to A; now, A ticks OK, but
timer B will probably loose precision!
As an addition, stdout and stderr are redirected and dumped upon exit. This
means that `printf' can be safely called during graphics. A bit of a hack, I
know, because all messages come in bulk, but I think it's better than nothing.
"Borrowed" from LIBRHUTI (Robert Hoehne).
Window creating defaults: 300x300x16 at (0,0), 16-bit depth, 16-bit accum,
8-bit stencil. However, the video mode is chosen in such a way that first
window will fit. If you need high resolution with small windows, set initial
position far to the right (or way down); then you can move them back to any
position right before the main loop.
The following environment variables can customize GLUT behaviour:
DMESA_GLUT_REFRESH - set vertical screen refresh rate (VESA3)
DMESA_GLUT_BPP - set default bits per pixel (VGA needs 8)
GLUT_FPS - print frames/second statistics to stderr
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
v1.2 (nov-2002)
* synced w/ Mesa-4.1
- removed dmesadxe.h
v1.3 (mar-2003)
+ enabled OpenGL 1.4 support
+ added MMX clear/blit routines
+ enabled SGI's GLU compilation
+ added samples makefile
+ added new GLUT functions
+ added color-index modes
+ added Matrox Millennium MGA2064W driver
+ added 8bit FakeColor (thanks to Neil Funk)
+ added VGA support (to keep Ben Decker happy)
! fixed some compilation errors (reported by Chan Kar Heng)
* optimized driver for faster callback access... yeah, right :)
* overhauled virtual buffer and internal video drivers
* better fxMesa integration
* revamped GLUT
* switched to DXE3
Contact:
~~~~~~~~
Name: Borca Daniel
E-mail: dborca@yahoo.com
WWW: http://www.geocities.com/dborca/
Mesa 5.0.1 DOS/DJGPP Port v1.4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Description:
~~~~~~~~~~~~
Well, guess what... this is the DOS port of Mesa 5.0.1, 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, provided this package is used within Mesa. For anything
else, see GPL.
Installation:
~~~~~~~~~~~~~
Unzip and type:
make -f Makefile.DJ [OPTIONS...]
Available options:
Environment variables:
CPU optimize for the given processor.
default = k6
GLU=[mesa|sgi] specify GLU directory; can be `sgi' (requires GNU/C++)
or `mesa'.
default = mesa
GLIDE path to Glide3 SDK include files; used with FX.
default = $(TOP)/include/glide3
FX=1 build for 3dfx Glide3. Note that this disables
compilation of most DMesa code and requires fxMesa.
As a consequence, you'll need the DJGPP Glide3
library to build any application.
default = no
MATROX=1 build for Matrox Millennium I (MGA2064W) cards.
This is experimental and not intensively tested.
default = no
HAVE_X86=1 optimize for i386.
default = no
HAVE_MMX=1 allow MMX specializations, provided your assembler
supports MMX instruction set. However, the true CPU
capabilities are checked at run-time to avoid crashes.
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: AMD Duron @800 MHz
Mainboard: EP-8KTA3 w/ 128 MB SDRAM
Video card: Voodoo5 5500 AGP w/ 64 MB SDRAM
DJGPP: djdev 2.04 + gcc v3.2.2 + make v3.79.1
OS: DOS and Win98SE
FAQ:
~~~~
1. Compilation
Q) I tried to run `make' and it exits because `gcc' complains it cannot find
some stupid file.
A) You need LFN support.
A) When compiling for Glide (FX=1), pay attention to Glide path.
Q) Libraries built OK, but linker complains about `vsnprintf' every time I
compile some demo.
A) Upgrade to DJGPP 2.04.
A) Add `vsnprintf.c' to the CORE_SOURCES in `src/Makefile.DJ' (untested!).
A) The following hack should be safe in 90% of the cases, but if anything
goes wrong, don't come back to me crying. Anyway, patch `src/imports.c'
with the following line:
#define vsnprintf(buf, max, fmt, arg) vsprintf(buf, fmt, arg)
Q) `make' complains about DXE3 or something, yet it builds the libraries.
A) DXE3 refers to the DJGPP dynamic modules. You'll need either the latest
DJGPP distro, or download the separate package from my web page. Read the
DXE3 documentation on how to use them.
A) When compiling for Glide (FX=1), make sure `glid3.dxe' can be found in
LD_LIBRARY_PATH (or top `lib' directory).
2. Using Mesa for DJGPP
Q) DMesa is so SLOOOW! The Win32 OpenGL performs so much better...
A) Is that a question? If you have a 3dfx Voodoo Banshee or higher card,
you're lucky (check http://sourceforge.net/projects/glide for the DJGPP
port). If you have a Matrox Millennium I card, you just MIGHT be lucky...
If you haven't, sorry; everything is done in software. Suggestions?
Q) I tried to set refresh rate w/ DMesa, but without success.
A) Refresh rate control works only for VESA 3.0. If you were compiling for
Glide, see Glide info. If not, sorry!
Q) I made a simple application and it does nothing. It exits right away. Not
even a blank screen.
A) The pure software drivers (VESA/VGA) support only double-buffered modes.
A) Another weird "feature" is that buffer width must be multiple of 8 (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 GLUT is incomplete.
A) See below.
libGLUT (the toolkit):
~~~~~~~~~~~~~~~~~~~~~~
Well, this "skeletal" GLUT implementation was taken from AllegGL project and
heavily changed. Thanks should go to Bernhard Tschirren, Mark Kilgard, Brian
Paul and probably others (or probably not ;-). GLUT functionality will be
extended only on an "as needed" basis.
GLUT talks to hardware via PC_HW package which was put together from various
pieces I wrote long time ago. It consists from the keyboard, mouse and timer
drivers.
My keyboard driver used only scancodes; as GLUT requires ASCII values for keys,
I borrowed the translation tables (and maybe more) from Allegro -- many thanks
to Shawn Hargreaves et co. Ctrl-Alt-Del (plus Ctrl-Alt-End, for Windows users)
will shut down the GLUT engine unconditionally: it will raise SIGINT, which in
turn will (hopefully) call the destructors, thus cleaning up your/my mess ;-)
NB: since the DJGPP guys ensured signal handlers won't go beyond program's
space (and since dynamic modules shall) the SIGINT can't be hooked (well, it
can, but it is useless), therefore you must live with the 'Exiting due to
signal SIGINT' message...
The mouse driver is far from complete (lack of drawing, etc), but is enough to
make almost all the demos work. Supports the CuteMouse WheelAPI.
The timer is pretty versatile for it supports multiple timers with different
frequencies. While not being the most accurate timer in the known universe, I
think it's OK. Take this example: you have timer A with a very high rate, and
then you have timer B with very low rate compared to A; now, A ticks OK, but
timer B will probably loose precision!
As an addition, stdout and stderr are redirected and dumped upon exit. This
means that `printf' can be safely called during graphics. A bit of a hack, I
know, because all messages come in bulk, but I think it's better than nothing.
"Borrowed" from LIBRHUTI (Robert Hoehne).
Window creating defaults: 300x300x16 at (0,0), 16-bit depth, 16-bit accum,
8-bit stencil. However, the video mode is chosen in such a way that first
window will fit. If you need high resolution with small windows, set initial
position far to the right (or way down); then you can move them back to any
position right before the main loop.
The following environment variables can customize GLUT behaviour:
DMESA_GLUT_REFRESH - set vertical screen refresh rate (VESA3)
DMESA_GLUT_BPP - set default bits per pixel (VGA needs 8)
GLUT_FPS - print frames/second statistics to stderr
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
v1.2 (nov-2002)
* synced w/ Mesa-4.1
- removed dmesadxe.h
v1.3 (mar-2003)
+ enabled OpenGL 1.4 support
+ added MMX clear/blit routines
+ enabled SGI's GLU compilation
+ added samples makefile
+ added new GLUT functions
+ added color-index modes
+ added Matrox Millennium MGA2064W driver
+ added 8bit FakeColor (thanks to Neil Funk)
+ added VGA support (to keep Ben Decker happy)
! fixed some compilation errors (reported by Chan Kar Heng)
* optimized driver for faster callback access... yeah, right :)
* overhauled virtual buffer and internal video drivers
* better fxMesa integration
* revamped GLUT
* switched to DXE3
v1.4 (jun-2003)
* accomodated makefiles with the new sourcetree
Contact:
~~~~~~~~
Name: Borca Daniel
E-mail: dborca@yahoo.com
WWW: http://www.geocities.com/dborca/

View file

@ -1,147 +1,147 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef DMESA_H_included
#define DMESA_H_included
#define DMESA_MAJOR_VERSION 5
#define DMESA_MINOR_VERSION 0
/* Sample Usage:
*
* 1. Call DMesaCreateVisual() to initialize graphics.
* 2. Call DMesaCreateContext() to create a DMesa rendering context.
* 3. Call DMesaCreateBuffer() to define the window.
* 4. Call DMesaMakeCurrent() to bind the DMesaBuffer to a DMesaContext.
* 5. Make gl* calls to render your graphics.
* 6. Use DMesaSwapBuffers() when double buffering to swap front/back buffers.
* 7. Before exiting, destroy DMesaBuffer, DMesaContext and DMesaVisual.
*/
typedef struct dmesa_context *DMesaContext;
typedef struct dmesa_visual *DMesaVisual;
typedef struct dmesa_buffer *DMesaBuffer;
#ifdef __cplusplus
extern "C" {
#endif
/*
* Create a new Visual and set graphics mode.
*/
DMesaVisual DMesaCreateVisual (GLint width, /* X res */
GLint height, /* Y res */
GLint colDepth, /* BPP */
GLint refresh, /* refresh rate: 0=default */
GLboolean dbFlag, /* double-buffered */
GLboolean rgbFlag, /* RGB mode */
GLboolean alphaFlag,/* alpha buffer requested */
GLint depthSize, /* requested bits/depth */
GLint stencilSize, /* requested bits/stencil */
GLint accumSize); /* requested bits/accum */
/*
* Destroy Visual and restore screen.
*/
void DMesaDestroyVisual (DMesaVisual v);
/*
* Create a new Context for rendering.
*/
DMesaContext DMesaCreateContext (DMesaVisual visual, DMesaContext share);
/*
* Destroy Context.
*/
void DMesaDestroyContext (DMesaContext c);
/*
* Return a handle to the current context.
*/
DMesaContext DMesaGetCurrentContext (void);
/*
* Create a new Buffer (window).
*/
DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
GLint xpos, GLint ypos,
GLint width, GLint height);
/*
* Destroy Buffer.
*/
void DMesaDestroyBuffer (DMesaBuffer b);
/*
* Swap the front and back buffers for the given Buffer.
* No action is taken if the buffer is not double buffered.
*/
void DMesaSwapBuffers (DMesaBuffer b);
/*
* Bind Buffer to Context and make the Context the current one.
*/
GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b);
/*
* Move/Resize current Buffer.
*/
GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos);
GLboolean DMesaResizeBuffer (GLint width, GLint height);
/*
* Set palette index, using normalized values.
*/
void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue);
/*
* DMesa state retrieval.
*/
#define DMESA_GET_SCREEN_SIZE 0x0100
#define DMESA_GET_DRIVER_CAPS 0x0200
#define DMESA_DRIVER_SWDB_BIT 0x1 /* software double-buffered */
#define DMESA_DRIVER_LLWO_BIT 0x2 /* lower-left window origin */
int DMesaGetIntegerv (GLenum pname, GLint *params);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef DMESA_H_included
#define DMESA_H_included
#define DMESA_MAJOR_VERSION 5
#define DMESA_MINOR_VERSION 0
/* Sample Usage:
*
* 1. Call DMesaCreateVisual() to initialize graphics.
* 2. Call DMesaCreateContext() to create a DMesa rendering context.
* 3. Call DMesaCreateBuffer() to define the window.
* 4. Call DMesaMakeCurrent() to bind the DMesaBuffer to a DMesaContext.
* 5. Make gl* calls to render your graphics.
* 6. Use DMesaSwapBuffers() when double buffering to swap front/back buffers.
* 7. Before exiting, destroy DMesaBuffer, DMesaContext and DMesaVisual.
*/
typedef struct dmesa_context *DMesaContext;
typedef struct dmesa_visual *DMesaVisual;
typedef struct dmesa_buffer *DMesaBuffer;
#ifdef __cplusplus
extern "C" {
#endif
/*
* Create a new Visual and set graphics mode.
*/
DMesaVisual DMesaCreateVisual (GLint width, /* X res */
GLint height, /* Y res */
GLint colDepth, /* BPP */
GLint refresh, /* refresh rate: 0=default */
GLboolean dbFlag, /* double-buffered */
GLboolean rgbFlag, /* RGB mode */
GLboolean alphaFlag,/* alpha buffer requested */
GLint depthSize, /* requested bits/depth */
GLint stencilSize, /* requested bits/stencil */
GLint accumSize); /* requested bits/accum */
/*
* Destroy Visual and restore screen.
*/
void DMesaDestroyVisual (DMesaVisual v);
/*
* Create a new Context for rendering.
*/
DMesaContext DMesaCreateContext (DMesaVisual visual, DMesaContext share);
/*
* Destroy Context.
*/
void DMesaDestroyContext (DMesaContext c);
/*
* Return a handle to the current context.
*/
DMesaContext DMesaGetCurrentContext (void);
/*
* Create a new Buffer (window).
*/
DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
GLint xpos, GLint ypos,
GLint width, GLint height);
/*
* Destroy Buffer.
*/
void DMesaDestroyBuffer (DMesaBuffer b);
/*
* Swap the front and back buffers for the given Buffer.
* No action is taken if the buffer is not double buffered.
*/
void DMesaSwapBuffers (DMesaBuffer b);
/*
* Bind Buffer to Context and make the Context the current one.
*/
GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b);
/*
* Move/Resize current Buffer.
*/
GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos);
GLboolean DMesaResizeBuffer (GLint width, GLint height);
/*
* Set palette index, using normalized values.
*/
void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue);
/*
* DMesa state retrieval.
*/
#define DMESA_GET_SCREEN_SIZE 0x0100
#define DMESA_GET_DRIVER_CAPS 0x0200
#define DMESA_DRIVER_SWDB_BIT 0x1 /* software double-buffered */
#define DMESA_DRIVER_LLWO_BIT 0x2 /* lower-left window origin */
int DMesaGetIntegerv (GLenum pname, GLint *params);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,86 +1,83 @@
# 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 samples makefile v1.3 for Mesa
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
#
# Available options:
#
# Environment variables:
# CPU optimize for the given processor.
# default = k6
# GLIDE path to Glide3 SDK library files; used with FX.
# default = $(TOP)/lib/glide3
# FX=1 build for 3dfx Glide3. Note that this disables
# compilation of most DMesa code and requires fxMesa.
# As a consequence, you'll need the DJGPP Glide3
# library to build any application.
# default = no
# DXE=1 use DXE modules. The resolution object file must be
# present in the `lib' directory in order to use this
# option (see README.DJ for details).
# default = no
#
# Targets:
# <file.exe> build a specific file
#
.PHONY : all
.SUFFIXES : .c .o .exe
TOP = ..
CPU ?= k6
GLIDE ?= $(TOP)/lib/glide3
CC = gcc
CFLAGS = -Wall -W -pedantic
CFLAGS += -O2 -ffast-math -mcpu=$(CPU)
CFLAGS += -I$(TOP)/include
LD = gxx
LDFLAGS = -s -L$(TOP)/lib
ifeq ($(DXE),1)
DXE3TABLE = $(TOP)/lib/dxe3tbl.o
LDLIBS += -liglut -liglu -ligl -ldl
else
LDLIBS = -lglut -lglu -lgl
ifeq ($(FX),1)
LDFLAGS += -L$(GLIDE)
LDLIBS += -lglid3
endif
endif
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.o.exe:
$(LD) -o $@ $(LDFLAGS) $(DXE3TABLE) $< $(LDLIBS)
all:
$(error Must specify <filename.exe> to build)
# 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 samples makefile v1.4 for Mesa
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
#
# Available options:
#
# Environment variables:
# CPU optimize for the given processor.
# default = k6
# GLIDE path to Glide3 SDK library files; used with FX.
# default = $(TOP)/lib/glide3
# FX=1 build for 3dfx Glide3. Note that this disables
# compilation of most DMesa code and requires fxMesa.
# As a consequence, you'll need the DJGPP Glide3
# library to build any application.
# default = no
# DXE=1 use DXE modules (see README.DJ for details).
# default = no
#
# Targets:
# <file.exe> build a specific file
#
.PHONY : all
.SUFFIXES : .c .o .exe
TOP = ../..
CPU ?= k6
GLIDE ?= $(TOP)/lib/glide3
CC = gcc
CFLAGS = -Wall -W -pedantic
CFLAGS += -O2 -ffast-math -mcpu=$(CPU)
CFLAGS += -I$(TOP)/include -I../util
LD = gxx
LDFLAGS = -s -L$(TOP)/lib
ifeq ($(DXE),1)
LDLIBS += -liglut -liglu -ligl
else
LDLIBS = -lglut -lglu -lgl
ifeq ($(FX),1)
LDFLAGS += -L$(GLIDE)
LDLIBS += -lglid3
endif
endif
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.o.exe:
$(LD) -o $@ $(LDFLAGS) $< $(LDLIBS)
all:
$(error Must specify <filename.exe> to build)

View file

@ -1,100 +1,102 @@
# 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 glu makefile v1.3 for Mesa
#
# 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
AR = ar
ARFLAGS = rus
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
CORE_SOURCES = \
glu.c \
mipmap.c \
nurbs.c \
nurbscrv.c \
nurbssrf.c \
nurbsutl.c \
polytest.c \
project.c \
quadric.c \
tess.c \
tesselat.c
SOURCES = $(CORE_SOURCES)
OBJECTS = $(SOURCES:.c=.o)
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
all: $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP)
$(LIBDIR)/$(GLU_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLU_LIB) $(OBJECTS)
$(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GLU_DXE))
else
-dxe3gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU DJGPP" -E _glu -P gl.dxe -U $(OBJECTS)
endif
clean:
-$(call UNLINK,*.o)
-include depend
# 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 glu makefile v1.4 for Mesa
#
# 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
export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR)
CC = gcc
CFLAGS += -I$(TOP)/include
AR = ar
ARFLAGS = rus
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
CORE_SOURCES = \
glu.c \
mipmap.c \
nurbs.c \
nurbscrv.c \
nurbssrf.c \
nurbsutl.c \
polytest.c \
project.c \
quadric.c \
tess.c \
tesselat.c
SOURCES = $(CORE_SOURCES)
OBJECTS = $(SOURCES:.c=.o)
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
all: $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP)
$(LIBDIR)/$(GLU_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLU_LIB) $(OBJECTS)
$(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GLU_DXE))
else
-dxe3gen -o $(LIBDIR)/$(GLU_DXE) -Y $(LIBDIR)/$(GLU_IMP) -D "MesaGLU DJGPP" -E _glu -P gl.dxe -U $(OBJECTS)
endif
clean:
-$(call UNLINK,*.o)
-include depend

View file

@ -1,188 +1,190 @@
# 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 glu makefile v1.3 for Mesa
#
# 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 += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude
CXX = gpp
CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess
AR = ar
ARFLAGS = rus
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
C_SOURCES = \
libutil/error.c \
libutil/glue.c \
libutil/mipmap.c \
libutil/project.c \
libutil/quad.c \
libutil/registry.c \
libtess/dict.c \
libtess/geom.c \
libtess/memalloc.c \
libtess/mesh.c \
libtess/normal.c \
libtess/priorityq.c \
libtess/render.c \
libtess/sweep.c \
libtess/tess.c \
libtess/tessmono.c
CC_SOURCES = \
libnurbs/interface/bezierEval.cc \
libnurbs/interface/bezierPatch.cc \
libnurbs/interface/bezierPatchMesh.cc \
libnurbs/interface/glcurveval.cc \
libnurbs/interface/glinterface.cc \
libnurbs/interface/glrenderer.cc \
libnurbs/interface/glsurfeval.cc \
libnurbs/interface/incurveeval.cc \
libnurbs/interface/insurfeval.cc \
libnurbs/internals/arc.cc \
libnurbs/internals/arcsorter.cc \
libnurbs/internals/arctess.cc \
libnurbs/internals/backend.cc \
libnurbs/internals/basiccrveval.cc \
libnurbs/internals/basicsurfeval.cc \
libnurbs/internals/bin.cc \
libnurbs/internals/bufpool.cc \
libnurbs/internals/cachingeval.cc \
libnurbs/internals/ccw.cc \
libnurbs/internals/coveandtiler.cc \
libnurbs/internals/curve.cc \
libnurbs/internals/curvelist.cc \
libnurbs/internals/curvesub.cc \
libnurbs/internals/dataTransform.cc \
libnurbs/internals/displaylist.cc \
libnurbs/internals/flist.cc \
libnurbs/internals/flistsorter.cc \
libnurbs/internals/hull.cc \
libnurbs/internals/intersect.cc \
libnurbs/internals/knotvector.cc \
libnurbs/internals/mapdesc.cc \
libnurbs/internals/mapdescv.cc \
libnurbs/internals/maplist.cc \
libnurbs/internals/mesher.cc \
libnurbs/internals/monoTriangulationBackend.cc \
libnurbs/internals/monotonizer.cc \
libnurbs/internals/mycode.cc \
libnurbs/internals/nurbsinterfac.cc \
libnurbs/internals/nurbstess.cc \
libnurbs/internals/patch.cc \
libnurbs/internals/patchlist.cc \
libnurbs/internals/quilt.cc \
libnurbs/internals/reader.cc \
libnurbs/internals/renderhints.cc \
libnurbs/internals/slicer.cc \
libnurbs/internals/sorter.cc \
libnurbs/internals/splitarcs.cc \
libnurbs/internals/subdivider.cc \
libnurbs/internals/tobezier.cc \
libnurbs/internals/trimline.cc \
libnurbs/internals/trimregion.cc \
libnurbs/internals/trimvertpool.cc \
libnurbs/internals/uarray.cc \
libnurbs/internals/varray.cc \
libnurbs/nurbtess/directedLine.cc \
libnurbs/nurbtess/gridWrap.cc \
libnurbs/nurbtess/monoChain.cc \
libnurbs/nurbtess/monoPolyPart.cc \
libnurbs/nurbtess/monoTriangulation.cc \
libnurbs/nurbtess/partitionX.cc \
libnurbs/nurbtess/partitionY.cc \
libnurbs/nurbtess/polyDBG.cc \
libnurbs/nurbtess/polyUtil.cc \
libnurbs/nurbtess/primitiveStream.cc \
libnurbs/nurbtess/quicksort.cc \
libnurbs/nurbtess/rectBlock.cc \
libnurbs/nurbtess/sampleComp.cc \
libnurbs/nurbtess/sampleCompBot.cc \
libnurbs/nurbtess/sampleCompRight.cc \
libnurbs/nurbtess/sampleCompTop.cc \
libnurbs/nurbtess/sampleMonoPoly.cc \
libnurbs/nurbtess/sampledLine.cc \
libnurbs/nurbtess/searchTree.cc
SOURCES = $(C_SOURCES) $(CC_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.cc.o:
$(CXX) -o $@ $(CXXFLAGS) -c $<
all: $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP)
$(LIBDIR)/$(GLU_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLU_LIB) $(OBJECTS)
$(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GLU_DXE))
else
-dxe3gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU/SGI DJGPP" -E _glu -P gl.dxe -U $(OBJECTS)
endif
clean:
-$(call UNLINK,libutil/*.o)
-$(call UNLINK,libtess/*.o)
-$(call UNLINK,libnurbs/interface/*.o)
-$(call UNLINK,libnurbs/internals/*.o)
-$(call UNLINK,libnurbs/nurbtess/*.o)
-include depend
# 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 glu makefile v1.4 for Mesa
#
# 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
export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR)
CC = gcc
CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude
CXX = gpp
CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess
AR = ar
ARFLAGS = rus
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
C_SOURCES = \
libutil/error.c \
libutil/glue.c \
libutil/mipmap.c \
libutil/project.c \
libutil/quad.c \
libutil/registry.c \
libtess/dict.c \
libtess/geom.c \
libtess/memalloc.c \
libtess/mesh.c \
libtess/normal.c \
libtess/priorityq.c \
libtess/render.c \
libtess/sweep.c \
libtess/tess.c \
libtess/tessmono.c
CC_SOURCES = \
libnurbs/interface/bezierEval.cc \
libnurbs/interface/bezierPatch.cc \
libnurbs/interface/bezierPatchMesh.cc \
libnurbs/interface/glcurveval.cc \
libnurbs/interface/glinterface.cc \
libnurbs/interface/glrenderer.cc \
libnurbs/interface/glsurfeval.cc \
libnurbs/interface/incurveeval.cc \
libnurbs/interface/insurfeval.cc \
libnurbs/internals/arc.cc \
libnurbs/internals/arcsorter.cc \
libnurbs/internals/arctess.cc \
libnurbs/internals/backend.cc \
libnurbs/internals/basiccrveval.cc \
libnurbs/internals/basicsurfeval.cc \
libnurbs/internals/bin.cc \
libnurbs/internals/bufpool.cc \
libnurbs/internals/cachingeval.cc \
libnurbs/internals/ccw.cc \
libnurbs/internals/coveandtiler.cc \
libnurbs/internals/curve.cc \
libnurbs/internals/curvelist.cc \
libnurbs/internals/curvesub.cc \
libnurbs/internals/dataTransform.cc \
libnurbs/internals/displaylist.cc \
libnurbs/internals/flist.cc \
libnurbs/internals/flistsorter.cc \
libnurbs/internals/hull.cc \
libnurbs/internals/intersect.cc \
libnurbs/internals/knotvector.cc \
libnurbs/internals/mapdesc.cc \
libnurbs/internals/mapdescv.cc \
libnurbs/internals/maplist.cc \
libnurbs/internals/mesher.cc \
libnurbs/internals/monoTriangulationBackend.cc \
libnurbs/internals/monotonizer.cc \
libnurbs/internals/mycode.cc \
libnurbs/internals/nurbsinterfac.cc \
libnurbs/internals/nurbstess.cc \
libnurbs/internals/patch.cc \
libnurbs/internals/patchlist.cc \
libnurbs/internals/quilt.cc \
libnurbs/internals/reader.cc \
libnurbs/internals/renderhints.cc \
libnurbs/internals/slicer.cc \
libnurbs/internals/sorter.cc \
libnurbs/internals/splitarcs.cc \
libnurbs/internals/subdivider.cc \
libnurbs/internals/tobezier.cc \
libnurbs/internals/trimline.cc \
libnurbs/internals/trimregion.cc \
libnurbs/internals/trimvertpool.cc \
libnurbs/internals/uarray.cc \
libnurbs/internals/varray.cc \
libnurbs/nurbtess/directedLine.cc \
libnurbs/nurbtess/gridWrap.cc \
libnurbs/nurbtess/monoChain.cc \
libnurbs/nurbtess/monoPolyPart.cc \
libnurbs/nurbtess/monoTriangulation.cc \
libnurbs/nurbtess/partitionX.cc \
libnurbs/nurbtess/partitionY.cc \
libnurbs/nurbtess/polyDBG.cc \
libnurbs/nurbtess/polyUtil.cc \
libnurbs/nurbtess/primitiveStream.cc \
libnurbs/nurbtess/quicksort.cc \
libnurbs/nurbtess/rectBlock.cc \
libnurbs/nurbtess/sampleComp.cc \
libnurbs/nurbtess/sampleCompBot.cc \
libnurbs/nurbtess/sampleCompRight.cc \
libnurbs/nurbtess/sampleCompTop.cc \
libnurbs/nurbtess/sampleMonoPoly.cc \
libnurbs/nurbtess/sampledLine.cc \
libnurbs/nurbtess/searchTree.cc
SOURCES = $(C_SOURCES) $(CC_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.cc.o:
$(CXX) -o $@ $(CXXFLAGS) -c $<
all: $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP)
$(LIBDIR)/$(GLU_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLU_LIB) $(OBJECTS)
$(LIBDIR)/$(GLU_DXE) $(LIBDIR)/$(GLU_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GLU_DXE))
else
-dxe3gen -o $(LIBDIR)/$(GLU_DXE) -Y $(LIBDIR)/$(GLU_IMP) -D "MesaGLU/SGI DJGPP" -E _glu -P gl.dxe -U $(OBJECTS)
endif
clean:
-$(call UNLINK,libutil/*.o)
-$(call UNLINK,libtess/*.o)
-$(call UNLINK,libnurbs/interface/*.o)
-$(call UNLINK,libnurbs/internals/*.o)
-$(call UNLINK,libnurbs/nurbtess/*.o)
-include depend

View file

@ -1,134 +1,136 @@
# 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 glut makefile v1.3 for Mesa
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
#
# Available options:
#
# Environment variables:
# CFLAGS
#
# MKGLUT 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
MKGLUT ?= $(TOP)/src-glut
LIBDIR = $(TOP)/lib
GLUT_LIB = libglut.a
GLUT_DXE = glut.dxe
GLUT_IMP = libiglut.a
CC = gcc
CFLAGS += -I- -I$(TOP)/include -I. -I$(MKGLUT) -IPC_HW
AR = ar
ARFLAGS = rus
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
CORE_SOURCES = \
callback.c \
color.c \
extens.c \
init.c \
menu.c \
mouse.c \
overlay.c \
state.c \
window.c
PC_HW_SOURCES = \
PC_HW/pc_hw.c \
PC_HW/pc_keyb.c \
PC_HW/pc_mouse.c \
PC_HW/pc_timer.c \
PC_HW/pc_irq.S
MKGLUT_SOURCES = \
$(MKGLUT)/glut_bitmap.c \
$(MKGLUT)/glut_bwidth.c \
$(MKGLUT)/glut_stroke.c \
$(MKGLUT)/glut_swidth.c \
$(MKGLUT)/glut_shapes.c \
$(MKGLUT)/glut_teapot.c \
$(MKGLUT)/glut_8x13.c \
$(MKGLUT)/glut_9x15.c \
$(MKGLUT)/glut_hel10.c \
$(MKGLUT)/glut_hel12.c \
$(MKGLUT)/glut_hel18.c \
$(MKGLUT)/glut_tr10.c \
$(MKGLUT)/glut_tr24.c \
$(MKGLUT)/glut_roman.c \
$(MKGLUT)/glut_mroman.c \
$(MKGLUT)/glut_util.c
SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES) $(MKGLUT_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.S.o:
$(CC) -o $@ $(CFLAGS) -c $<
.s.o:
$(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP)
$(LIBDIR)/$(GLUT_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS)
$(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GLUT_DXE))
else
-dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E _glut -P gl.dxe -P glu.dxe -U $(OBJECTS)
endif
clean:
-$(call UNLINK,*.o)
-$(call UNLINK,PC_HW/*.o)
-$(call UNLINK,$(MKGLUT)/*.o)
-include depend
# 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 glut makefile v1.4 for Mesa
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
#
# Available options:
#
# Environment variables:
# CFLAGS
#
# MKGLUT 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
MKGLUT ?= $(TOP)/src/glut/glx
LIBDIR = $(TOP)/lib
GLUT_LIB = libglut.a
GLUT_DXE = glut.dxe
GLUT_IMP = libiglut.a
export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR)
CC = gcc
CFLAGS += -I- -I$(TOP)/include -I. -I$(MKGLUT) -IPC_HW
AR = ar
ARFLAGS = rus
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
CORE_SOURCES = \
callback.c \
color.c \
extens.c \
init.c \
menu.c \
mouse.c \
overlay.c \
state.c \
window.c
PC_HW_SOURCES = \
PC_HW/pc_hw.c \
PC_HW/pc_keyb.c \
PC_HW/pc_mouse.c \
PC_HW/pc_timer.c \
PC_HW/pc_irq.S
MKGLUT_SOURCES = \
$(MKGLUT)/glut_bitmap.c \
$(MKGLUT)/glut_bwidth.c \
$(MKGLUT)/glut_stroke.c \
$(MKGLUT)/glut_swidth.c \
$(MKGLUT)/glut_shapes.c \
$(MKGLUT)/glut_teapot.c \
$(MKGLUT)/glut_8x13.c \
$(MKGLUT)/glut_9x15.c \
$(MKGLUT)/glut_hel10.c \
$(MKGLUT)/glut_hel12.c \
$(MKGLUT)/glut_hel18.c \
$(MKGLUT)/glut_tr10.c \
$(MKGLUT)/glut_tr24.c \
$(MKGLUT)/glut_roman.c \
$(MKGLUT)/glut_mroman.c \
$(MKGLUT)/glut_util.c
SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES) $(MKGLUT_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.S.o:
$(CC) -o $@ $(CFLAGS) -c $<
.s.o:
$(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP)
$(LIBDIR)/$(GLUT_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS)
$(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GLUT_DXE))
else
-dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -Y $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E _glut -P gl.dxe -P glu.dxe -U $(OBJECTS)
endif
clean:
-$(call UNLINK,*.o)
-$(call UNLINK,PC_HW/*.o)
-$(call UNLINK,$(MKGLUT)/*.o)
-include depend

View file

@ -1,145 +1,145 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include <fcntl.h>
#include <sys/stat.h> /* for mode definitions */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "pc_hw.h"
/*
* atexit
*/
#define MAX_ATEXIT 32
static volatile int atexitcnt;
static VFUNC atexittbl[MAX_ATEXIT];
static void __attribute__((destructor)) doexit (void)
{
while (atexitcnt) atexittbl[--atexitcnt]();
}
int pc_clexit (VFUNC f)
{
int i;
for (i=0;i<atexitcnt;i++) {
if (atexittbl[i]==f) {
for (atexitcnt--;i<atexitcnt;i++) atexittbl[i] = atexittbl[i+1];
atexittbl[i] = 0;
return 0;
}
}
return -1;
}
int pc_atexit (VFUNC f)
{
pc_clexit(f);
if (atexitcnt<MAX_ATEXIT) {
atexittbl[atexitcnt++] = f;
return 0;
}
return -1;
}
/*
* locked memory allocation
*/
void *pc_malloc (size_t size)
{
void *p = malloc(size);
if (p) {
if (_go32_dpmi_lock_data(p, size)) {
free(p);
return NULL;
}
}
return p;
}
/*
* standard redirection
*/
static char outname[L_tmpnam];
static int h_out, h_outbak;
static char errname[L_tmpnam];
static int h_err, h_errbak;
int pc_open_stdout (void)
{
tmpnam(outname);
if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
h_outbak = dup(STDOUT_FILENO);
fflush(stdout);
dup2(h_out, STDOUT_FILENO);
}
return h_out;
}
void pc_close_stdout (void)
{
FILE *f;
char *line = alloca(512);
if (h_out > 0) {
dup2(h_outbak, STDOUT_FILENO);
close(h_out);
close(h_outbak);
f = fopen(outname, "rt");
while (fgets(line, 512, f)) {
fputs(line, stdout);
}
fclose(f);
remove(outname);
}
}
int pc_open_stderr (void)
{
tmpnam(errname);
if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
h_errbak = dup(STDERR_FILENO);
fflush(stderr);
dup2(h_err, STDERR_FILENO);
}
return h_err;
}
void pc_close_stderr (void)
{
FILE *f;
char *line = alloca(512);
if (h_err > 0) {
dup2(h_errbak, STDERR_FILENO);
close(h_err);
close(h_errbak);
f = fopen(errname, "rt");
while (fgets(line, 512, f)) {
fputs(line, stderr);
}
fclose(f);
remove(errname);
}
}
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include <fcntl.h>
#include <sys/stat.h> /* for mode definitions */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "pc_hw.h"
/*
* atexit
*/
#define MAX_ATEXIT 32
static volatile int atexitcnt;
static VFUNC atexittbl[MAX_ATEXIT];
static void __attribute__((destructor)) doexit (void)
{
while (atexitcnt) atexittbl[--atexitcnt]();
}
int pc_clexit (VFUNC f)
{
int i;
for (i=0;i<atexitcnt;i++) {
if (atexittbl[i]==f) {
for (atexitcnt--;i<atexitcnt;i++) atexittbl[i] = atexittbl[i+1];
atexittbl[i] = 0;
return 0;
}
}
return -1;
}
int pc_atexit (VFUNC f)
{
pc_clexit(f);
if (atexitcnt<MAX_ATEXIT) {
atexittbl[atexitcnt++] = f;
return 0;
}
return -1;
}
/*
* locked memory allocation
*/
void *pc_malloc (size_t size)
{
void *p = malloc(size);
if (p) {
if (_go32_dpmi_lock_data(p, size)) {
free(p);
return NULL;
}
}
return p;
}
/*
* standard redirection
*/
static char outname[L_tmpnam];
static int h_out, h_outbak;
static char errname[L_tmpnam];
static int h_err, h_errbak;
int pc_open_stdout (void)
{
tmpnam(outname);
if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
h_outbak = dup(STDOUT_FILENO);
fflush(stdout);
dup2(h_out, STDOUT_FILENO);
}
return h_out;
}
void pc_close_stdout (void)
{
FILE *f;
char *line = alloca(512);
if (h_out > 0) {
dup2(h_outbak, STDOUT_FILENO);
close(h_out);
close(h_outbak);
f = fopen(outname, "rt");
while (fgets(line, 512, f)) {
fputs(line, stdout);
}
fclose(f);
remove(outname);
}
}
int pc_open_stderr (void)
{
tmpnam(errname);
if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
h_errbak = dup(STDERR_FILENO);
fflush(stderr);
dup2(h_err, STDERR_FILENO);
}
return h_err;
}
void pc_close_stderr (void)
{
FILE *f;
char *line = alloca(512);
if (h_err > 0) {
dup2(h_errbak, STDERR_FILENO);
close(h_err);
close(h_errbak);
f = fopen(errname, "rt");
while (fgets(line, 512, f)) {
fputs(line, stderr);
}
fclose(f);
remove(errname);
}
}

View file

@ -1,225 +1,225 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef PC_HW_H_included
#define PC_HW_H_included
#include <dpmi.h>
#include <stdlib.h>
/*
* misc C definitions
*/
#define FALSE 0
#define TRUE !FALSE
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#define MID(x,y,z) MAX((x), MIN((y), (z)))
typedef void (*VFUNC) (void);
typedef void (*PFUNC) (void *);
typedef void (*MFUNC) (int x, int y, int z, int b);
/*
* atexit
*/
int pc_atexit (VFUNC f);
int pc_clexit (VFUNC f);
/*
* locked memory
*/
#define ENDOFUNC(x) static void x##_end() { }
#define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x)
#define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x))
#define LOCKBUFF(x, l) _go32_dpmi_lock_data((void *)x, l)
void *pc_malloc (size_t size);
/*
* IRQ
*/
#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);
/*
* keyboard
*/
#define KB_SHIFT_FLAG 0x0001
#define KB_CTRL_FLAG 0x0002
#define KB_ALT_FLAG 0x0004
#define KB_LWIN_FLAG 0x0008
#define KB_RWIN_FLAG 0x0010
#define KB_MENU_FLAG 0x0020
#define KB_SCROLOCK_FLAG 0x0100
#define KB_NUMLOCK_FLAG 0x0200
#define KB_CAPSLOCK_FLAG 0x0400
#define KB_INALTSEQ_FLAG 0x0800
#define KB_ACCENT1_FLAG 0x1000
#define KB_ACCENT2_FLAG 0x2000
#define KB_ACCENT3_FLAG 0x4000
#define KB_ACCENT4_FLAG 0x8000
#define KEY_A 1
#define KEY_B 2
#define KEY_C 3
#define KEY_D 4
#define KEY_E 5
#define KEY_F 6
#define KEY_G 7
#define KEY_H 8
#define KEY_I 9
#define KEY_J 10
#define KEY_K 11
#define KEY_L 12
#define KEY_M 13
#define KEY_N 14
#define KEY_O 15
#define KEY_P 16
#define KEY_Q 17
#define KEY_R 18
#define KEY_S 19
#define KEY_T 20
#define KEY_U 21
#define KEY_V 22
#define KEY_W 23
#define KEY_X 24
#define KEY_Y 25
#define KEY_Z 26
#define KEY_0 27
#define KEY_1 28
#define KEY_2 29
#define KEY_3 30
#define KEY_4 31
#define KEY_5 32
#define KEY_6 33
#define KEY_7 34
#define KEY_8 35
#define KEY_9 36
#define KEY_0_PAD 37
#define KEY_1_PAD 38
#define KEY_2_PAD 39
#define KEY_3_PAD 40
#define KEY_4_PAD 41
#define KEY_5_PAD 42
#define KEY_6_PAD 43
#define KEY_7_PAD 44
#define KEY_8_PAD 45
#define KEY_9_PAD 46
#define KEY_F1 47
#define KEY_F2 48
#define KEY_F3 49
#define KEY_F4 50
#define KEY_F5 51
#define KEY_F6 52
#define KEY_F7 53
#define KEY_F8 54
#define KEY_F9 55
#define KEY_F10 56
#define KEY_F11 57
#define KEY_F12 58
#define KEY_ESC 59
#define KEY_TILDE 60
#define KEY_MINUS 61
#define KEY_EQUALS 62
#define KEY_BACKSPACE 63
#define KEY_TAB 64
#define KEY_OPENBRACE 65
#define KEY_CLOSEBRACE 66
#define KEY_ENTER 67
#define KEY_COLON 68
#define KEY_QUOTE 69
#define KEY_BACKSLASH 70
#define KEY_BACKSLASH2 71
#define KEY_COMMA 72
#define KEY_STOP 73
#define KEY_SLASH 74
#define KEY_SPACE 75
#define KEY_INSERT 76
#define KEY_DEL 77
#define KEY_HOME 78
#define KEY_END 79
#define KEY_PGUP 80
#define KEY_PGDN 81
#define KEY_LEFT 82
#define KEY_RIGHT 83
#define KEY_UP 84
#define KEY_DOWN 85
#define KEY_SLASH_PAD 86
#define KEY_ASTERISK 87
#define KEY_MINUS_PAD 88
#define KEY_PLUS_PAD 89
#define KEY_DEL_PAD 90
#define KEY_ENTER_PAD 91
#define KEY_PRTSCR 92
#define KEY_PAUSE 93
#define KEY_ABNT_C1 94
#define KEY_YEN 95
#define KEY_KANA 96
#define KEY_CONVERT 97
#define KEY_NOCONVERT 98
#define KEY_AT 99
#define KEY_CIRCUMFLEX 100
#define KEY_COLON2 101
#define KEY_KANJI 102
#define KEY_MODIFIERS 103
#define KEY_LSHIFT 103
#define KEY_RSHIFT 104
#define KEY_LCONTROL 105
#define KEY_RCONTROL 106
#define KEY_ALT 107
#define KEY_ALTGR 108
#define KEY_LWIN 109
#define KEY_RWIN 110
#define KEY_MENU 111
#define KEY_SCRLOCK 112
#define KEY_NUMLOCK 113
#define KEY_CAPSLOCK 114
#define KEY_MAX 115
int pc_install_keyb (void);
void pc_remove_keyb (void);
int pc_keypressed (void);
int pc_readkey (void);
int pc_keydown (int code);
int pc_keyshifts (void);
/*
* timer
*/
int pc_install_int (PFUNC func, void *parm, unsigned int freq);
void pc_remove_timer (void);
/*
* mouse
*/
int pc_install_mouse (void);
void pc_remove_mouse (void);
MFUNC pc_install_mouse_handler (MFUNC handler);
void pc_mouse_area (int x1, int y1, int x2, int y2);
void pc_mouse_speed (int xspeed, int yspeed);
int pc_query_mouse (int *x, int *y, int *z);
void pc_warp_mouse (int x, int y);
/*
* standard redirection
*/
int pc_open_stdout (void);
int pc_open_stderr (void);
void pc_close_stdout (void);
void pc_close_stderr (void);
#endif
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef PC_HW_H_included
#define PC_HW_H_included
#include <dpmi.h>
#include <stdlib.h>
/*
* misc C definitions
*/
#define FALSE 0
#define TRUE !FALSE
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#define MID(x,y,z) MAX((x), MIN((y), (z)))
typedef void (*VFUNC) (void);
typedef void (*PFUNC) (void *);
typedef void (*MFUNC) (int x, int y, int z, int b);
/*
* atexit
*/
int pc_atexit (VFUNC f);
int pc_clexit (VFUNC f);
/*
* locked memory
*/
#define ENDOFUNC(x) static void x##_end() { }
#define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x)
#define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x))
#define LOCKBUFF(x, l) _go32_dpmi_lock_data((void *)x, l)
void *pc_malloc (size_t size);
/*
* IRQ
*/
#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);
/*
* keyboard
*/
#define KB_SHIFT_FLAG 0x0001
#define KB_CTRL_FLAG 0x0002
#define KB_ALT_FLAG 0x0004
#define KB_LWIN_FLAG 0x0008
#define KB_RWIN_FLAG 0x0010
#define KB_MENU_FLAG 0x0020
#define KB_SCROLOCK_FLAG 0x0100
#define KB_NUMLOCK_FLAG 0x0200
#define KB_CAPSLOCK_FLAG 0x0400
#define KB_INALTSEQ_FLAG 0x0800
#define KB_ACCENT1_FLAG 0x1000
#define KB_ACCENT2_FLAG 0x2000
#define KB_ACCENT3_FLAG 0x4000
#define KB_ACCENT4_FLAG 0x8000
#define KEY_A 1
#define KEY_B 2
#define KEY_C 3
#define KEY_D 4
#define KEY_E 5
#define KEY_F 6
#define KEY_G 7
#define KEY_H 8
#define KEY_I 9
#define KEY_J 10
#define KEY_K 11
#define KEY_L 12
#define KEY_M 13
#define KEY_N 14
#define KEY_O 15
#define KEY_P 16
#define KEY_Q 17
#define KEY_R 18
#define KEY_S 19
#define KEY_T 20
#define KEY_U 21
#define KEY_V 22
#define KEY_W 23
#define KEY_X 24
#define KEY_Y 25
#define KEY_Z 26
#define KEY_0 27
#define KEY_1 28
#define KEY_2 29
#define KEY_3 30
#define KEY_4 31
#define KEY_5 32
#define KEY_6 33
#define KEY_7 34
#define KEY_8 35
#define KEY_9 36
#define KEY_0_PAD 37
#define KEY_1_PAD 38
#define KEY_2_PAD 39
#define KEY_3_PAD 40
#define KEY_4_PAD 41
#define KEY_5_PAD 42
#define KEY_6_PAD 43
#define KEY_7_PAD 44
#define KEY_8_PAD 45
#define KEY_9_PAD 46
#define KEY_F1 47
#define KEY_F2 48
#define KEY_F3 49
#define KEY_F4 50
#define KEY_F5 51
#define KEY_F6 52
#define KEY_F7 53
#define KEY_F8 54
#define KEY_F9 55
#define KEY_F10 56
#define KEY_F11 57
#define KEY_F12 58
#define KEY_ESC 59
#define KEY_TILDE 60
#define KEY_MINUS 61
#define KEY_EQUALS 62
#define KEY_BACKSPACE 63
#define KEY_TAB 64
#define KEY_OPENBRACE 65
#define KEY_CLOSEBRACE 66
#define KEY_ENTER 67
#define KEY_COLON 68
#define KEY_QUOTE 69
#define KEY_BACKSLASH 70
#define KEY_BACKSLASH2 71
#define KEY_COMMA 72
#define KEY_STOP 73
#define KEY_SLASH 74
#define KEY_SPACE 75
#define KEY_INSERT 76
#define KEY_DEL 77
#define KEY_HOME 78
#define KEY_END 79
#define KEY_PGUP 80
#define KEY_PGDN 81
#define KEY_LEFT 82
#define KEY_RIGHT 83
#define KEY_UP 84
#define KEY_DOWN 85
#define KEY_SLASH_PAD 86
#define KEY_ASTERISK 87
#define KEY_MINUS_PAD 88
#define KEY_PLUS_PAD 89
#define KEY_DEL_PAD 90
#define KEY_ENTER_PAD 91
#define KEY_PRTSCR 92
#define KEY_PAUSE 93
#define KEY_ABNT_C1 94
#define KEY_YEN 95
#define KEY_KANA 96
#define KEY_CONVERT 97
#define KEY_NOCONVERT 98
#define KEY_AT 99
#define KEY_CIRCUMFLEX 100
#define KEY_COLON2 101
#define KEY_KANJI 102
#define KEY_MODIFIERS 103
#define KEY_LSHIFT 103
#define KEY_RSHIFT 104
#define KEY_LCONTROL 105
#define KEY_RCONTROL 106
#define KEY_ALT 107
#define KEY_ALTGR 108
#define KEY_LWIN 109
#define KEY_RWIN 110
#define KEY_MENU 111
#define KEY_SCRLOCK 112
#define KEY_NUMLOCK 113
#define KEY_CAPSLOCK 114
#define KEY_MAX 115
int pc_install_keyb (void);
void pc_remove_keyb (void);
int pc_keypressed (void);
int pc_readkey (void);
int pc_keydown (int code);
int pc_keyshifts (void);
/*
* timer
*/
int pc_install_int (PFUNC func, void *parm, unsigned int freq);
void pc_remove_timer (void);
/*
* mouse
*/
int pc_install_mouse (void);
void pc_remove_mouse (void);
MFUNC pc_install_mouse_handler (MFUNC handler);
void pc_mouse_area (int x1, int y1, int x2, int y2);
void pc_mouse_speed (int xspeed, int yspeed);
int pc_query_mouse (int *x, int *y, int *z);
void pc_warp_mouse (int x, int y);
/*
* standard redirection
*/
int pc_open_stdout (void);
int pc_open_stderr (void);
void pc_close_stdout (void);
void pc_close_stderr (void);
#endif

View file

@ -1,182 +1,182 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
.file "pc_irq.S"
.text
#define IRQ_STACK_SIZE 16384
#define IRQ_WRAPPER_LEN (__irq_wrapper_1-__irq_wrapper_0)
#define IRQ_OLD (__irq_old_0-__irq_wrapper_0)
#define IRQ_HOOK (__irq_hook_0-__irq_wrapper_0)
#define IRQ_STACK (__irq_stack_0-__irq_wrapper_0)
.balign 4
common:
movw $0x0400, %ax
int $0x31
movl %ss:8(%ebp), %ebx
cmpl $15, %ebx
jbe 0f
fail:
orl $-1, %eax
popl %edi
popl %ebx
leave
ret
0:
movl %ebx, %edi
imull $IRQ_WRAPPER_LEN, %edi
addl $__irq_wrapper_0, %edi
cmpb $7, %bl
jbe 1f
movb %dl, %dh
subb $8, %dh
1:
addb %dh, %bl
ret
.balign 4
.global _pc_install_irq
_pc_install_irq:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
call common
cmpl $0, IRQ_HOOK(%edi)
jne fail
pushl $IRQ_WRAPPER_LEN
pushl %edi
call __go32_dpmi_lock_code
addl $8, %esp
testl %eax, %eax
jnz fail
pushl $IRQ_STACK_SIZE
call _pc_malloc
popl %edx
testl %eax, %eax
jz fail
addl %edx, %eax
movl %eax, IRQ_STACK(%edi)
movl ___djgpp_ds_alias, %eax
movl %eax, IRQ_STACK+4(%edi)
movl %ss:12(%ebp), %eax
movl %eax, IRQ_HOOK(%edi)
movw $0x0204, %ax
int $0x31
movl %edx, IRQ_OLD(%edi)
movw %cx, IRQ_OLD+4(%edi)
movw $0x0205, %ax
movl %edi, %edx
movl %cs, %ecx
int $0x31
done:
xorl %eax, %eax
popl %edi
popl %ebx
leave
ret
.balign 4
.global _pc_remove_irq
_pc_remove_irq:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
call common
cmpl $0, IRQ_HOOK(%edi)
je fail
movl $0, IRQ_HOOK(%edi)
movw $0x0205, %ax
movl IRQ_OLD(%edi), %edx
movl IRQ_OLD+4(%edi), %ecx
int $0x31
movl IRQ_STACK(%edi), %eax
subl $IRQ_STACK_SIZE, %eax
pushl %eax
call _free
popl %eax
jmp done
#define WRAPPER(x) ; \
.balign 4 ; \
__irq_wrapper_##x: ; \
pushal ; \
pushl %ds ; \
pushl %es ; \
pushl %fs ; \
pushl %gs ; \
movl %ss, %ebx ; \
movl %esp, %esi ; \
lss %cs:__irq_stack_##x, %esp ; \
pushl %ss ; \
pushl %ss ; \
popl %es ; \
popl %ds ; \
movl ___djgpp_dos_sel, %fs ; \
pushl %fs ; \
popl %gs ; \
call *__irq_hook_##x ; \
movl %ebx, %ss ; \
movl %esi, %esp ; \
testl %eax, %eax ; \
popl %gs ; \
popl %fs ; \
popl %es ; \
popl %ds ; \
popal ; \
jz __irq_ignore_##x ; \
__irq_bypass_##x: ; \
ljmp *%cs:__irq_old_##x ; \
__irq_ignore_##x: ; \
iret ; \
.balign 4 ; \
__irq_old_##x: ; \
.long 0, 0 ; \
__irq_hook_##x: ; \
.long 0 ; \
__irq_stack_##x: ; \
.long 0, 0
WRAPPER(0);
WRAPPER(1);
WRAPPER(2);
WRAPPER(3);
WRAPPER(4);
WRAPPER(5);
WRAPPER(6);
WRAPPER(7);
WRAPPER(8);
WRAPPER(9);
WRAPPER(10);
WRAPPER(11);
WRAPPER(12);
WRAPPER(13);
WRAPPER(14);
WRAPPER(15);
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
.file "pc_irq.S"
.text
#define IRQ_STACK_SIZE 16384
#define IRQ_WRAPPER_LEN (__irq_wrapper_1-__irq_wrapper_0)
#define IRQ_OLD (__irq_old_0-__irq_wrapper_0)
#define IRQ_HOOK (__irq_hook_0-__irq_wrapper_0)
#define IRQ_STACK (__irq_stack_0-__irq_wrapper_0)
.balign 4
common:
movw $0x0400, %ax
int $0x31
movl %ss:8(%ebp), %ebx
cmpl $15, %ebx
jbe 0f
fail:
orl $-1, %eax
popl %edi
popl %ebx
leave
ret
0:
movl %ebx, %edi
imull $IRQ_WRAPPER_LEN, %edi
addl $__irq_wrapper_0, %edi
cmpb $7, %bl
jbe 1f
movb %dl, %dh
subb $8, %dh
1:
addb %dh, %bl
ret
.balign 4
.global _pc_install_irq
_pc_install_irq:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
call common
cmpl $0, IRQ_HOOK(%edi)
jne fail
pushl $IRQ_WRAPPER_LEN
pushl %edi
call __go32_dpmi_lock_code
addl $8, %esp
testl %eax, %eax
jnz fail
pushl $IRQ_STACK_SIZE
call _pc_malloc
popl %edx
testl %eax, %eax
jz fail
addl %edx, %eax
movl %eax, IRQ_STACK(%edi)
movl ___djgpp_ds_alias, %eax
movl %eax, IRQ_STACK+4(%edi)
movl %ss:12(%ebp), %eax
movl %eax, IRQ_HOOK(%edi)
movw $0x0204, %ax
int $0x31
movl %edx, IRQ_OLD(%edi)
movw %cx, IRQ_OLD+4(%edi)
movw $0x0205, %ax
movl %edi, %edx
movl %cs, %ecx
int $0x31
done:
xorl %eax, %eax
popl %edi
popl %ebx
leave
ret
.balign 4
.global _pc_remove_irq
_pc_remove_irq:
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %edi
call common
cmpl $0, IRQ_HOOK(%edi)
je fail
movl $0, IRQ_HOOK(%edi)
movw $0x0205, %ax
movl IRQ_OLD(%edi), %edx
movl IRQ_OLD+4(%edi), %ecx
int $0x31
movl IRQ_STACK(%edi), %eax
subl $IRQ_STACK_SIZE, %eax
pushl %eax
call _free
popl %eax
jmp done
#define WRAPPER(x) ; \
.balign 4 ; \
__irq_wrapper_##x: ; \
pushal ; \
pushl %ds ; \
pushl %es ; \
pushl %fs ; \
pushl %gs ; \
movl %ss, %ebx ; \
movl %esp, %esi ; \
lss %cs:__irq_stack_##x, %esp ; \
pushl %ss ; \
pushl %ss ; \
popl %es ; \
popl %ds ; \
movl ___djgpp_dos_sel, %fs ; \
pushl %fs ; \
popl %gs ; \
call *__irq_hook_##x ; \
movl %ebx, %ss ; \
movl %esi, %esp ; \
testl %eax, %eax ; \
popl %gs ; \
popl %fs ; \
popl %es ; \
popl %ds ; \
popal ; \
jz __irq_ignore_##x ; \
__irq_bypass_##x: ; \
ljmp *%cs:__irq_old_##x ; \
__irq_ignore_##x: ; \
iret ; \
.balign 4 ; \
__irq_old_##x: ; \
.long 0, 0 ; \
__irq_hook_##x: ; \
.long 0 ; \
__irq_stack_##x: ; \
.long 0, 0
WRAPPER(0);
WRAPPER(1);
WRAPPER(2);
WRAPPER(3);
WRAPPER(4);
WRAPPER(5);
WRAPPER(6);
WRAPPER(7);
WRAPPER(8);
WRAPPER(9);
WRAPPER(10);
WRAPPER(11);
WRAPPER(12);
WRAPPER(13);
WRAPPER(14);
WRAPPER(15);

File diff suppressed because it is too large Load diff

View file

@ -1,278 +1,278 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include <sys/exceptn.h>
#include <sys/segments.h>
#include "pc_hw.h"
#define PC_CUTE_WHEEL 1 /* CuteMouse WheelAPI */
#define MOUSE_STACK_SIZE 16384
#define CLEAR_MICKEYS() \
do { \
__asm __volatile ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \
ox = oy = 0; \
} while (0)
extern void mouse_wrap (void);
extern int mouse_wrap_end[];
static MFUNC mouse_func;
static long mouse_callback;
static __dpmi_regs mouse_regs;
static volatile struct {
volatile int x, y, z, b;
} pc_mouse;
static int minx = 0;
static int maxx = 319;
static int miny = 0;
static int maxy = 199;
static int minz = 0;
static int maxz = 255;
static int sx = 2;
static int sy = 2;
static int emulat3 = FALSE;
static int ox, oy;
static void mouse (__dpmi_regs *r)
{
int nx = (signed short)r->x.si / sx;
int ny = (signed short)r->x.di / sy;
int dx = nx - ox;
int dy = ny - oy;
#if PC_CUTE_WHEEL
int dz = (signed char)r->h.bh;
#endif
ox = nx;
oy = ny;
pc_mouse.b = r->h.bl;
pc_mouse.x = MID(minx, pc_mouse.x + dx, maxx);
pc_mouse.y = MID(miny, pc_mouse.y + dy, maxy);
#if PC_CUTE_WHEEL
pc_mouse.z = MID(minz, pc_mouse.z + dz, maxz);
#endif
if (emulat3) {
if ((pc_mouse.b&3)==3) {
pc_mouse.b = 4;
}
}
if (mouse_func) {
mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b);
}
} ENDOFUNC(mouse)
void pc_remove_mouse (void)
{
if (mouse_callback) {
pc_clexit(pc_remove_mouse);
__asm("\n\
movl %%edx, %%ecx \n\
shrl $16, %%ecx \n\
movw $0x0304, %%ax \n\
int $0x31 \n\
movw $0x000c, %%ax \n\
xorl %%ecx, %%ecx \n\
int $0x33 \n\
"::"d"(mouse_callback):"%eax", "%ecx");
mouse_callback = 0;
free((void *)(mouse_wrap_end[0] - MOUSE_STACK_SIZE));
}
}
int pc_install_mouse (void)
{
int buttons;
/* fail if already call-backed */
if (mouse_callback) {
return 0;
}
/* reset mouse and get status */
__asm("\n\
xorl %%eax, %%eax \n\
int $0x33 \n\
andl %%ebx, %%eax \n\
movl %%eax, %0 \n\
":"=g" (buttons)::"%eax", "%ebx");
if (!buttons) {
return 0;
}
/* lock wrapper */
LOCKDATA(mouse_func);
LOCKDATA(mouse_callback);
LOCKDATA(mouse_regs);
LOCKDATA(pc_mouse);
LOCKDATA(minx);
LOCKDATA(maxx);
LOCKDATA(miny);
LOCKDATA(maxy);
LOCKDATA(minz);
LOCKDATA(maxz);
LOCKDATA(sx);
LOCKDATA(sy);
LOCKDATA(emulat3);
LOCKDATA(ox);
LOCKDATA(oy);
LOCKFUNC(mouse);
LOCKFUNC(mouse_wrap);
mouse_wrap_end[1] = __djgpp_ds_alias;
/* grab a locked stack */
if ((mouse_wrap_end[0] = (int)pc_malloc(MOUSE_STACK_SIZE)) == NULL) {
return 0;
}
/* try to hook a call-back */
__asm("\n\
pushl %%ds \n\
pushl %%es \n\
movw $0x0303, %%ax \n\
pushl %%ds \n\
pushl %%cs \n\
popl %%ds \n\
popl %%es \n\
int $0x31 \n\
popl %%es \n\
popl %%ds \n\
jc 0f \n\
shll $16, %%ecx \n\
movw %%dx, %%cx \n\
movl %%ecx, %0 \n\
0: \n\
":"=g"(mouse_callback)
:"S" (mouse_wrap), "D"(&mouse_regs)
:"%eax", "%ecx", "%edx");
if (!mouse_callback) {
free((void *)mouse_wrap_end[0]);
return 0;
}
/* adjust stack */
mouse_wrap_end[0] += MOUSE_STACK_SIZE;
/* install the handler */
mouse_regs.x.ax = 0x000c;
#if PC_CUTE_WHEEL
mouse_regs.x.cx = 0x7f | 0x80;
#else
mouse_regs.x.cx = 0x7f;
#endif
mouse_regs.x.dx = mouse_callback&0xffff;
mouse_regs.x.es = mouse_callback>>16;
__dpmi_int(0x33, &mouse_regs);
CLEAR_MICKEYS();
emulat3 = buttons<3;
pc_atexit(pc_remove_mouse);
return buttons;
}
MFUNC pc_install_mouse_handler (MFUNC handler)
{
MFUNC old;
if (!mouse_callback && !pc_install_mouse()) {
return NULL;
}
old = mouse_func;
mouse_func = handler;
return old;
}
void pc_mouse_area (int x1, int y1, int x2, int y2)
{
minx = x1;
maxx = x2;
miny = y1;
maxy = y2;
}
void pc_mouse_speed (int xspeed, int yspeed)
{
DISABLE();
sx = MAX(1, xspeed);
sy = MAX(1, yspeed);
ENABLE();
}
int pc_query_mouse (int *x, int *y, int *z)
{
*x = pc_mouse.x;
*y = pc_mouse.y;
*z = pc_mouse.z;
return pc_mouse.b;
}
void pc_warp_mouse (int x, int y)
{
CLEAR_MICKEYS();
pc_mouse.x = MID(minx, x, maxx);
pc_mouse.y = MID(miny, y, maxy);
if (mouse_func) {
mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b);
}
}
/* Hack alert:
* `mouse_wrap_end' actually holds the
* address of stack in a safe data selector.
*/
__asm("\n\
.text \n\
.p2align 5,,31 \n\
.global _mouse_wrap \n\
_mouse_wrap: \n\
cld \n\
lodsl \n\
movl %eax, %es:42(%edi) \n\
addw $4, %es:46(%edi) \n\
pushl %es \n\
movl %ss, %ebx \n\
movl %esp, %esi \n\
lss %cs:_mouse_wrap_end, %esp\n\
pushl %ss \n\
pushl %ss \n\
popl %es \n\
popl %ds \n\
movl ___djgpp_dos_sel, %fs \n\
pushl %fs \n\
popl %gs \n\
pushl %edi \n\
call _mouse \n\
popl %edi \n\
movl %ebx, %ss \n\
movl %esi, %esp \n\
popl %es \n\
iret \n\
.global _mouse_wrap_end \n\
_mouse_wrap_end:.long 0, 0");
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include <sys/exceptn.h>
#include <sys/segments.h>
#include "pc_hw.h"
#define PC_CUTE_WHEEL 1 /* CuteMouse WheelAPI */
#define MOUSE_STACK_SIZE 16384
#define CLEAR_MICKEYS() \
do { \
__asm __volatile ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \
ox = oy = 0; \
} while (0)
extern void mouse_wrap (void);
extern int mouse_wrap_end[];
static MFUNC mouse_func;
static long mouse_callback;
static __dpmi_regs mouse_regs;
static volatile struct {
volatile int x, y, z, b;
} pc_mouse;
static int minx = 0;
static int maxx = 319;
static int miny = 0;
static int maxy = 199;
static int minz = 0;
static int maxz = 255;
static int sx = 2;
static int sy = 2;
static int emulat3 = FALSE;
static int ox, oy;
static void mouse (__dpmi_regs *r)
{
int nx = (signed short)r->x.si / sx;
int ny = (signed short)r->x.di / sy;
int dx = nx - ox;
int dy = ny - oy;
#if PC_CUTE_WHEEL
int dz = (signed char)r->h.bh;
#endif
ox = nx;
oy = ny;
pc_mouse.b = r->h.bl;
pc_mouse.x = MID(minx, pc_mouse.x + dx, maxx);
pc_mouse.y = MID(miny, pc_mouse.y + dy, maxy);
#if PC_CUTE_WHEEL
pc_mouse.z = MID(minz, pc_mouse.z + dz, maxz);
#endif
if (emulat3) {
if ((pc_mouse.b&3)==3) {
pc_mouse.b = 4;
}
}
if (mouse_func) {
mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b);
}
} ENDOFUNC(mouse)
void pc_remove_mouse (void)
{
if (mouse_callback) {
pc_clexit(pc_remove_mouse);
__asm("\n\
movl %%edx, %%ecx \n\
shrl $16, %%ecx \n\
movw $0x0304, %%ax \n\
int $0x31 \n\
movw $0x000c, %%ax \n\
xorl %%ecx, %%ecx \n\
int $0x33 \n\
"::"d"(mouse_callback):"%eax", "%ecx");
mouse_callback = 0;
free((void *)(mouse_wrap_end[0] - MOUSE_STACK_SIZE));
}
}
int pc_install_mouse (void)
{
int buttons;
/* fail if already call-backed */
if (mouse_callback) {
return 0;
}
/* reset mouse and get status */
__asm("\n\
xorl %%eax, %%eax \n\
int $0x33 \n\
andl %%ebx, %%eax \n\
movl %%eax, %0 \n\
":"=g" (buttons)::"%eax", "%ebx");
if (!buttons) {
return 0;
}
/* lock wrapper */
LOCKDATA(mouse_func);
LOCKDATA(mouse_callback);
LOCKDATA(mouse_regs);
LOCKDATA(pc_mouse);
LOCKDATA(minx);
LOCKDATA(maxx);
LOCKDATA(miny);
LOCKDATA(maxy);
LOCKDATA(minz);
LOCKDATA(maxz);
LOCKDATA(sx);
LOCKDATA(sy);
LOCKDATA(emulat3);
LOCKDATA(ox);
LOCKDATA(oy);
LOCKFUNC(mouse);
LOCKFUNC(mouse_wrap);
mouse_wrap_end[1] = __djgpp_ds_alias;
/* grab a locked stack */
if ((mouse_wrap_end[0] = (int)pc_malloc(MOUSE_STACK_SIZE)) == NULL) {
return 0;
}
/* try to hook a call-back */
__asm("\n\
pushl %%ds \n\
pushl %%es \n\
movw $0x0303, %%ax \n\
pushl %%ds \n\
pushl %%cs \n\
popl %%ds \n\
popl %%es \n\
int $0x31 \n\
popl %%es \n\
popl %%ds \n\
jc 0f \n\
shll $16, %%ecx \n\
movw %%dx, %%cx \n\
movl %%ecx, %0 \n\
0: \n\
":"=g"(mouse_callback)
:"S" (mouse_wrap), "D"(&mouse_regs)
:"%eax", "%ecx", "%edx");
if (!mouse_callback) {
free((void *)mouse_wrap_end[0]);
return 0;
}
/* adjust stack */
mouse_wrap_end[0] += MOUSE_STACK_SIZE;
/* install the handler */
mouse_regs.x.ax = 0x000c;
#if PC_CUTE_WHEEL
mouse_regs.x.cx = 0x7f | 0x80;
#else
mouse_regs.x.cx = 0x7f;
#endif
mouse_regs.x.dx = mouse_callback&0xffff;
mouse_regs.x.es = mouse_callback>>16;
__dpmi_int(0x33, &mouse_regs);
CLEAR_MICKEYS();
emulat3 = buttons<3;
pc_atexit(pc_remove_mouse);
return buttons;
}
MFUNC pc_install_mouse_handler (MFUNC handler)
{
MFUNC old;
if (!mouse_callback && !pc_install_mouse()) {
return NULL;
}
old = mouse_func;
mouse_func = handler;
return old;
}
void pc_mouse_area (int x1, int y1, int x2, int y2)
{
minx = x1;
maxx = x2;
miny = y1;
maxy = y2;
}
void pc_mouse_speed (int xspeed, int yspeed)
{
DISABLE();
sx = MAX(1, xspeed);
sy = MAX(1, yspeed);
ENABLE();
}
int pc_query_mouse (int *x, int *y, int *z)
{
*x = pc_mouse.x;
*y = pc_mouse.y;
*z = pc_mouse.z;
return pc_mouse.b;
}
void pc_warp_mouse (int x, int y)
{
CLEAR_MICKEYS();
pc_mouse.x = MID(minx, x, maxx);
pc_mouse.y = MID(miny, y, maxy);
if (mouse_func) {
mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b);
}
}
/* Hack alert:
* `mouse_wrap_end' actually holds the
* address of stack in a safe data selector.
*/
__asm("\n\
.text \n\
.p2align 5,,31 \n\
.global _mouse_wrap \n\
_mouse_wrap: \n\
cld \n\
lodsl \n\
movl %eax, %es:42(%edi) \n\
addw $4, %es:46(%edi) \n\
pushl %es \n\
movl %ss, %ebx \n\
movl %esp, %esi \n\
lss %cs:_mouse_wrap_end, %esp\n\
pushl %ss \n\
pushl %ss \n\
popl %es \n\
popl %ds \n\
movl ___djgpp_dos_sel, %fs \n\
pushl %fs \n\
popl %gs \n\
pushl %edi \n\
call _mouse \n\
popl %edi \n\
movl %ebx, %ss \n\
movl %esi, %esp \n\
popl %es \n\
iret \n\
.global _mouse_wrap_end \n\
_mouse_wrap_end:.long 0, 0");

View file

@ -1,158 +1,158 @@
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <pc.h>
#include "pc_hw.h"
#define TIMER_IRQ 0
#define MAX_TIMERS 8
#define PIT_FREQ 0x1234DD
#define unvolatile(__v, __t) __extension__ ({union { volatile __t __cp; __t __p; } __q; __q.__cp = __v; __q.__p;})
static int timer_installed;
typedef struct {
volatile unsigned int counter, clock_ticks, freq;
volatile PFUNC func;
volatile void *parm;
} TIMER;
static TIMER timer_main, timer_func[MAX_TIMERS];
static int timer ()
{
int i;
for (i=0;i<MAX_TIMERS;i++) {
TIMER *t = &timer_func[i];
if (t->func) {
t->clock_ticks += t->counter;
if (t->clock_ticks>=timer_main.counter) {
t->clock_ticks -= timer_main.counter;
t->func(unvolatile(t->parm, void *));
}
}
}
timer_main.clock_ticks += timer_main.counter;
if (timer_main.clock_ticks>=0x10000) {
timer_main.clock_ticks -= 0x10000;
return 1;
} else {
outportb(0x20, 0x20);
return 0;
}
} ENDOFUNC(timer)
void pc_remove_timer (void)
{
if (timer_installed) {
timer_installed = FALSE;
pc_clexit(pc_remove_timer);
DISABLE();
outportb(0x43, 0x34);
outportb(0x40, 0);
outportb(0x40, 0);
ENABLE();
pc_remove_irq(TIMER_IRQ);
}
}
static int install_timer (void)
{
if (timer_installed||pc_install_irq(TIMER_IRQ, timer)) {
return -1;
} else {
LOCKDATA(timer_func);
LOCKDATA(timer_main);
LOCKFUNC(timer);
timer_main.counter = 0x10000;
DISABLE();
outportb(0x43, 0x34);
outportb(0x40, 0);
outportb(0x40, 0);
timer_main.clock_ticks = 0;
ENABLE();
pc_atexit(pc_remove_timer);
timer_installed = TRUE;
return 0;
}
}
static TIMER *find_slot (PFUNC func)
{
int i;
for (i=0;i<MAX_TIMERS;i++) {
if (timer_func[i].func==func) {
return &timer_func[i];
}
}
for (i=0;i<MAX_TIMERS;i++) {
if (!timer_func[i].func) {
return &timer_func[i];
}
}
return NULL;
}
int pc_install_int (PFUNC func, void *parm, unsigned int freq)
{
int i;
TIMER *t;
if (!timer_installed) {
if (install_timer()) {
return -1;
}
}
if ((t=find_slot(func))!=NULL) {
unsigned int new_counter = PIT_FREQ / freq;
DISABLE();
t->func = func;
t->parm = parm;
t->freq = freq;
t->clock_ticks = 0;
if (new_counter < timer_main.counter) {
for (i=0;i<MAX_TIMERS;i++) {
if (timer_func[i].func) {
timer_func[i].counter = new_counter * timer_func[i].freq / freq;
}
}
outportb(0x43, 0x34);
outportb(0x40, (unsigned char)new_counter);
outportb(0x40, (unsigned char)(new_counter>>8));
timer_main.clock_ticks = 0;
timer_main.counter = new_counter;
timer_main.freq = freq;
} else {
t->counter = PIT_FREQ * freq / (timer_main.freq * timer_main.freq);
}
ENABLE();
return 0;
}
return -1;
}
/*
* PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <pc.h>
#include "pc_hw.h"
#define TIMER_IRQ 0
#define MAX_TIMERS 8
#define PIT_FREQ 0x1234DD
#define unvolatile(__v, __t) __extension__ ({union { volatile __t __cp; __t __p; } __q; __q.__cp = __v; __q.__p;})
static int timer_installed;
typedef struct {
volatile unsigned int counter, clock_ticks, freq;
volatile PFUNC func;
volatile void *parm;
} TIMER;
static TIMER timer_main, timer_func[MAX_TIMERS];
static int timer ()
{
int i;
for (i=0;i<MAX_TIMERS;i++) {
TIMER *t = &timer_func[i];
if (t->func) {
t->clock_ticks += t->counter;
if (t->clock_ticks>=timer_main.counter) {
t->clock_ticks -= timer_main.counter;
t->func(unvolatile(t->parm, void *));
}
}
}
timer_main.clock_ticks += timer_main.counter;
if (timer_main.clock_ticks>=0x10000) {
timer_main.clock_ticks -= 0x10000;
return 1;
} else {
outportb(0x20, 0x20);
return 0;
}
} ENDOFUNC(timer)
void pc_remove_timer (void)
{
if (timer_installed) {
timer_installed = FALSE;
pc_clexit(pc_remove_timer);
DISABLE();
outportb(0x43, 0x34);
outportb(0x40, 0);
outportb(0x40, 0);
ENABLE();
pc_remove_irq(TIMER_IRQ);
}
}
static int install_timer (void)
{
if (timer_installed||pc_install_irq(TIMER_IRQ, timer)) {
return -1;
} else {
LOCKDATA(timer_func);
LOCKDATA(timer_main);
LOCKFUNC(timer);
timer_main.counter = 0x10000;
DISABLE();
outportb(0x43, 0x34);
outportb(0x40, 0);
outportb(0x40, 0);
timer_main.clock_ticks = 0;
ENABLE();
pc_atexit(pc_remove_timer);
timer_installed = TRUE;
return 0;
}
}
static TIMER *find_slot (PFUNC func)
{
int i;
for (i=0;i<MAX_TIMERS;i++) {
if (timer_func[i].func==func) {
return &timer_func[i];
}
}
for (i=0;i<MAX_TIMERS;i++) {
if (!timer_func[i].func) {
return &timer_func[i];
}
}
return NULL;
}
int pc_install_int (PFUNC func, void *parm, unsigned int freq)
{
int i;
TIMER *t;
if (!timer_installed) {
if (install_timer()) {
return -1;
}
}
if ((t=find_slot(func))!=NULL) {
unsigned int new_counter = PIT_FREQ / freq;
DISABLE();
t->func = func;
t->parm = parm;
t->freq = freq;
t->clock_ticks = 0;
if (new_counter < timer_main.counter) {
for (i=0;i<MAX_TIMERS;i++) {
if (timer_func[i].func) {
timer_func[i].counter = new_counter * timer_func[i].freq / freq;
}
}
outportb(0x43, 0x34);
outportb(0x40, (unsigned char)new_counter);
outportb(0x40, (unsigned char)(new_counter>>8));
timer_main.clock_ticks = 0;
timer_main.counter = new_counter;
timer_main.freq = freq;
} else {
t->counter = PIT_FREQ * freq / (timer_main.freq * timer_main.freq);
}
ENABLE();
return 0;
}
return -1;
}

View file

@ -1,164 +1,164 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
GLUTidleCB g_idle_func = NULL;
void APIENTRY glutDisplayFunc (GLUTdisplayCB func)
{
g_curwin->display = func;
}
void APIENTRY glutReshapeFunc (GLUTreshapeCB func)
{
g_curwin->reshape = func;
}
void APIENTRY glutKeyboardFunc (GLUTkeyboardCB func)
{
g_curwin->keyboard = func;
}
void APIENTRY glutMouseFunc (GLUTmouseCB func)
{
g_curwin->mouse = func;
}
void APIENTRY glutMotionFunc (GLUTmotionCB func)
{
g_curwin->motion = func;
}
void APIENTRY glutPassiveMotionFunc (GLUTpassiveCB func)
{
g_curwin->passive = func;
}
void APIENTRY glutEntryFunc (GLUTentryCB func)
{
g_curwin->entry = func;
}
void APIENTRY glutVisibilityFunc (GLUTvisibilityCB func)
{
g_curwin->visibility = func;
}
void APIENTRY glutWindowStatusFunc (GLUTwindowStatusCB func)
{
}
void APIENTRY glutIdleFunc (GLUTidleCB func)
{
g_idle_func = func;
}
void APIENTRY glutTimerFunc (unsigned int millis, GLUTtimerCB func, int value)
{
}
void APIENTRY glutSpecialFunc (GLUTspecialCB func)
{
g_curwin->special = func;
}
void APIENTRY glutSpaceballMotionFunc (GLUTspaceMotionCB func)
{
}
void APIENTRY glutSpaceballRotateFunc (GLUTspaceRotateCB func)
{
}
void APIENTRY glutSpaceballButtonFunc (GLUTspaceButtonCB func)
{
}
void APIENTRY glutDialsFunc (GLUTdialsCB func)
{
}
void APIENTRY glutButtonBoxFunc (GLUTbuttonBoxCB func)
{
}
void APIENTRY glutTabletMotionFunc (GLUTtabletMotionCB func)
{
}
void APIENTRY glutTabletButtonFunc (GLUTtabletButtonCB func)
{
}
void APIENTRY glutJoystickFunc (GLUTjoystickCB func, int interval)
{
}
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
GLUTidleCB g_idle_func = NULL;
void APIENTRY glutDisplayFunc (GLUTdisplayCB func)
{
g_curwin->display = func;
}
void APIENTRY glutReshapeFunc (GLUTreshapeCB func)
{
g_curwin->reshape = func;
}
void APIENTRY glutKeyboardFunc (GLUTkeyboardCB func)
{
g_curwin->keyboard = func;
}
void APIENTRY glutMouseFunc (GLUTmouseCB func)
{
g_curwin->mouse = func;
}
void APIENTRY glutMotionFunc (GLUTmotionCB func)
{
g_curwin->motion = func;
}
void APIENTRY glutPassiveMotionFunc (GLUTpassiveCB func)
{
g_curwin->passive = func;
}
void APIENTRY glutEntryFunc (GLUTentryCB func)
{
g_curwin->entry = func;
}
void APIENTRY glutVisibilityFunc (GLUTvisibilityCB func)
{
g_curwin->visibility = func;
}
void APIENTRY glutWindowStatusFunc (GLUTwindowStatusCB func)
{
}
void APIENTRY glutIdleFunc (GLUTidleCB func)
{
g_idle_func = func;
}
void APIENTRY glutTimerFunc (unsigned int millis, GLUTtimerCB func, int value)
{
}
void APIENTRY glutSpecialFunc (GLUTspecialCB func)
{
g_curwin->special = func;
}
void APIENTRY glutSpaceballMotionFunc (GLUTspaceMotionCB func)
{
}
void APIENTRY glutSpaceballRotateFunc (GLUTspaceRotateCB func)
{
}
void APIENTRY glutSpaceballButtonFunc (GLUTspaceButtonCB func)
{
}
void APIENTRY glutDialsFunc (GLUTdialsCB func)
{
}
void APIENTRY glutButtonBoxFunc (GLUTbuttonBoxCB func)
{
}
void APIENTRY glutTabletMotionFunc (GLUTtabletMotionCB func)
{
}
void APIENTRY glutTabletButtonFunc (GLUTtabletButtonCB func)
{
}
void APIENTRY glutJoystickFunc (GLUTjoystickCB func, int interval)
{
}

View file

@ -1,59 +1,59 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
#include "GL/dmesa.h"
#define CLAMP(i) ((i) > 1.0 ? 1.0 : ((i) < 0.0 ? 0.0 : (i)))
void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)
{
if (g_display_mode & GLUT_INDEX) {
if ((ndx >= 0) && (ndx < (256 - RESERVED_COLORS))) {
DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue));
}
}
}
GLfloat APIENTRY glutGetColor (int ndx, int component)
{
return 0.0;
}
void APIENTRY glutCopyColormap (int win)
{
}
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
#include "GL/dmesa.h"
#define CLAMP(i) ((i) > 1.0 ? 1.0 : ((i) < 0.0 ? 0.0 : (i)))
void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)
{
if (g_display_mode & GLUT_INDEX) {
if ((ndx >= 0) && (ndx < (256 - RESERVED_COLORS))) {
DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue));
}
}
}
GLfloat APIENTRY glutGetColor (int ndx, int component)
{
return 0.0;
}
void APIENTRY glutCopyColormap (int win)
{
}

View file

@ -1,63 +1,63 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <string.h>
#include "GL/glut.h"
int APIENTRY glutExtensionSupported (const char *extension)
{
static const GLubyte *extensions = NULL;
const GLubyte *last, *where;
/* Extension names should not have spaces. */
if (strchr(extension, ' ') || *extension == '\0') {
return GL_FALSE;
}
/* Not my problem if you don't have a valid OpenGL context */
if (!extensions) {
extensions = glGetString(GL_EXTENSIONS);
}
/* Take care of sub-strings etc. */
for (last = extensions;;) {
if ((where = (GLubyte *)strstr((const char *)last, extension)) == NULL) {
return GL_FALSE;
}
last = where + strlen(extension);
if (where == extensions || *(where - 1) == ' ') {
if (*last == ' ' || *last == '\0') {
return GL_TRUE;
}
}
}
}
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <string.h>
#include "GL/glut.h"
int APIENTRY glutExtensionSupported (const char *extension)
{
static const GLubyte *extensions = NULL;
const GLubyte *last, *where;
/* Extension names should not have spaces. */
if (strchr(extension, ' ') || *extension == '\0') {
return GL_FALSE;
}
/* Not my problem if you don't have a valid OpenGL context */
if (!extensions) {
extensions = glGetString(GL_EXTENSIONS);
}
/* Take care of sub-strings etc. */
for (last = extensions;;) {
if ((where = (GLubyte *)strstr((const char *)last, extension)) == NULL) {
return GL_FALSE;
}
last = where + strlen(extension);
if (where == extensions || *(where - 1) == ' ') {
if (*last == ' ' || *last == '\0') {
return GL_TRUE;
}
}
}
}

View file

@ -1,150 +1,150 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef __glutint_h__
#define __glutint_h__
#include <GL/glut.h>
#include "GL/dmesa.h"
/* GLUT function types */
typedef void (GLUTCALLBACK *GLUTdisplayCB) (void);
typedef void (GLUTCALLBACK *GLUTreshapeCB) (int, int);
typedef void (GLUTCALLBACK *GLUTkeyboardCB) (unsigned char, int, int);
typedef void (GLUTCALLBACK *GLUTmouseCB) (int, int, int, int);
typedef void (GLUTCALLBACK *GLUTmotionCB) (int, int);
typedef void (GLUTCALLBACK *GLUTpassiveCB) (int, int);
typedef void (GLUTCALLBACK *GLUTentryCB) (int);
typedef void (GLUTCALLBACK *GLUTvisibilityCB) (int);
typedef void (GLUTCALLBACK *GLUTwindowStatusCB) (int);
typedef void (GLUTCALLBACK *GLUTidleCB) (void);
typedef void (GLUTCALLBACK *GLUTtimerCB) (int);
typedef void (GLUTCALLBACK *GLUTmenuStateCB) (int); /* DEPRECATED. */
typedef void (GLUTCALLBACK *GLUTmenuStatusCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTselectCB) (int);
typedef void (GLUTCALLBACK *GLUTspecialCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceMotionCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceRotateCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceButtonCB) (int, int);
typedef void (GLUTCALLBACK *GLUTdialsCB) (int, int);
typedef void (GLUTCALLBACK *GLUTbuttonBoxCB) (int, int);
typedef void (GLUTCALLBACK *GLUTtabletMotionCB) (int, int);
typedef void (GLUTCALLBACK *GLUTtabletButtonCB) (int, int, int, int);
typedef void (GLUTCALLBACK *GLUTjoystickCB) (unsigned int, int, int, int);
typedef struct GLUTwindow {
int num; /* window id */
DMesaBuffer buffer;
int show_mouse;
/* GLUT settable or visible window state. */
int xpos;
int ypos;
int width; /* window width in pixels */
int height; /* window height in pixels */
/* Per-window callbacks. */
GLUTdisplayCB display; /* redraw */
GLUTreshapeCB reshape; /* resize (width,height) */
GLUTmouseCB mouse; /* mouse (button,state,x,y) */
GLUTmotionCB motion; /* motion (x,y) */
GLUTpassiveCB passive; /* passive motion (x,y) */
GLUTentryCB entry; /* window entry/exit (state) */
GLUTkeyboardCB keyboard; /* keyboard (ASCII,x,y) */
GLUTkeyboardCB keyboardUp; /* keyboard up (ASCII,x,y) */
GLUTwindowStatusCB windowStatus; /* window status */
GLUTvisibilityCB visibility; /* visibility */
GLUTspecialCB special; /* special key */
GLUTspecialCB specialUp; /* special up key */
GLUTbuttonBoxCB buttonBox; /* button box */
GLUTdialsCB dials; /* dials */
GLUTspaceMotionCB spaceMotion; /* Spaceball motion */
GLUTspaceRotateCB spaceRotate; /* Spaceball rotate */
GLUTspaceButtonCB spaceButton; /* Spaceball button */
GLUTtabletMotionCB tabletMotion; /* tablet motion */
GLUTtabletButtonCB tabletButton; /* tablet button */
GLUTjoystickCB joystick; /* joystick */
} GLUTwindow;
extern GLUTidleCB g_idle_func;
extern GLUTmenuStatusCB g_menu_status_func;
extern GLboolean g_redisplay;
extern GLuint g_bpp; /* HW: bits per pixel */
extern GLuint g_refresh; /* HW: vertical refresh rate */
extern GLuint g_screen_w, g_screen_h; /* HW: physical screen size */
extern GLint g_driver_caps;
extern GLuint g_fps;
extern GLuint g_display_mode; /* display bits */
extern int g_init_x, g_init_y; /* initial window position */
extern GLuint g_init_w, g_init_h; /* initial window size */
extern int g_mouse; /* non-zero if mouse installed */
extern int g_mouse_x, g_mouse_y; /* mouse coords, relative to current win */
extern GLUTwindow *g_curwin; /* current window */
extern char *__glutProgramName; /* program name */
extern void __glutInitMouse (void);
/* private routines from glut_util.c */
extern char * __glutStrdup(const char *string);
extern void __glutWarning(char *format,...);
extern void __glutFatalError(char *format,...);
extern void __glutFatalUsage(char *format,...);
/* hmmm... */
#include "pc_hw/pc_hw.h"
#define MAX_WINDOWS 2
#define DEFAULT_WIDTH 300
#define DEFAULT_HEIGHT 300
#define DEFAULT_BPP 16
#define DEPTH_SIZE 16
#define STENCIL_SIZE 8
#define ACCUM_SIZE 16
#define RESERVED_COLORS 0
#endif /* __glutint_h__ */
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef __glutint_h__
#define __glutint_h__
#include <GL/glut.h>
#include "GL/dmesa.h"
/* GLUT function types */
typedef void (GLUTCALLBACK *GLUTdisplayCB) (void);
typedef void (GLUTCALLBACK *GLUTreshapeCB) (int, int);
typedef void (GLUTCALLBACK *GLUTkeyboardCB) (unsigned char, int, int);
typedef void (GLUTCALLBACK *GLUTmouseCB) (int, int, int, int);
typedef void (GLUTCALLBACK *GLUTmotionCB) (int, int);
typedef void (GLUTCALLBACK *GLUTpassiveCB) (int, int);
typedef void (GLUTCALLBACK *GLUTentryCB) (int);
typedef void (GLUTCALLBACK *GLUTvisibilityCB) (int);
typedef void (GLUTCALLBACK *GLUTwindowStatusCB) (int);
typedef void (GLUTCALLBACK *GLUTidleCB) (void);
typedef void (GLUTCALLBACK *GLUTtimerCB) (int);
typedef void (GLUTCALLBACK *GLUTmenuStateCB) (int); /* DEPRECATED. */
typedef void (GLUTCALLBACK *GLUTmenuStatusCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTselectCB) (int);
typedef void (GLUTCALLBACK *GLUTspecialCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceMotionCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceRotateCB) (int, int, int);
typedef void (GLUTCALLBACK *GLUTspaceButtonCB) (int, int);
typedef void (GLUTCALLBACK *GLUTdialsCB) (int, int);
typedef void (GLUTCALLBACK *GLUTbuttonBoxCB) (int, int);
typedef void (GLUTCALLBACK *GLUTtabletMotionCB) (int, int);
typedef void (GLUTCALLBACK *GLUTtabletButtonCB) (int, int, int, int);
typedef void (GLUTCALLBACK *GLUTjoystickCB) (unsigned int, int, int, int);
typedef struct GLUTwindow {
int num; /* window id */
DMesaBuffer buffer;
int show_mouse;
/* GLUT settable or visible window state. */
int xpos;
int ypos;
int width; /* window width in pixels */
int height; /* window height in pixels */
/* Per-window callbacks. */
GLUTdisplayCB display; /* redraw */
GLUTreshapeCB reshape; /* resize (width,height) */
GLUTmouseCB mouse; /* mouse (button,state,x,y) */
GLUTmotionCB motion; /* motion (x,y) */
GLUTpassiveCB passive; /* passive motion (x,y) */
GLUTentryCB entry; /* window entry/exit (state) */
GLUTkeyboardCB keyboard; /* keyboard (ASCII,x,y) */
GLUTkeyboardCB keyboardUp; /* keyboard up (ASCII,x,y) */
GLUTwindowStatusCB windowStatus; /* window status */
GLUTvisibilityCB visibility; /* visibility */
GLUTspecialCB special; /* special key */
GLUTspecialCB specialUp; /* special up key */
GLUTbuttonBoxCB buttonBox; /* button box */
GLUTdialsCB dials; /* dials */
GLUTspaceMotionCB spaceMotion; /* Spaceball motion */
GLUTspaceRotateCB spaceRotate; /* Spaceball rotate */
GLUTspaceButtonCB spaceButton; /* Spaceball button */
GLUTtabletMotionCB tabletMotion; /* tablet motion */
GLUTtabletButtonCB tabletButton; /* tablet button */
GLUTjoystickCB joystick; /* joystick */
} GLUTwindow;
extern GLUTidleCB g_idle_func;
extern GLUTmenuStatusCB g_menu_status_func;
extern GLboolean g_redisplay;
extern GLuint g_bpp; /* HW: bits per pixel */
extern GLuint g_refresh; /* HW: vertical refresh rate */
extern GLuint g_screen_w, g_screen_h; /* HW: physical screen size */
extern GLint g_driver_caps;
extern GLuint g_fps;
extern GLuint g_display_mode; /* display bits */
extern int g_init_x, g_init_y; /* initial window position */
extern GLuint g_init_w, g_init_h; /* initial window size */
extern int g_mouse; /* non-zero if mouse installed */
extern int g_mouse_x, g_mouse_y; /* mouse coords, relative to current win */
extern GLUTwindow *g_curwin; /* current window */
extern char *__glutProgramName; /* program name */
extern void __glutInitMouse (void);
/* private routines from glut_util.c */
extern char * __glutStrdup(const char *string);
extern void __glutWarning(char *format,...);
extern void __glutFatalError(char *format,...);
extern void __glutFatalUsage(char *format,...);
/* hmmm... */
#include "pc_hw/pc_hw.h"
#define MAX_WINDOWS 2
#define DEFAULT_WIDTH 300
#define DEFAULT_HEIGHT 300
#define DEFAULT_BPP 16
#define DEPTH_SIZE 16
#define STENCIL_SIZE 8
#define ACCUM_SIZE 16
#define RESERVED_COLORS 0
#endif /* __glutint_h__ */

View file

@ -1,254 +1,254 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <string.h>
#include "glutint.h"
GLboolean g_redisplay = GL_FALSE;
GLuint g_bpp = DEFAULT_BPP;
GLuint g_refresh = 0;
GLuint g_screen_w, g_screen_h;
GLint g_driver_caps;
GLuint g_fps = 0;
GLuint g_display_mode = 0;
int g_init_x = 0, g_init_y = 0;
GLuint g_init_w = DEFAULT_WIDTH, g_init_h = DEFAULT_HEIGHT;
char *__glutProgramName = NULL;
void APIENTRY glutInit (int *argc, char **argv)
{
char *str;
const char *env;
if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {
g_bpp = atoi(env);
}
if ((env = getenv("DMESA_GLUT_REFRESH")) != NULL) {
g_refresh = atoi(env);
}
/* Determine program name. */
str = strrchr(argv[0], '/');
if (str == NULL) {
str = argv[0];
} else {
str++;
}
__glutProgramName = __glutStrdup(str);
/* check if GLUT_FPS env var is set */
if ((env = getenv("GLUT_FPS")) != NULL) {
if ((g_fps = atoi(env)) <= 0) {
g_fps = 5000; /* 5000 milliseconds */
}
}
/* Initialize timer */
glutGet(GLUT_ELAPSED_TIME);
}
void APIENTRY glutInitDisplayMode (unsigned int mode)
{
g_display_mode = mode;
}
void APIENTRY glutInitWindowPosition (int x, int y)
{
g_init_x = x;
g_init_y = y;
}
void APIENTRY glutInitWindowSize (int width, int height)
{
g_init_w = width;
g_init_h = height;
}
void APIENTRY glutMainLoop (void)
{
GLboolean idle;
static int old_mouse_x = 0;
static int old_mouse_y = 0;
static int old_mouse_b = 0;
{
GLint screen_size[2];
DMesaGetIntegerv(DMESA_GET_SCREEN_SIZE, screen_size);
g_screen_w = screen_size[0];
g_screen_h = screen_size[1];
DMesaGetIntegerv(DMESA_GET_DRIVER_CAPS, &g_driver_caps);
}
pc_install_keyb();
__glutInitMouse();
glutPostRedisplay();
if (g_curwin->reshape) {
g_curwin->reshape(g_curwin->width, g_curwin->height);
}
if (g_curwin->visibility) {
g_curwin->visibility(GLUT_VISIBLE);
}
while (GL_TRUE) {
idle = GL_TRUE;
if (g_redisplay && g_curwin->display) {
idle = GL_FALSE;
g_redisplay = GL_FALSE;
if (g_curwin->show_mouse && !(g_display_mode & GLUT_DOUBLE)) {
/* XXX scare mouse */
g_curwin->display();
/* XXX unscare mouse */
} else {
g_curwin->display();
}
}
if (g_mouse) {
int mouse_x;
int mouse_y;
int mouse_z;
int mouse_b;
/* query mouse */
mouse_b = pc_query_mouse(&mouse_x, &mouse_y, &mouse_z);
/* relative to window coordinates */
g_mouse_x = mouse_x - g_curwin->xpos;
g_mouse_y = mouse_y - g_curwin->ypos;
/* mouse was moved? */
if ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y)) {
idle = GL_FALSE;
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
if (mouse_b) {
/* any button pressed */
if (g_curwin->motion) {
g_curwin->motion(g_mouse_x, g_mouse_y);
}
} else {
/* no button pressed */
if (g_curwin->passive) {
g_curwin->passive(g_mouse_x, g_mouse_y);
}
}
}
/* button state changed? */
if (mouse_b != old_mouse_b) {
GLUTmouseCB mouse_func;
if ((mouse_func = g_curwin->mouse)) {
if ((old_mouse_b & 1) && !(mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
else if (!(old_mouse_b & 1) && (mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
if ((old_mouse_b & 2) && !(mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
else if (!(old_mouse_b & 2) && (mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
if ((old_mouse_b & 4) && !(mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
else if (!(old_mouse_b & 3) && (mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
}
idle = GL_FALSE;
old_mouse_b = mouse_b;
}
}
if (pc_keypressed()) {
int key;
int glut_key;
idle = GL_FALSE;
key = pc_readkey();
switch (key>>16) {
case KEY_F1: glut_key = GLUT_KEY_F1; goto special;
case KEY_F2: glut_key = GLUT_KEY_F2; goto special;
case KEY_F3: glut_key = GLUT_KEY_F3; goto special;
case KEY_F4: glut_key = GLUT_KEY_F4; goto special;
case KEY_F5: glut_key = GLUT_KEY_F5; goto special;
case KEY_F6: glut_key = GLUT_KEY_F6; goto special;
case KEY_F7: glut_key = GLUT_KEY_F7; goto special;
case KEY_F8: glut_key = GLUT_KEY_F8; goto special;
case KEY_F9: glut_key = GLUT_KEY_F9; goto special;
case KEY_F10: glut_key = GLUT_KEY_F10; goto special;
case KEY_F11: glut_key = GLUT_KEY_F11; goto special;
case KEY_F12: glut_key = GLUT_KEY_F12; goto special;
case KEY_LEFT: glut_key = GLUT_KEY_LEFT; goto special;
case KEY_UP: glut_key = GLUT_KEY_UP; goto special;
case KEY_RIGHT: glut_key = GLUT_KEY_RIGHT; goto special;
case KEY_DOWN: glut_key = GLUT_KEY_DOWN; goto special;
case KEY_PGUP: glut_key = GLUT_KEY_PAGE_UP; goto special;
case KEY_PGDN: glut_key = GLUT_KEY_PAGE_DOWN; goto special;
case KEY_HOME: glut_key = GLUT_KEY_HOME; goto special;
case KEY_END: glut_key = GLUT_KEY_END; goto special;
case KEY_INSERT: glut_key = GLUT_KEY_INSERT; goto special;
special:
if (g_curwin->special) {
g_curwin->special(glut_key, g_mouse_x, g_mouse_y);
}
break;
default:
if (g_curwin->keyboard) {
g_curwin->keyboard(key & 0xFF, g_mouse_x, g_mouse_y);
}
}
}
if (idle && g_idle_func)
g_idle_func();
}
}
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <string.h>
#include "glutint.h"
GLboolean g_redisplay = GL_FALSE;
GLuint g_bpp = DEFAULT_BPP;
GLuint g_refresh = 0;
GLuint g_screen_w, g_screen_h;
GLint g_driver_caps;
GLuint g_fps = 0;
GLuint g_display_mode = 0;
int g_init_x = 0, g_init_y = 0;
GLuint g_init_w = DEFAULT_WIDTH, g_init_h = DEFAULT_HEIGHT;
char *__glutProgramName = NULL;
void APIENTRY glutInit (int *argc, char **argv)
{
char *str;
const char *env;
if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {
g_bpp = atoi(env);
}
if ((env = getenv("DMESA_GLUT_REFRESH")) != NULL) {
g_refresh = atoi(env);
}
/* Determine program name. */
str = strrchr(argv[0], '/');
if (str == NULL) {
str = argv[0];
} else {
str++;
}
__glutProgramName = __glutStrdup(str);
/* check if GLUT_FPS env var is set */
if ((env = getenv("GLUT_FPS")) != NULL) {
if ((g_fps = atoi(env)) <= 0) {
g_fps = 5000; /* 5000 milliseconds */
}
}
/* Initialize timer */
glutGet(GLUT_ELAPSED_TIME);
}
void APIENTRY glutInitDisplayMode (unsigned int mode)
{
g_display_mode = mode;
}
void APIENTRY glutInitWindowPosition (int x, int y)
{
g_init_x = x;
g_init_y = y;
}
void APIENTRY glutInitWindowSize (int width, int height)
{
g_init_w = width;
g_init_h = height;
}
void APIENTRY glutMainLoop (void)
{
GLboolean idle;
static int old_mouse_x = 0;
static int old_mouse_y = 0;
static int old_mouse_b = 0;
{
GLint screen_size[2];
DMesaGetIntegerv(DMESA_GET_SCREEN_SIZE, screen_size);
g_screen_w = screen_size[0];
g_screen_h = screen_size[1];
DMesaGetIntegerv(DMESA_GET_DRIVER_CAPS, &g_driver_caps);
}
pc_install_keyb();
__glutInitMouse();
glutPostRedisplay();
if (g_curwin->reshape) {
g_curwin->reshape(g_curwin->width, g_curwin->height);
}
if (g_curwin->visibility) {
g_curwin->visibility(GLUT_VISIBLE);
}
while (GL_TRUE) {
idle = GL_TRUE;
if (g_redisplay && g_curwin->display) {
idle = GL_FALSE;
g_redisplay = GL_FALSE;
if (g_curwin->show_mouse && !(g_display_mode & GLUT_DOUBLE)) {
/* XXX scare mouse */
g_curwin->display();
/* XXX unscare mouse */
} else {
g_curwin->display();
}
}
if (g_mouse) {
int mouse_x;
int mouse_y;
int mouse_z;
int mouse_b;
/* query mouse */
mouse_b = pc_query_mouse(&mouse_x, &mouse_y, &mouse_z);
/* relative to window coordinates */
g_mouse_x = mouse_x - g_curwin->xpos;
g_mouse_y = mouse_y - g_curwin->ypos;
/* mouse was moved? */
if ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y)) {
idle = GL_FALSE;
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
if (mouse_b) {
/* any button pressed */
if (g_curwin->motion) {
g_curwin->motion(g_mouse_x, g_mouse_y);
}
} else {
/* no button pressed */
if (g_curwin->passive) {
g_curwin->passive(g_mouse_x, g_mouse_y);
}
}
}
/* button state changed? */
if (mouse_b != old_mouse_b) {
GLUTmouseCB mouse_func;
if ((mouse_func = g_curwin->mouse)) {
if ((old_mouse_b & 1) && !(mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
else if (!(old_mouse_b & 1) && (mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
if ((old_mouse_b & 2) && !(mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
else if (!(old_mouse_b & 2) && (mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
if ((old_mouse_b & 4) && !(mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
else if (!(old_mouse_b & 3) && (mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
}
idle = GL_FALSE;
old_mouse_b = mouse_b;
}
}
if (pc_keypressed()) {
int key;
int glut_key;
idle = GL_FALSE;
key = pc_readkey();
switch (key>>16) {
case KEY_F1: glut_key = GLUT_KEY_F1; goto special;
case KEY_F2: glut_key = GLUT_KEY_F2; goto special;
case KEY_F3: glut_key = GLUT_KEY_F3; goto special;
case KEY_F4: glut_key = GLUT_KEY_F4; goto special;
case KEY_F5: glut_key = GLUT_KEY_F5; goto special;
case KEY_F6: glut_key = GLUT_KEY_F6; goto special;
case KEY_F7: glut_key = GLUT_KEY_F7; goto special;
case KEY_F8: glut_key = GLUT_KEY_F8; goto special;
case KEY_F9: glut_key = GLUT_KEY_F9; goto special;
case KEY_F10: glut_key = GLUT_KEY_F10; goto special;
case KEY_F11: glut_key = GLUT_KEY_F11; goto special;
case KEY_F12: glut_key = GLUT_KEY_F12; goto special;
case KEY_LEFT: glut_key = GLUT_KEY_LEFT; goto special;
case KEY_UP: glut_key = GLUT_KEY_UP; goto special;
case KEY_RIGHT: glut_key = GLUT_KEY_RIGHT; goto special;
case KEY_DOWN: glut_key = GLUT_KEY_DOWN; goto special;
case KEY_PGUP: glut_key = GLUT_KEY_PAGE_UP; goto special;
case KEY_PGDN: glut_key = GLUT_KEY_PAGE_DOWN; goto special;
case KEY_HOME: glut_key = GLUT_KEY_HOME; goto special;
case KEY_END: glut_key = GLUT_KEY_END; goto special;
case KEY_INSERT: glut_key = GLUT_KEY_INSERT; goto special;
special:
if (g_curwin->special) {
g_curwin->special(glut_key, g_mouse_x, g_mouse_y);
}
break;
default:
if (g_curwin->keyboard) {
g_curwin->keyboard(key & 0xFF, g_mouse_x, g_mouse_y);
}
}
}
if (idle && g_idle_func)
g_idle_func();
}
}

View file

@ -1,116 +1,116 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
GLUTmenuStatusCB g_menu_status_func = NULL;
void APIENTRY glutMenuStateFunc (GLUTmenuStateCB func)
{
g_menu_status_func = (GLUTmenuStatusCB)func;
}
void APIENTRY glutMenuStatusFunc (GLUTmenuStatusCB func)
{
g_menu_status_func = func;
}
int APIENTRY glutCreateMenu (GLUTselectCB func)
{
return 0;
}
void APIENTRY glutDestroyMenu (int menu)
{
}
int APIENTRY glutGetMenu (void)
{
return 0;
}
void APIENTRY glutSetMenu (int menu)
{
}
void APIENTRY glutAddMenuEntry (const char *label, int value)
{
}
void APIENTRY glutAddSubMenu (const char *label, int submenu)
{
}
void APIENTRY glutChangeToMenuEntry (int item, const char *label, int value)
{
}
void APIENTRY glutChangeToSubMenu (int item, const char *label, int submenu)
{
}
void APIENTRY glutRemoveMenuItem (int item)
{
}
void APIENTRY glutAttachMenu (int button)
{
}
void APIENTRY glutDetachMenu (int button)
{
}
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
GLUTmenuStatusCB g_menu_status_func = NULL;
void APIENTRY glutMenuStateFunc (GLUTmenuStateCB func)
{
g_menu_status_func = (GLUTmenuStatusCB)func;
}
void APIENTRY glutMenuStatusFunc (GLUTmenuStatusCB func)
{
g_menu_status_func = func;
}
int APIENTRY glutCreateMenu (GLUTselectCB func)
{
return 0;
}
void APIENTRY glutDestroyMenu (int menu)
{
}
int APIENTRY glutGetMenu (void)
{
return 0;
}
void APIENTRY glutSetMenu (int menu)
{
}
void APIENTRY glutAddMenuEntry (const char *label, int value)
{
}
void APIENTRY glutAddSubMenu (const char *label, int submenu)
{
}
void APIENTRY glutChangeToMenuEntry (int item, const char *label, int value)
{
}
void APIENTRY glutChangeToSubMenu (int item, const char *label, int submenu)
{
}
void APIENTRY glutRemoveMenuItem (int item)
{
}
void APIENTRY glutAttachMenu (int button)
{
}
void APIENTRY glutDetachMenu (int button)
{
}

View file

@ -1,60 +1,60 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
int g_mouse;
int g_mouse_x = 0, g_mouse_y = 0;
void __glutInitMouse (void)
{
if ((g_mouse = pc_install_mouse())) {
pc_mouse_area(g_curwin->xpos, g_curwin->ypos, g_curwin->xpos + g_curwin->width - 1, g_curwin->ypos + g_curwin->height - 1);
g_curwin->show_mouse = (g_curwin->mouse || g_curwin->motion || g_curwin->passive);
}
}
void APIENTRY glutSetCursor (int cursor)
{
/* XXX completely futile until full mouse support (maybe never) */
}
void APIENTRY glutWarpPointer (int x, int y)
{
pc_warp_mouse(x, y);
}
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
int g_mouse;
int g_mouse_x = 0, g_mouse_y = 0;
void __glutInitMouse (void)
{
if ((g_mouse = pc_install_mouse())) {
pc_mouse_area(g_curwin->xpos, g_curwin->ypos, g_curwin->xpos + g_curwin->width - 1, g_curwin->ypos + g_curwin->height - 1);
g_curwin->show_mouse = (g_curwin->mouse || g_curwin->motion || g_curwin->passive);
}
}
void APIENTRY glutSetCursor (int cursor)
{
/* XXX completely futile until full mouse support (maybe never) */
}
void APIENTRY glutWarpPointer (int x, int y)
{
pc_warp_mouse(x, y);
}

View file

@ -1,91 +1,91 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
int APIENTRY glutLayerGet (GLenum info)
{
switch (info) {
case GLUT_OVERLAY_POSSIBLE:
case GLUT_HAS_OVERLAY:
return GL_FALSE;
case GLUT_LAYER_IN_USE:
return GLUT_NORMAL;
case GLUT_NORMAL_DAMAGED:
return GL_FALSE;
case GLUT_OVERLAY_DAMAGED:
case GLUT_TRANSPARENT_INDEX:
default:
return -1;
}
}
void APIENTRY glutOverlayDisplayFunc (GLUTdisplayCB func)
{
}
void APIENTRY glutEstablishOverlay (void)
{
}
void APIENTRY glutRemoveOverlay (void)
{
}
void APIENTRY glutUseLayer (GLenum layer)
{
}
void APIENTRY glutPostOverlayRedisplay (void)
{
}
void APIENTRY glutShowOverlay (void)
{
}
void APIENTRY glutHideOverlay (void)
{
}
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
int APIENTRY glutLayerGet (GLenum info)
{
switch (info) {
case GLUT_OVERLAY_POSSIBLE:
case GLUT_HAS_OVERLAY:
return GL_FALSE;
case GLUT_LAYER_IN_USE:
return GLUT_NORMAL;
case GLUT_NORMAL_DAMAGED:
return GL_FALSE;
case GLUT_OVERLAY_DAMAGED:
case GLUT_TRANSPARENT_INDEX:
default:
return -1;
}
}
void APIENTRY glutOverlayDisplayFunc (GLUTdisplayCB func)
{
}
void APIENTRY glutEstablishOverlay (void)
{
}
void APIENTRY glutRemoveOverlay (void)
{
}
void APIENTRY glutUseLayer (GLenum layer)
{
}
void APIENTRY glutPostOverlayRedisplay (void)
{
}
void APIENTRY glutShowOverlay (void)
{
}
void APIENTRY glutHideOverlay (void)
{
}

View file

@ -1,142 +1,142 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
#define FREQUENCY 100
static int timer_installed;
static volatile int ticks;
static void ticks_timer (void *p)
{
(void)p;
ticks++;
} ENDOFUNC(ticks_timer)
int APIENTRY glutGet (GLenum type)
{
switch (type) {
case GLUT_WINDOW_X:
return g_curwin->xpos;
case GLUT_WINDOW_Y:
return g_curwin->ypos;
case GLUT_WINDOW_WIDTH:
return g_curwin->width;
case GLUT_WINDOW_HEIGHT:
return g_curwin->height;
case GLUT_WINDOW_STENCIL_SIZE:
return STENCIL_SIZE;
case GLUT_WINDOW_DEPTH_SIZE:
return DEPTH_SIZE;
case GLUT_WINDOW_RGBA:
return !(g_display_mode & GLUT_INDEX);
case GLUT_WINDOW_COLORMAP_SIZE:
return (g_display_mode & GLUT_INDEX) ? (256 - RESERVED_COLORS) : 0;
case GLUT_SCREEN_WIDTH:
return g_screen_w;
case GLUT_SCREEN_HEIGHT:
return g_screen_h;
case GLUT_INIT_WINDOW_X:
return g_init_x;
case GLUT_INIT_WINDOW_Y:
return g_init_y;
case GLUT_INIT_WINDOW_WIDTH:
return g_init_w;
case GLUT_INIT_WINDOW_HEIGHT:
return g_init_h;
case GLUT_INIT_DISPLAY_MODE:
return g_display_mode;
case GLUT_ELAPSED_TIME:
if (!timer_installed) {
timer_installed = GL_TRUE;
LOCKDATA(ticks);
LOCKFUNC(ticks_timer);
pc_install_int(ticks_timer, NULL, FREQUENCY);
}
return ticks*1000/FREQUENCY;
default:
return -1;
}
}
int APIENTRY glutDeviceGet (GLenum type)
{
switch (type) {
case GLUT_HAS_KEYBOARD:
return GL_TRUE;
case GLUT_HAS_MOUSE:
return (g_mouse != 0);
case GLUT_NUM_MOUSE_BUTTONS:
return g_mouse;
case GLUT_HAS_SPACEBALL:
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
case GLUT_HAS_TABLET:
return GL_FALSE;
case GLUT_NUM_SPACEBALL_BUTTONS:
case GLUT_NUM_BUTTON_BOX_BUTTONS:
case GLUT_NUM_DIALS:
case GLUT_NUM_TABLET_BUTTONS:
return 0;
default:
return -1;
}
}
int APIENTRY glutGetModifiers (void)
{
int mod = 0;
int shifts = pc_keyshifts();
if (shifts & (KB_SHIFT_FLAG | KB_CAPSLOCK_FLAG)) {
mod |= GLUT_ACTIVE_SHIFT;
}
if (shifts & KB_ALT_FLAG) {
mod |= GLUT_ACTIVE_ALT;
}
if (shifts & KB_CTRL_FLAG) {
mod |= GLUT_ACTIVE_CTRL;
}
return mod;
}
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "glutint.h"
#define FREQUENCY 100
static int timer_installed;
static volatile int ticks;
static void ticks_timer (void *p)
{
(void)p;
ticks++;
} ENDOFUNC(ticks_timer)
int APIENTRY glutGet (GLenum type)
{
switch (type) {
case GLUT_WINDOW_X:
return g_curwin->xpos;
case GLUT_WINDOW_Y:
return g_curwin->ypos;
case GLUT_WINDOW_WIDTH:
return g_curwin->width;
case GLUT_WINDOW_HEIGHT:
return g_curwin->height;
case GLUT_WINDOW_STENCIL_SIZE:
return STENCIL_SIZE;
case GLUT_WINDOW_DEPTH_SIZE:
return DEPTH_SIZE;
case GLUT_WINDOW_RGBA:
return !(g_display_mode & GLUT_INDEX);
case GLUT_WINDOW_COLORMAP_SIZE:
return (g_display_mode & GLUT_INDEX) ? (256 - RESERVED_COLORS) : 0;
case GLUT_SCREEN_WIDTH:
return g_screen_w;
case GLUT_SCREEN_HEIGHT:
return g_screen_h;
case GLUT_INIT_WINDOW_X:
return g_init_x;
case GLUT_INIT_WINDOW_Y:
return g_init_y;
case GLUT_INIT_WINDOW_WIDTH:
return g_init_w;
case GLUT_INIT_WINDOW_HEIGHT:
return g_init_h;
case GLUT_INIT_DISPLAY_MODE:
return g_display_mode;
case GLUT_ELAPSED_TIME:
if (!timer_installed) {
timer_installed = GL_TRUE;
LOCKDATA(ticks);
LOCKFUNC(ticks_timer);
pc_install_int(ticks_timer, NULL, FREQUENCY);
}
return ticks*1000/FREQUENCY;
default:
return -1;
}
}
int APIENTRY glutDeviceGet (GLenum type)
{
switch (type) {
case GLUT_HAS_KEYBOARD:
return GL_TRUE;
case GLUT_HAS_MOUSE:
return (g_mouse != 0);
case GLUT_NUM_MOUSE_BUTTONS:
return g_mouse;
case GLUT_HAS_SPACEBALL:
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
case GLUT_HAS_TABLET:
return GL_FALSE;
case GLUT_NUM_SPACEBALL_BUTTONS:
case GLUT_NUM_BUTTON_BOX_BUTTONS:
case GLUT_NUM_DIALS:
case GLUT_NUM_TABLET_BUTTONS:
return 0;
default:
return -1;
}
}
int APIENTRY glutGetModifiers (void)
{
int mod = 0;
int shifts = pc_keyshifts();
if (shifts & (KB_SHIFT_FLAG | KB_CAPSLOCK_FLAG)) {
mod |= GLUT_ACTIVE_SHIFT;
}
if (shifts & KB_ALT_FLAG) {
mod |= GLUT_ACTIVE_ALT;
}
if (shifts & KB_CTRL_FLAG) {
mod |= GLUT_ACTIVE_CTRL;
}
return mod;
}

View file

@ -1,260 +1,260 @@
/*
* Mesa 3-D graphics library
* Version: 4.1
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <stdio.h>
#include "glutint.h"
#include "GL/dmesa.h"
GLUTwindow *g_curwin;
static GLuint swaptime, swapcount;
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
static GLUTwindow *windows[MAX_WINDOWS];
static void clean (void)
{
int i;
for (i=1; i<=MAX_WINDOWS; i++) {
glutDestroyWindow(i);
}
if (context) DMesaDestroyContext(context);
if (visual) DMesaDestroyVisual(visual);
pc_close_stdout();
pc_close_stderr();
}
int APIENTRY glutCreateWindow (const char *title)
{
int i;
int m8width = (g_init_w + 7) & ~7;
if (!visual) {
if ((visual=DMesaCreateVisual(g_init_x + m8width, g_init_y + g_init_h, g_bpp, g_refresh,
g_display_mode & GLUT_DOUBLE,
!(g_display_mode & GLUT_INDEX),
g_display_mode & GLUT_ALPHA,
g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,
g_display_mode & GLUT_STENCIL?STENCIL_SIZE:0,
g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
return 0;
}
if ((context=DMesaCreateContext(visual, NULL))==NULL) {
DMesaDestroyVisual(visual);
return 0;
}
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}
for (i=0; i<MAX_WINDOWS; i++) {
if (windows[i] == NULL) {
DMesaBuffer b;
GLUTwindow *w;
if ((w=(GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) {
return 0;
}
if ((b=DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h))==NULL) {
free(w);
return 0;
}
if (!DMesaMakeCurrent(context, b)) {
DMesaDestroyBuffer(b);
free(w);
return 0;
}
g_curwin = windows[i] = w;
w->num = ++i;
w->xpos = g_init_x;
w->ypos = g_init_y;
w->width = m8width;
w->height = g_init_h;
w->buffer = b;
return i;
}
}
return 0;
}
int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
{
return GL_FALSE;
}
void APIENTRY glutDestroyWindow (int win)
{
if (windows[--win]) {
DMesaDestroyBuffer(windows[win]->buffer);
free(windows[win]);
windows[win] = NULL;
}
}
void APIENTRY glutPostRedisplay (void)
{
g_redisplay = GL_TRUE;
}
void APIENTRY glutSwapBuffers (void)
{
if (g_curwin->show_mouse) {
/* XXX scare mouse */
DMesaSwapBuffers(g_curwin->buffer);
/* XXX unscare mouse */
} else {
DMesaSwapBuffers(g_curwin->buffer);
}
if (g_fps) {
GLint t = glutGet(GLUT_ELAPSED_TIME);
swapcount++;
if (swaptime == 0)
swaptime = t;
else if (t - swaptime > g_fps) {
double time = 0.001 * (t - swaptime);
double fps = (double)swapcount / time;
fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n", swapcount, time, fps);
swaptime = t;
swapcount = 0;
}
}
}
int APIENTRY glutGetWindow (void)
{
return g_curwin->num;
}
void APIENTRY glutSetWindow (int win)
{
g_curwin = windows[win - 1];
}
void APIENTRY glutSetWindowTitle (const char *title)
{
}
void APIENTRY glutSetIconTitle (const char *title)
{
}
void APIENTRY glutPositionWindow (int x, int y)
{
if (DMesaMoveBuffer(x, y)) {
g_curwin->xpos = x;
g_curwin->ypos = y;
}
}
void APIENTRY glutReshapeWindow (int width, int height)
{
if (DMesaResizeBuffer(width, height)) {
g_curwin->width = width;
g_curwin->height = height;
if (g_curwin->reshape) {
g_curwin->reshape(width, height);
} else {
glViewport(0, 0, width, height);
}
}
}
void APIENTRY glutFullScreen (void)
{
}
void APIENTRY glutPopWindow (void)
{
}
void APIENTRY glutPushWindow (void)
{
}
void APIENTRY glutIconifyWindow (void)
{
}
void APIENTRY glutShowWindow (void)
{
}
void APIENTRY glutHideWindow (void)
{
}
/*
* Mesa 3-D graphics library
* Version: 4.1
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <stdio.h>
#include "glutint.h"
#include "GL/dmesa.h"
GLUTwindow *g_curwin;
static GLuint swaptime, swapcount;
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
static GLUTwindow *windows[MAX_WINDOWS];
static void clean (void)
{
int i;
for (i=1; i<=MAX_WINDOWS; i++) {
glutDestroyWindow(i);
}
if (context) DMesaDestroyContext(context);
if (visual) DMesaDestroyVisual(visual);
pc_close_stdout();
pc_close_stderr();
}
int APIENTRY glutCreateWindow (const char *title)
{
int i;
int m8width = (g_init_w + 7) & ~7;
if (!visual) {
if ((visual=DMesaCreateVisual(g_init_x + m8width, g_init_y + g_init_h, g_bpp, g_refresh,
g_display_mode & GLUT_DOUBLE,
!(g_display_mode & GLUT_INDEX),
g_display_mode & GLUT_ALPHA,
g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,
g_display_mode & GLUT_STENCIL?STENCIL_SIZE:0,
g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
return 0;
}
if ((context=DMesaCreateContext(visual, NULL))==NULL) {
DMesaDestroyVisual(visual);
return 0;
}
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}
for (i=0; i<MAX_WINDOWS; i++) {
if (windows[i] == NULL) {
DMesaBuffer b;
GLUTwindow *w;
if ((w=(GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) {
return 0;
}
if ((b=DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h))==NULL) {
free(w);
return 0;
}
if (!DMesaMakeCurrent(context, b)) {
DMesaDestroyBuffer(b);
free(w);
return 0;
}
g_curwin = windows[i] = w;
w->num = ++i;
w->xpos = g_init_x;
w->ypos = g_init_y;
w->width = m8width;
w->height = g_init_h;
w->buffer = b;
return i;
}
}
return 0;
}
int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
{
return GL_FALSE;
}
void APIENTRY glutDestroyWindow (int win)
{
if (windows[--win]) {
DMesaDestroyBuffer(windows[win]->buffer);
free(windows[win]);
windows[win] = NULL;
}
}
void APIENTRY glutPostRedisplay (void)
{
g_redisplay = GL_TRUE;
}
void APIENTRY glutSwapBuffers (void)
{
if (g_curwin->show_mouse) {
/* XXX scare mouse */
DMesaSwapBuffers(g_curwin->buffer);
/* XXX unscare mouse */
} else {
DMesaSwapBuffers(g_curwin->buffer);
}
if (g_fps) {
GLint t = glutGet(GLUT_ELAPSED_TIME);
swapcount++;
if (swaptime == 0)
swaptime = t;
else if (t - swaptime > g_fps) {
double time = 0.001 * (t - swaptime);
double fps = (double)swapcount / time;
fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n", swapcount, time, fps);
swaptime = t;
swapcount = 0;
}
}
}
int APIENTRY glutGetWindow (void)
{
return g_curwin->num;
}
void APIENTRY glutSetWindow (int win)
{
g_curwin = windows[win - 1];
}
void APIENTRY glutSetWindowTitle (const char *title)
{
}
void APIENTRY glutSetIconTitle (const char *title)
{
}
void APIENTRY glutPositionWindow (int x, int y)
{
if (DMesaMoveBuffer(x, y)) {
g_curwin->xpos = x;
g_curwin->ypos = y;
}
}
void APIENTRY glutReshapeWindow (int width, int height)
{
if (DMesaResizeBuffer(width, height)) {
g_curwin->width = width;
g_curwin->height = height;
if (g_curwin->reshape) {
g_curwin->reshape(width, height);
} else {
glViewport(0, 0, width, height);
}
}
}
void APIENTRY glutFullScreen (void)
{
}
void APIENTRY glutPopWindow (void)
{
}
void APIENTRY glutPushWindow (void)
{
}
void APIENTRY glutIconifyWindow (void)
{
}
void APIENTRY glutShowWindow (void)
{
}
void APIENTRY glutHideWindow (void)
{
}

View file

@ -1,348 +1,373 @@
# Mesa 3-D graphics library
# Version: 5.1
#
# Copyright (C) 1999-2003 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 core makefile v1.3 for Mesa
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
#
# Available options:
#
# Environment variables:
# CFLAGS
#
# GLIDE path to Glide3 SDK include files; used with FX.
# default = $(TOP)/include/glide3
# FX=1 build for 3dfx Glide3. Note that this disables
# compilation of most DMesa code and requires fxMesa.
# As a consequence, you'll need the DJGPP Glide3
# library to build any application.
# default = no
# MATROX=1 build for Matrox Millennium I (MGA2064W) cards.
# This is experimental and not intensively tested.
# default = no
# HAVE_X86=1 optimize for i386.
# default = no
# HAVE_MMX=1 allow MMX specializations, provided your assembler
# supports MMX instruction set. However, the true CPU
# capabilities are checked at run-time to avoid crashes.
# 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
.INTERMEDIATE: X86/gen_matypes.exe
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.
ifeq ($(FX),1)
CFLAGS += -D__DOS__ -DH3
CFLAGS += -I$(GLIDE) -DFX -DFX_GLIDE3 -DFXMESA_USE_ARGB
LIBNAME = "MesaGL/FX DJGPP"
else
ifeq ($(MATROX),1)
CFLAGS += -DMATROX
LIBNAME = "MesaGL/MGA DJGPP"
else
LIBNAME = "MesaGL DJGPP"
endif
endif
AR = ar
ARFLAGS = rus
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
CORE_SOURCES = \
api_arrayelt.c \
api_loopback.c \
api_noop.c \
api_validate.c \
accum.c \
arbprogram.c \
attrib.c \
blend.c \
bufferobj.c \
buffers.c \
clip.c \
colortab.c \
context.c \
convolve.c \
debug.c \
depth.c \
dispatch.c \
dlist.c \
drawpix.c \
enable.c \
enums.c \
eval.c \
extensions.c \
feedback.c \
fog.c \
get.c \
glapi.c \
glthread.c \
hash.c \
hint.c \
histogram.c \
image.c \
imports.c \
light.c \
lines.c \
matrix.c \
mmath.c \
pixel.c \
points.c \
polygon.c \
rastpos.c \
state.c \
stencil.c \
texcompress.c \
texformat.c \
teximage.c \
texobj.c \
texstate.c \
texstore.c \
texutil.c \
varray.c \
vpexec.c \
vpparse.c \
vpstate.c \
vtxfmt.c \
math/m_debug_clip.c \
math/m_debug_norm.c \
math/m_debug_xform.c \
math/m_eval.c \
math/m_matrix.c \
math/m_translate.c \
math/m_vector.c \
math/m_xform.c \
array_cache/ac_context.c \
array_cache/ac_import.c \
swrast/s_aaline.c \
swrast/s_aatriangle.c \
swrast/s_accum.c \
swrast/s_alpha.c \
swrast/s_alphabuf.c \
swrast/s_bitmap.c \
swrast/s_blend.c \
swrast/s_buffers.c \
swrast/s_copypix.c \
swrast/s_context.c \
swrast/s_depth.c \
swrast/s_drawpix.c \
swrast/s_feedback.c \
swrast/s_fog.c \
swrast/s_histogram.c \
swrast/s_imaging.c \
swrast/s_lines.c \
swrast/s_logic.c \
swrast/s_masking.c \
swrast/s_pixeltex.c \
swrast/s_points.c \
swrast/s_readpix.c \
swrast/s_span.c \
swrast/s_stencil.c \
swrast/s_texture.c \
swrast/s_texstore.c \
swrast/s_triangle.c \
swrast/s_zoom.c \
swrast_setup/ss_context.c \
swrast_setup/ss_triangle.c \
swrast_setup/ss_vb.c \
tnl/t_array_api.c \
tnl/t_array_import.c \
tnl/t_context.c \
tnl/t_eval_api.c \
tnl/t_imm_alloc.c \
tnl/t_imm_api.c \
tnl/t_imm_debug.c \
tnl/t_imm_dlist.c \
tnl/t_imm_elt.c \
tnl/t_imm_eval.c \
tnl/t_imm_exec.c \
tnl/t_imm_fixup.c \
tnl/t_pipeline.c \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
tnl/t_vb_normals.c \
tnl/t_vb_points.c \
tnl/t_vb_program.c \
tnl/t_vb_render.c \
tnl/t_vb_texgen.c \
tnl/t_vb_texmat.c \
tnl/t_vb_vertex.c
X86_SOURCES = \
X86/x86.c \
X86/glapi_x86.S \
X86/common_x86.c \
X86/common_x86_asm.S \
X86/x86_xform2.S \
X86/x86_xform3.S \
X86/x86_xform4.S \
X86/x86_cliptest.S
MMX_SOURCES = \
X86/mmx_blend.S
SSE_SOURCES = \
X86/sse.c \
X86/sse_xform2.S \
X86/sse_xform3.S \
X86/sse_xform4.S \
X86/sse_normal.S
K3D_SOURCES = \
X86/3dnow.c \
X86/3dnow_xform2.S \
X86/3dnow_xform3.S \
X86/3dnow_xform4.S \
X86/3dnow_normal.S
ifeq ($(HAVE_MMX),1)
X86_SOURCES += $(MMX_SOURCES)
CFLAGS += -DUSE_MMX_ASM
HAVE_X86 = 1
endif
ifeq ($(HAVE_SSE),1)
X86_SOURCES += $(SSE_SOURCES)
CFLAGS += -DUSE_SSE_ASM
HAVE_X86 = 1
endif
ifeq ($(HAVE_3DNOW),1)
X86_SOURCES += $(K3D_SOURCES)
CFLAGS += -DUSE_3DNOW_ASM
HAVE_X86 = 1
endif
ifeq ($(HAVE_X86),1)
CFLAGS += -DUSE_X86_ASM
else
X86_SOURCES =
endif
DRIVER_SOURCES = \
DOS/dmesa.c
ifeq ($(FX),1)
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
else
ifeq ($(MATROX),1)
DRIVER_SOURCES += \
DOS/mga/mga.c \
DOS/mga/mga_hw.c \
DOS/mga/mga_mode.c \
DOS/dpmi.c
else
DRIVER_SOURCES += \
DOS/video.c \
DOS/virtual.S \
DOS/vesa.c \
DOS/blit.S \
DOS/vga.c \
DOS/dpmi.c
endif
endif
SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.S.o:
$(CC) -o $@ $(CFLAGS) -c $<
.s.o:
$(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
all: $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP)
$(LIBDIR)/$(GL_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GL_LIB) $(OBJECTS)
$(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GL_DXE))
else
ifeq ($(FX),1)
-dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D $(LIBNAME) -E _gl -E _DMesa -P glid3.dxe -U $(OBJECTS)
else
-dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D $(LIBNAME) -E _gl -E _DMesa -U $(OBJECTS)
endif
endif
$(X86_OBJECTS): X86/matypes.h
X86/matypes.h: X86/gen_matypes.exe
$< > $@
X86/gen_matypes.exe: X86/gen_matypes.c
$(CC) -o $@ $(CFLAGS) -s $<
clean:
-$(call UNLINK,*.o)
-$(call UNLINK,array_cache/*.o)
-$(call UNLINK,math/*.o)
-$(call UNLINK,swrast/*.o)
-$(call UNLINK,swrast_setup/*.o)
-$(call UNLINK,tnl/*.o)
-$(call UNLINK,X86/*.o)
-$(call UNLINK,DOS/*.o)
-$(call UNLINK,DOS/mga/*.o)
-$(call UNLINK,FX/*.o)
-include depend
# Mesa 3-D graphics library
# Version: 5.1
#
# Copyright (C) 1999-2003 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 core makefile v1.4 for Mesa
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
#
# Available options:
#
# Environment variables:
# CFLAGS
#
# GLIDE path to Glide3 SDK include files; used with FX.
# default = $(TOP)/include/glide3
# FX=1 build for 3dfx Glide3. Note that this disables
# compilation of most DMesa code and requires fxMesa.
# As a consequence, you'll need the DJGPP Glide3
# library to build any application.
# default = no
# MATROX=1 build for Matrox Millennium I (MGA2064W) cards.
# This is experimental and not intensively tested.
# default = no
# HAVE_X86=1 optimize for i386.
# default = no
# HAVE_MMX=1 allow MMX specializations, provided your assembler
# supports MMX instruction set. However, the true CPU
# capabilities are checked at run-time to avoid crashes.
# 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
.INTERMEDIATE: x86/gen_matypes.exe
TOP = ../..
GLIDE ?= $(TOP)/include/glide3
LIBDIR = $(TOP)/lib
GL_LIB = libgl.a
GL_DXE = gl.dxe
GL_IMP = libigl.a
export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR)
CC = gcc
CFLAGS += -I$(TOP)/include -I. -Imain -Iglapi
ifeq ($(FX),1)
CFLAGS += -D__DOS__ -DH3
CFLAGS += -I$(GLIDE) -DFX -DFX_GLIDE3 -DFXMESA_USE_ARGB
LIBNAME = "MesaGL/FX DJGPP"
else
ifeq ($(MATROX),1)
CFLAGS += -DMATROX
LIBNAME = "MesaGL/MGA DJGPP"
else
LIBNAME = "MesaGL DJGPP"
endif
endif
AR = ar
ARFLAGS = rus
HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
UNLINK = del $(subst /,\,$(1))
else
UNLINK = $(RM) $(1)
endif
MAIN_SOURCES = \
main/api_arrayelt.c \
main/api_loopback.c \
main/api_noop.c \
main/api_validate.c \
main/accum.c \
main/arbprogram.c \
main/attrib.c \
main/blend.c \
main/bufferobj.c \
main/buffers.c \
main/clip.c \
main/colortab.c \
main/context.c \
main/convolve.c \
main/debug.c \
main/depth.c \
main/dispatch.c \
main/dlist.c \
main/drawpix.c \
main/enable.c \
main/enums.c \
main/eval.c \
main/extensions.c \
main/feedback.c \
main/fog.c \
main/get.c \
main/hash.c \
main/hint.c \
main/histogram.c \
main/image.c \
main/imports.c \
main/light.c \
main/lines.c \
main/matrix.c \
main/nvprogram.c \
main/nvfragparse.c \
main/nvvertexec.c \
main/nvvertparse.c \
main/occlude.c \
main/pixel.c \
main/points.c \
main/polygon.c \
main/rastpos.c \
main/state.c \
main/stencil.c \
main/texcompress.c \
main/texformat.c \
main/teximage.c \
main/texobj.c \
main/texstate.c \
main/texstore.c \
main/texutil.c \
main/varray.c \
main/vtxfmt.c
GLAPI_SOURCES = \
glapi/glapi.c \
glapi/glthread.c
MATH_SOURCES = \
math/m_debug_clip.c \
math/m_debug_norm.c \
math/m_debug_xform.c \
math/m_eval.c \
math/m_matrix.c \
math/m_translate.c \
math/m_vector.c \
math/m_xform.c
ARRAY_CACHE_SOURCES = \
array_cache/ac_context.c \
array_cache/ac_import.c
SWRAST_SOURCES = \
swrast/s_aaline.c \
swrast/s_aatriangle.c \
swrast/s_accum.c \
swrast/s_alpha.c \
swrast/s_alphabuf.c \
swrast/s_bitmap.c \
swrast/s_blend.c \
swrast/s_buffers.c \
swrast/s_copypix.c \
swrast/s_context.c \
swrast/s_depth.c \
swrast/s_drawpix.c \
swrast/s_feedback.c \
swrast/s_fog.c \
swrast/s_imaging.c \
swrast/s_lines.c \
swrast/s_logic.c \
swrast/s_masking.c \
swrast/s_nvfragprog.c \
swrast/s_pixeltex.c \
swrast/s_points.c \
swrast/s_readpix.c \
swrast/s_span.c \
swrast/s_stencil.c \
swrast/s_texture.c \
swrast/s_texstore.c \
swrast/s_triangle.c \
swrast/s_zoom.c
SWRAST_SETUP_SOURCES = \
swrast_setup/ss_context.c \
swrast_setup/ss_triangle.c \
swrast_setup/ss_vb.c
TNL_SOURCES = \
tnl/t_array_api.c \
tnl/t_array_import.c \
tnl/t_context.c \
tnl/t_eval_api.c \
tnl/t_imm_alloc.c \
tnl/t_imm_api.c \
tnl/t_imm_debug.c \
tnl/t_imm_dlist.c \
tnl/t_imm_elt.c \
tnl/t_imm_eval.c \
tnl/t_imm_exec.c \
tnl/t_imm_fixup.c \
tnl/t_pipeline.c \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
tnl/t_vb_normals.c \
tnl/t_vb_points.c \
tnl/t_vb_program.c \
tnl/t_vb_render.c \
tnl/t_vb_texgen.c \
tnl/t_vb_texmat.c \
tnl/t_vb_vertex.c
X86_SOURCES = \
x86/x86.c \
x86/glapi_x86.S \
x86/common_x86.c \
x86/common_x86_asm.S \
x86/x86_xform2.S \
x86/x86_xform3.S \
x86/x86_xform4.S \
x86/x86_cliptest.S
MMX_SOURCES = \
x86/mmx_blend.S
SSE_SOURCES = \
x86/sse.c \
x86/sse_xform2.S \
x86/sse_xform3.S \
x86/sse_xform4.S \
x86/sse_normal.S
K3D_SOURCES = \
x86/3dnow.c \
x86/3dnow_xform2.S \
x86/3dnow_xform3.S \
x86/3dnow_xform4.S \
x86/3dnow_normal.S
CORE_SOURCES = \
$(MAIN_SOURCES) \
$(GLAPI_SOURCES) \
$(MATH_SOURCES) \
$(ARRAY_CACHE_SOURCES) \
$(SWRAST_SOURCES) \
$(SWRAST_SETUP_SOURCES) \
$(TNL_SOURCES)
ifeq ($(HAVE_MMX),1)
X86_SOURCES += $(MMX_SOURCES)
CFLAGS += -DUSE_MMX_ASM
HAVE_X86 = 1
endif
ifeq ($(HAVE_SSE),1)
X86_SOURCES += $(SSE_SOURCES)
CFLAGS += -DUSE_SSE_ASM
HAVE_X86 = 1
endif
ifeq ($(HAVE_3DNOW),1)
X86_SOURCES += $(K3D_SOURCES)
CFLAGS += -DUSE_3DNOW_ASM
HAVE_X86 = 1
endif
ifeq ($(HAVE_X86),1)
CFLAGS += -DUSE_X86_ASM
else
X86_SOURCES =
endif
DRIVER_SOURCES = \
drivers/dos/dmesa.c
ifeq ($(FX),1)
DRIVER_SOURCES += \
drivers/glide/fxapi.c \
drivers/glide/fxdd.c \
drivers/glide/fxddspan.c \
drivers/glide/fxddtex.c \
drivers/glide/fxsetup.c \
drivers/glide/fxtexman.c \
drivers/glide/fxtris.c \
drivers/glide/fxvb.c \
drivers/glide/fxglidew.c
else
ifeq ($(MATROX),1)
DRIVER_SOURCES += \
drivers/dos/mga/mga.c \
drivers/dos/mga/mga_hw.c \
drivers/dos/mga/mga_mode.c \
drivers/dos/dpmi.c
else
DRIVER_SOURCES += \
drivers/dos/video.c \
drivers/dos/virtual.S \
drivers/dos/vesa.c \
drivers/dos/blit.S \
drivers/dos/vga.c \
drivers/dos/dpmi.c
endif
endif
SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
.c.o:
$(CC) -o $@ $(CFLAGS) -c $<
.S.o:
$(CC) -o $@ $(CFLAGS) -c $<
.s.o:
$(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
all: $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP)
$(LIBDIR)/$(GL_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GL_LIB) $(OBJECTS)
$(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GL_DXE))
else
ifeq ($(FX),1)
-dxe3gen -o $(LIBDIR)/$(GL_DXE) -Y $(LIBDIR)/$(GL_IMP) -D $(LIBNAME) -E _gl -E _DMesa -P glid3.dxe -U $(OBJECTS)
else
-dxe3gen -o $(LIBDIR)/$(GL_DXE) -Y $(LIBDIR)/$(GL_IMP) -D $(LIBNAME) -E _gl -E _DMesa -U $(OBJECTS)
endif
endif
$(X86_OBJECTS): x86/matypes.h
x86/matypes.h: x86/gen_matypes.exe
$< > $@
x86/gen_matypes.exe: x86/gen_matypes.c
$(CC) -o $@ $(CFLAGS) -s $<
clean:
-$(call UNLINK,array_cache/*.o)
-$(call UNLINK,glapi/*.o)
-$(call UNLINK,main/*.o)
-$(call UNLINK,math/*.o)
-$(call UNLINK,swrast/*.o)
-$(call UNLINK,swrast_setup/*.o)
-$(call UNLINK,tnl/*.o)
-$(call UNLINK,x86/*.o)
-$(call UNLINK,drivers/dos/*.o)
-$(call UNLINK,drivers/dos/mga/*.o)
-$(call UNLINK,drivers/glide/*.o)
-include depend

View file

@ -1,199 +1,199 @@
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
.file "blit.S"
/*
* extern unsigned int vesa_gran_mask, vesa_gran_shift;
* extern int vl_video_selector;
* extern void *vl_current_draw_buffer;
* extern int vl_current_stride, vl_current_height;
* extern int vl_current_offset, vl_current_delta;
*/
.text
/* Desc: VESA bank switching routine (BIOS)
*
* In : EBX=0, EDX = bank number
* Out : -
*
* Note: thrashes EAX
*/
.p2align 5,,31
_vesa_swbankBIOS:
movw $0x4f05, %ax
int $0x10
ret
.p2align 2,,3
.global _vesa_swbank
_vesa_swbank: .long _vesa_swbankBIOS
/* Desc: void vesa_b_dump_virtual (void);
*
* In : -
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _vesa_b_dump_virtual
_vesa_b_dump_virtual:
cld
pushl %es
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %es
movl _vl_current_draw_buffer, %esi
movl _vl_current_offset, %edi
movl _vesa_gran_shift, %ecx
movl _vesa_gran_mask, %ebp
movl %edi, %edx
xorl %ebx, %ebx
andl %ebp, %edi
shrl %cl, %edx
incl %ebp
call *_vesa_swbank
movl _vl_current_stride, %ecx
movl _vl_current_height, %eax
movl _vl_current_delta, %ebx
shrl $2, %ecx
.balign 4
0:
pushl %ecx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
pushl %eax
pushl %ebx
incl %edx
xorl %ebx, %ebx
call *_vesa_swbank
popl %ebx
popl %eax
subl %ebp, %edi
.balign 4
2:
movsl
decl %ecx
jnz 1b
popl %ecx
addl %ebx, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
popl %es
ret
/* Desc: void vesa_l_dump_virtual (void);
*
* In : -
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _vesa_l_dump_virtual
_vesa_l_dump_virtual:
cld
pushl %es
pushl %esi
pushl %edi
movl _vl_video_selector, %es
movl _vl_current_draw_buffer, %esi
movl _vl_current_offset, %edi
movl _vl_current_stride, %ecx
movl _vl_current_height, %edx
movl _vl_current_delta, %eax
shrl $2, %ecx
.balign 4
0:
pushl %ecx
rep; movsl
popl %ecx
addl %eax, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %es
ret
/* Desc: void vesa_l_dump_virtual_mmx (void);
*
* In : -
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _vesa_l_dump_virtual_mmx
_vesa_l_dump_virtual_mmx:
#ifdef USE_MMX_ASM
pushl %esi
pushl %edi
movl _vl_video_selector, %fs
movl _vl_current_draw_buffer, %esi
movl _vl_current_offset, %edi
movl _vl_current_stride, %ecx
movl _vl_current_height, %edx
movl _vl_current_delta, %eax
shrl $3, %ecx
.balign 4
0:
pushl %ecx
.balign 4
1:
movq (%esi), %mm0
addl $8, %esi
movq %mm0, %fs:(%edi)
addl $8, %edi
decl %ecx
jnz 1b
popl %ecx
addl %eax, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
emms
#endif
ret
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
.file "blit.S"
/*
* extern unsigned int vesa_gran_mask, vesa_gran_shift;
* extern int vl_video_selector;
* extern void *vl_current_draw_buffer;
* extern int vl_current_stride, vl_current_height;
* extern int vl_current_offset, vl_current_delta;
*/
.text
/* Desc: VESA bank switching routine (BIOS)
*
* In : EBX=0, EDX = bank number
* Out : -
*
* Note: thrashes EAX
*/
.p2align 5,,31
_vesa_swbankBIOS:
movw $0x4f05, %ax
int $0x10
ret
.p2align 2,,3
.global _vesa_swbank
_vesa_swbank: .long _vesa_swbankBIOS
/* Desc: void vesa_b_dump_virtual (void);
*
* In : -
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _vesa_b_dump_virtual
_vesa_b_dump_virtual:
cld
pushl %es
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %es
movl _vl_current_draw_buffer, %esi
movl _vl_current_offset, %edi
movl _vesa_gran_shift, %ecx
movl _vesa_gran_mask, %ebp
movl %edi, %edx
xorl %ebx, %ebx
andl %ebp, %edi
shrl %cl, %edx
incl %ebp
call *_vesa_swbank
movl _vl_current_stride, %ecx
movl _vl_current_height, %eax
movl _vl_current_delta, %ebx
shrl $2, %ecx
.balign 4
0:
pushl %ecx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
pushl %eax
pushl %ebx
incl %edx
xorl %ebx, %ebx
call *_vesa_swbank
popl %ebx
popl %eax
subl %ebp, %edi
.balign 4
2:
movsl
decl %ecx
jnz 1b
popl %ecx
addl %ebx, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
popl %es
ret
/* Desc: void vesa_l_dump_virtual (void);
*
* In : -
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _vesa_l_dump_virtual
_vesa_l_dump_virtual:
cld
pushl %es
pushl %esi
pushl %edi
movl _vl_video_selector, %es
movl _vl_current_draw_buffer, %esi
movl _vl_current_offset, %edi
movl _vl_current_stride, %ecx
movl _vl_current_height, %edx
movl _vl_current_delta, %eax
shrl $2, %ecx
.balign 4
0:
pushl %ecx
rep; movsl
popl %ecx
addl %eax, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %es
ret
/* Desc: void vesa_l_dump_virtual_mmx (void);
*
* In : -
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _vesa_l_dump_virtual_mmx
_vesa_l_dump_virtual_mmx:
#ifdef USE_MMX_ASM
pushl %esi
pushl %edi
movl _vl_video_selector, %fs
movl _vl_current_draw_buffer, %esi
movl _vl_current_offset, %edi
movl _vl_current_stride, %ecx
movl _vl_current_height, %edx
movl _vl_current_delta, %eax
shrl $3, %ecx
.balign 4
0:
pushl %ecx
.balign 4
1:
movq (%esi), %mm0
addl $8, %esi
movq %mm0, %fs:(%edi)
addl $8, %edi
decl %ecx
jnz 1b
popl %ecx
addl %eax, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
emms
#endif
ret

File diff suppressed because it is too large Load diff

View file

@ -1,148 +1,148 @@
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include "internal.h"
#ifndef MAX
#define MAX(x, y) (((x)<(y))?(y):(x))
#endif
/* _create_linear_mapping:
* Maps a physical address range into linear memory.
*/
int _create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size)
{
__dpmi_meminfo meminfo;
if (physaddr >= 0x100000) {
/* map into linear memory */
meminfo.address = physaddr;
meminfo.size = size;
if (__dpmi_physical_address_mapping(&meminfo) != 0)
return -1;
*linear = meminfo.address;
} else {
/* exploit 1 -> 1 physical to linear mapping in low megabyte */
*linear = physaddr;
}
return 0;
}
/* _remove_linear_mapping:
* Frees the DPMI resources being used to map a linear address range.
*/
void _remove_linear_mapping (unsigned long *linear)
{
__dpmi_meminfo meminfo;
if (*linear) {
if (*linear >= 0x100000) {
meminfo.address = *linear;
__dpmi_free_physical_address_mapping(&meminfo);
}
*linear = 0;
}
}
/* _create_selector:
* Allocates a selector to access a region of linear memory.
*/
int _create_selector (int *segment, unsigned long base, int size)
{
/* allocate an ldt descriptor */
if ((*segment=__dpmi_allocate_ldt_descriptors(1)) < 0) {
*segment = 0;
return -1;
}
/* create the linear mapping */
if (_create_linear_mapping(&base, base, size)) {
__dpmi_free_ldt_descriptor(*segment);
*segment = 0;
return -1;
}
/* set the descriptor base and limit */
__dpmi_set_segment_base_address(*segment, base);
__dpmi_set_segment_limit(*segment, MAX(size-1, 0xFFFF));
return 0;
}
/* _remove_selector:
* Frees a DPMI segment selector.
*/
void _remove_selector (int *segment)
{
if (*segment) {
unsigned long base;
__dpmi_get_segment_base_address(*segment, &base);
_remove_linear_mapping(&base);
__dpmi_free_ldt_descriptor(*segment);
*segment = 0;
}
}
/* Desc: retrieve CPU MMX capability
*
* In : -
* Out : FALSE if CPU cannot do MMX
*
* Note: -
*/
int _can_mmx (void)
{
#ifdef USE_MMX_ASM
extern int _mesa_identify_x86_cpu_features (void);
return (_mesa_identify_x86_cpu_features() & 0x00800000);
#else
return 0;
#endif
}
/*
* 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.4 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <dpmi.h>
#include "internal.h"
#ifndef MAX
#define MAX(x, y) (((x)<(y))?(y):(x))
#endif
/* _create_linear_mapping:
* Maps a physical address range into linear memory.
*/
int _create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size)
{
__dpmi_meminfo meminfo;
if (physaddr >= 0x100000) {
/* map into linear memory */
meminfo.address = physaddr;
meminfo.size = size;
if (__dpmi_physical_address_mapping(&meminfo) != 0)
return -1;
*linear = meminfo.address;
} else {
/* exploit 1 -> 1 physical to linear mapping in low megabyte */
*linear = physaddr;
}
return 0;
}
/* _remove_linear_mapping:
* Frees the DPMI resources being used to map a linear address range.
*/
void _remove_linear_mapping (unsigned long *linear)
{
__dpmi_meminfo meminfo;
if (*linear) {
if (*linear >= 0x100000) {
meminfo.address = *linear;
__dpmi_free_physical_address_mapping(&meminfo);
}
*linear = 0;
}
}
/* _create_selector:
* Allocates a selector to access a region of linear memory.
*/
int _create_selector (int *segment, unsigned long base, int size)
{
/* allocate an ldt descriptor */
if ((*segment=__dpmi_allocate_ldt_descriptors(1)) < 0) {
*segment = 0;
return -1;
}
/* create the linear mapping */
if (_create_linear_mapping(&base, base, size)) {
__dpmi_free_ldt_descriptor(*segment);
*segment = 0;
return -1;
}
/* set the descriptor base and limit */
__dpmi_set_segment_base_address(*segment, base);
__dpmi_set_segment_limit(*segment, MAX(size-1, 0xFFFF));
return 0;
}
/* _remove_selector:
* Frees a DPMI segment selector.
*/
void _remove_selector (int *segment)
{
if (*segment) {
unsigned long base;
__dpmi_get_segment_base_address(*segment, &base);
_remove_linear_mapping(&base);
__dpmi_free_ldt_descriptor(*segment);
*segment = 0;
}
}
/* Desc: retrieve CPU MMX capability
*
* In : -
* Out : FALSE if CPU cannot do MMX
*
* Note: -
*/
int _can_mmx (void)
{
#ifdef USE_MMX_ASM
extern int _mesa_x86_cpu_features;
return (_mesa_x86_cpu_features & 0x00800000);
#else
return 0;
#endif
}

View file

@ -1,129 +1,129 @@
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef INTERNAL_H_included
#define INTERNAL_H_included
#include "../mmath.h"
/*
* 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 *(*init) (void);
int (*entermode) (vl_mode *p, int refresh);
void (*blit) (void);
void (*setCI_f) (int index, float red, float green, float blue);
void (*setCI_i) (int index, int red, int green, int blue);
int (*get) (int pname, int *params);
void (*restore) (void);
void (*fini) (void);
} vl_driver;
/*
* memory mapping
*/
int _create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size);
void _remove_linear_mapping (unsigned long *linear);
int _create_selector (int *segment, unsigned long base, int size);
void _remove_selector (int *segment);
/*
* system routines
*/
int _can_mmx (void);
/*
* asm routines to deal with virtual buffering
*/
extern void v_clear8 (int color);
#define v_clear15 v_clear16
extern void v_clear16 (int color);
extern void v_clear24 (int color);
extern void v_clear32 (int color);
extern void v_clear8_mmx (int color);
#define v_clear15_mmx v_clear16_mmx
extern void v_clear16_mmx (int color);
extern void v_clear24_mmx (int color);
extern void v_clear32_mmx (int color);
extern void v_rect8 (int x, int y, int width, int height, int color);
#define v_rect15 v_rect16
extern void v_rect16 (int x, int y, int width, int height, int color);
extern void v_rect24 (int x, int y, int width, int height, int color);
extern void v_rect32 (int x, int y, int width, int height, int color);
extern void v_putpixel8 (unsigned int offset, int color);
#define v_putpixel15 v_putpixel16
extern void v_putpixel16 (unsigned int offset, int color);
extern void v_putpixel24 (unsigned int offset, int color);
extern void v_putpixel32 (unsigned int offset, int color);
#endif
/*
* 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.4 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef INTERNAL_H_included
#define INTERNAL_H_included
#include "../main/mtypes.h"
/*
* 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 *(*init) (void);
int (*entermode) (vl_mode *p, int refresh);
void (*blit) (void);
void (*setCI_f) (int index, float red, float green, float blue);
void (*setCI_i) (int index, int red, int green, int blue);
int (*get) (int pname, int *params);
void (*restore) (void);
void (*fini) (void);
} vl_driver;
/*
* memory mapping
*/
int _create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size);
void _remove_linear_mapping (unsigned long *linear);
int _create_selector (int *segment, unsigned long base, int size);
void _remove_selector (int *segment);
/*
* system routines
*/
int _can_mmx (void);
/*
* asm routines to deal with virtual buffering
*/
extern void v_clear8 (int color);
#define v_clear15 v_clear16
extern void v_clear16 (int color);
extern void v_clear24 (int color);
extern void v_clear32 (int color);
extern void v_clear8_mmx (int color);
#define v_clear15_mmx v_clear16_mmx
extern void v_clear16_mmx (int color);
extern void v_clear24_mmx (int color);
extern void v_clear32_mmx (int color);
extern void v_rect8 (int x, int y, int width, int height, int color);
#define v_rect15 v_rect16
extern void v_rect16 (int x, int y, int width, int height, int color);
extern void v_rect24 (int x, int y, int width, int height, int color);
extern void v_rect32 (int x, int y, int width, int height, int color);
extern void v_putpixel8 (unsigned int offset, int color);
#define v_putpixel15 v_putpixel16
extern void v_putpixel16 (unsigned int offset, int color);
extern void v_putpixel24 (unsigned int offset, int color);
extern void v_putpixel32 (unsigned int offset, int color);
#endif

View file

@ -1,377 +1,377 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W triangle template
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
/*
* Triangle Rasterizer Template
*
* This file is #include'd to generate custom triangle rasterizers.
*
* The following macros may be defined to indicate what auxillary information
* must be interplated across the triangle:
* INTERP_Z - if defined, interpolate Z values
* INTERP_RGB - if defined, interpolate RGB values
*
* TAG - function name
* CULL - enable culling for: 0=no, 1=back, -1=front
*
* SETUP_CODE - to be executed once per triangle (usually HW init)
*
* For flatshaded primitives, the provoking vertex is the final one.
* This code was designed for the origin to be in the upper-left corner.
*
* Inspired by triangle rasterizer code written by Brian Paul.
*/
#define TRI_SWAP(a, b) \
do { \
const MGAvertex *tmp = a; \
a = b; \
b = tmp; \
} while (0)
void TAG (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3)
{
int area;
int x1, y1, x2, y2, x3, y3;
int eMaj_dx, eMaj_dy, eBot_dx, eBot_dy, eTop_dx, eTop_dy;
#ifdef INTERP_RGB
#define FIFO_CNT_RGB 3
int eMaj_dr, eBot_dr, eMaj_dg, eBot_dg, eMaj_db, eBot_db;
int drdx, drdy, dgdx, dgdy, dbdx, dbdy;
#else
#define FIFO_CNT_RGB 0
#endif
#ifdef INTERP_Z
#define FIFO_CNT_Z 1
int dzdx, dzdy;
int eMaj_dz, eBot_dz;
int z1, z2, z3;
#else
#define FIFO_CNT_Z 0
#endif
#if defined(INTERP_Z) || defined(INTERP_RGB)
double one_area;
#ifndef INTERP_RGB
int red = v3->color[0];
int green = v3->color[1];
int blue = v3->color[2];
#endif
#else
unsigned long color = mga_mixrgb_full(v3->color);
#endif
int sgn = 0;
/* sort along the vertical axis */
if (v2->win[1] < v1->win[1]) {
TRI_SWAP(v1, v2);
#ifdef CULL
cull = -cull;
#endif
}
if (v3->win[1] < v1->win[1]) {
TRI_SWAP(v1, v3);
TRI_SWAP(v2, v3);
} else if (v3->win[1] < v2->win[1]) {
TRI_SWAP(v2, v3);
#ifdef CULL
cull = -cull;
#endif
}
x1 = v1->win[0];
y1 = v1->win[1];
x2 = v2->win[0];
y2 = v2->win[1];
x3 = v3->win[0];
y3 = v3->win[1];
/* compute deltas for each edge */
eMaj_dx = x3 - x1;
eMaj_dy = y3 - y1;
eBot_dx = x2 - x1;
eBot_dy = y2 - y1;
eTop_dx = x3 - x2;
eTop_dy = y3 - y2;
/* compute area */
if ((area = eMaj_dx * eBot_dy - eBot_dx * eMaj_dy) == 0) {
return;
}
#ifdef CULL
if ((area * cull) > 0) {
return;
}
#endif
mga_select();
/* set engine state */
#ifdef SETUP_CODE
SETUP_CODE
#endif
/* draw lower triangle */
#if defined(INTERP_Z) || defined(INTERP_RGB)
one_area = (double)(1<<15) / (double)area;
mga_fifo(1);
#else
mga_fifo(2);
mga_outl(M_FCOL, color);
#endif
mga_outl(M_YDST, y1);
#ifdef INTERP_Z
z1 = v1->win[2];
z2 = v2->win[2];
z3 = v3->win[2];
/* compute d?/dx and d?/dy derivatives */
eMaj_dz = z3 - z1;
eBot_dz = z2 - z1;
dzdx = (eMaj_dz * eBot_dy - eMaj_dy * eBot_dz) * one_area;
dzdy = (eMaj_dx * eBot_dz - eMaj_dz * eBot_dx) * one_area;
#ifndef INTERP_RGB
mga_fifo(11);
mga_outl(M_DR2, dzdx);
mga_outl(M_DR3, dzdy);
mga_outl(M_DR4, red<<15);
mga_outl(M_DR6, 0);
mga_outl(M_DR7, 0);
mga_outl(M_DR8, green<<15);
mga_outl(M_DR10, 0);
mga_outl(M_DR11, 0);
mga_outl(M_DR12, blue<<15);
mga_outl(M_DR14, 0);
mga_outl(M_DR15, 0);
#else
mga_fifo(2);
mga_outl(M_DR2, dzdx);
mga_outl(M_DR3, dzdy);
#endif
#endif
#ifdef INTERP_RGB
/* compute color deltas */
eMaj_dr = v3->color[0] - v1->color[0];
eBot_dr = v2->color[0] - v1->color[0];
eMaj_dg = v3->color[1] - v1->color[1];
eBot_dg = v2->color[1] - v1->color[1];
eMaj_db = v3->color[2] - v1->color[2];
eBot_db = v2->color[2] - v1->color[2];
/* compute color increments */
drdx = (eMaj_dr * eBot_dy - eMaj_dy * eBot_dr) * one_area;
drdy = (eMaj_dx * eBot_dr - eMaj_dr * eBot_dx) * one_area;
dgdx = (eMaj_dg * eBot_dy - eMaj_dy * eBot_dg) * one_area;
dgdy = (eMaj_dx * eBot_dg - eMaj_dg * eBot_dx) * one_area;
dbdx = (eMaj_db * eBot_dy - eMaj_dy * eBot_db) * one_area;
dbdy = (eMaj_dx * eBot_db - eMaj_db * eBot_dx) * one_area;
mga_fifo(6);
mga_outl(M_DR6, drdx);
mga_outl(M_DR7, drdy);
mga_outl(M_DR10, dgdx);
mga_outl(M_DR11, dgdy);
mga_outl(M_DR14, dbdx);
mga_outl(M_DR15, dbdy);
#endif
if (area > 0) { /* major edge on the right */
if (eBot_dy) { /* have lower triangle */
mga_fifo(9 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eBot_dy);
if (x2 < x1) {
mga_outl(M_AR1, eBot_dx + eBot_dy - 1);
mga_outl(M_AR2, eBot_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eBot_dx);
mga_outl(M_AR2, -eBot_dx);
}
mga_outl(M_AR6, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR4, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR5, eMaj_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eMaj_dx);
mga_outl(M_AR5, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eBot_dy);
} else { /* no lower triangle */
mga_fifo(4 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR6, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR4, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR5, eMaj_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eMaj_dx);
mga_outl(M_AR5, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x2);
#ifdef INTERP_Z
mga_outl(M_DR0, z2<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v2->color[0]<<15);
mga_outl(M_DR8, v2->color[1]<<15);
mga_outl(M_DR12, v2->color[2]<<15);
#endif
}
/* draw upper triangle */
if (eTop_dy) {
mga_fifo(5);
mga_outl(M_AR0, eTop_dy);
if (x3 < x2) {
mga_outl(M_AR1, eTop_dx + eTop_dy - 1);
mga_outl(M_AR2, eTop_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eTop_dx);
mga_outl(M_AR2, -eTop_dx);
sgn &= ~M_SDXL;
}
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eTop_dy);
}
} else { /* major edge on the left */
if (eBot_dy) { /* have lower triangle */
mga_fifo(9 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR1, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR2, eMaj_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eMaj_dx);
mga_outl(M_AR2, -eMaj_dx);
}
mga_outl(M_AR6, eBot_dy);
if (x2 < x1) {
mga_outl(M_AR4, eBot_dx + eBot_dy - 1);
mga_outl(M_AR5, eBot_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eBot_dx);
mga_outl(M_AR5, -eBot_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eBot_dy);
} else { /* no lower triangle */
mga_fifo(4 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR1, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR2, eMaj_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eMaj_dx);
mga_outl(M_AR2, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x2<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
}
/* draw upper triangle */
if (eTop_dy) {
mga_fifo(5);
mga_outl(M_AR6, eTop_dy);
if (x3 < x2) {
mga_outl(M_AR4, eTop_dx + eTop_dy - 1);
mga_outl(M_AR5, eTop_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eTop_dx);
mga_outl(M_AR5, -eTop_dx);
sgn &= ~M_SDXR;
}
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eTop_dy);
}
}
}
#undef FIFO_CNT_RGB
#undef FIFO_CNT_Z
#undef TRI_SWAP
#undef SETUP_CODE
#undef INTERP_RGB
#undef INTERP_Z
#undef CULL
#undef TAG
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W triangle template
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
/*
* Triangle Rasterizer Template
*
* This file is #include'd to generate custom triangle rasterizers.
*
* The following macros may be defined to indicate what auxillary information
* must be interplated across the triangle:
* INTERP_Z - if defined, interpolate Z values
* INTERP_RGB - if defined, interpolate RGB values
*
* TAG - function name
* CULL - enable culling for: 0=no, 1=back, -1=front
*
* SETUP_CODE - to be executed once per triangle (usually HW init)
*
* For flatshaded primitives, the provoking vertex is the final one.
* This code was designed for the origin to be in the upper-left corner.
*
* Inspired by triangle rasterizer code written by Brian Paul.
*/
#define TRI_SWAP(a, b) \
do { \
const MGAvertex *tmp = a; \
a = b; \
b = tmp; \
} while (0)
void TAG (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3)
{
int area;
int x1, y1, x2, y2, x3, y3;
int eMaj_dx, eMaj_dy, eBot_dx, eBot_dy, eTop_dx, eTop_dy;
#ifdef INTERP_RGB
#define FIFO_CNT_RGB 3
int eMaj_dr, eBot_dr, eMaj_dg, eBot_dg, eMaj_db, eBot_db;
int drdx, drdy, dgdx, dgdy, dbdx, dbdy;
#else
#define FIFO_CNT_RGB 0
#endif
#ifdef INTERP_Z
#define FIFO_CNT_Z 1
int dzdx, dzdy;
int eMaj_dz, eBot_dz;
int z1, z2, z3;
#else
#define FIFO_CNT_Z 0
#endif
#if defined(INTERP_Z) || defined(INTERP_RGB)
double one_area;
#ifndef INTERP_RGB
int red = v3->color[0];
int green = v3->color[1];
int blue = v3->color[2];
#endif
#else
unsigned long color = mga_mixrgb_full(v3->color);
#endif
int sgn = 0;
/* sort along the vertical axis */
if (v2->win[1] < v1->win[1]) {
TRI_SWAP(v1, v2);
#ifdef CULL
cull = -cull;
#endif
}
if (v3->win[1] < v1->win[1]) {
TRI_SWAP(v1, v3);
TRI_SWAP(v2, v3);
} else if (v3->win[1] < v2->win[1]) {
TRI_SWAP(v2, v3);
#ifdef CULL
cull = -cull;
#endif
}
x1 = v1->win[0];
y1 = v1->win[1];
x2 = v2->win[0];
y2 = v2->win[1];
x3 = v3->win[0];
y3 = v3->win[1];
/* compute deltas for each edge */
eMaj_dx = x3 - x1;
eMaj_dy = y3 - y1;
eBot_dx = x2 - x1;
eBot_dy = y2 - y1;
eTop_dx = x3 - x2;
eTop_dy = y3 - y2;
/* compute area */
if ((area = eMaj_dx * eBot_dy - eBot_dx * eMaj_dy) == 0) {
return;
}
#ifdef CULL
if ((area * cull) > 0) {
return;
}
#endif
mga_select();
/* set engine state */
#ifdef SETUP_CODE
SETUP_CODE
#endif
/* draw lower triangle */
#if defined(INTERP_Z) || defined(INTERP_RGB)
one_area = (double)(1<<15) / (double)area;
mga_fifo(1);
#else
mga_fifo(2);
mga_outl(M_FCOL, color);
#endif
mga_outl(M_YDST, y1);
#ifdef INTERP_Z
z1 = v1->win[2];
z2 = v2->win[2];
z3 = v3->win[2];
/* compute d?/dx and d?/dy derivatives */
eMaj_dz = z3 - z1;
eBot_dz = z2 - z1;
dzdx = (eMaj_dz * eBot_dy - eMaj_dy * eBot_dz) * one_area;
dzdy = (eMaj_dx * eBot_dz - eMaj_dz * eBot_dx) * one_area;
#ifndef INTERP_RGB
mga_fifo(11);
mga_outl(M_DR2, dzdx);
mga_outl(M_DR3, dzdy);
mga_outl(M_DR4, red<<15);
mga_outl(M_DR6, 0);
mga_outl(M_DR7, 0);
mga_outl(M_DR8, green<<15);
mga_outl(M_DR10, 0);
mga_outl(M_DR11, 0);
mga_outl(M_DR12, blue<<15);
mga_outl(M_DR14, 0);
mga_outl(M_DR15, 0);
#else
mga_fifo(2);
mga_outl(M_DR2, dzdx);
mga_outl(M_DR3, dzdy);
#endif
#endif
#ifdef INTERP_RGB
/* compute color deltas */
eMaj_dr = v3->color[0] - v1->color[0];
eBot_dr = v2->color[0] - v1->color[0];
eMaj_dg = v3->color[1] - v1->color[1];
eBot_dg = v2->color[1] - v1->color[1];
eMaj_db = v3->color[2] - v1->color[2];
eBot_db = v2->color[2] - v1->color[2];
/* compute color increments */
drdx = (eMaj_dr * eBot_dy - eMaj_dy * eBot_dr) * one_area;
drdy = (eMaj_dx * eBot_dr - eMaj_dr * eBot_dx) * one_area;
dgdx = (eMaj_dg * eBot_dy - eMaj_dy * eBot_dg) * one_area;
dgdy = (eMaj_dx * eBot_dg - eMaj_dg * eBot_dx) * one_area;
dbdx = (eMaj_db * eBot_dy - eMaj_dy * eBot_db) * one_area;
dbdy = (eMaj_dx * eBot_db - eMaj_db * eBot_dx) * one_area;
mga_fifo(6);
mga_outl(M_DR6, drdx);
mga_outl(M_DR7, drdy);
mga_outl(M_DR10, dgdx);
mga_outl(M_DR11, dgdy);
mga_outl(M_DR14, dbdx);
mga_outl(M_DR15, dbdy);
#endif
if (area > 0) { /* major edge on the right */
if (eBot_dy) { /* have lower triangle */
mga_fifo(9 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eBot_dy);
if (x2 < x1) {
mga_outl(M_AR1, eBot_dx + eBot_dy - 1);
mga_outl(M_AR2, eBot_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eBot_dx);
mga_outl(M_AR2, -eBot_dx);
}
mga_outl(M_AR6, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR4, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR5, eMaj_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eMaj_dx);
mga_outl(M_AR5, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eBot_dy);
} else { /* no lower triangle */
mga_fifo(4 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR6, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR4, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR5, eMaj_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eMaj_dx);
mga_outl(M_AR5, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x2);
#ifdef INTERP_Z
mga_outl(M_DR0, z2<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v2->color[0]<<15);
mga_outl(M_DR8, v2->color[1]<<15);
mga_outl(M_DR12, v2->color[2]<<15);
#endif
}
/* draw upper triangle */
if (eTop_dy) {
mga_fifo(5);
mga_outl(M_AR0, eTop_dy);
if (x3 < x2) {
mga_outl(M_AR1, eTop_dx + eTop_dy - 1);
mga_outl(M_AR2, eTop_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eTop_dx);
mga_outl(M_AR2, -eTop_dx);
sgn &= ~M_SDXL;
}
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eTop_dy);
}
} else { /* major edge on the left */
if (eBot_dy) { /* have lower triangle */
mga_fifo(9 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR1, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR2, eMaj_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eMaj_dx);
mga_outl(M_AR2, -eMaj_dx);
}
mga_outl(M_AR6, eBot_dy);
if (x2 < x1) {
mga_outl(M_AR4, eBot_dx + eBot_dy - 1);
mga_outl(M_AR5, eBot_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eBot_dx);
mga_outl(M_AR5, -eBot_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eBot_dy);
} else { /* no lower triangle */
mga_fifo(4 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR1, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR2, eMaj_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eMaj_dx);
mga_outl(M_AR2, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x2<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
}
/* draw upper triangle */
if (eTop_dy) {
mga_fifo(5);
mga_outl(M_AR6, eTop_dy);
if (x3 < x2) {
mga_outl(M_AR4, eTop_dx + eTop_dy - 1);
mga_outl(M_AR5, eTop_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eTop_dx);
mga_outl(M_AR5, -eTop_dx);
sgn &= ~M_SDXR;
}
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eTop_dy);
}
}
}
#undef FIFO_CNT_RGB
#undef FIFO_CNT_Z
#undef TRI_SWAP
#undef SETUP_CODE
#undef INTERP_RGB
#undef INTERP_Z
#undef CULL
#undef TAG

View file

@ -1,375 +1,375 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W triangle template
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
/*
* Triangle Rasterizer Template
*
* This file is #include'd to generate custom triangle rasterizers.
*
* The following macros may be defined to indicate what auxillary information
* must be interplated across the triangle:
* INTERP_Z - if defined, interpolate Z values
* INTERP_RGB - if defined, interpolate RGB values
*
* TAG - function name
* CULL - enable culling for: 0=no, 1=back, -1=front
*
* SETUP_CODE - to be executed once per triangle (usually HW init)
*
* For flatshaded primitives, the provoking vertex is the final one.
* This code was designed for the origin to be in the upper-left corner.
*
* Inspired by triangle rasterizer code written by Brian Paul.
*/
#define TRI_SWAP(a, b) \
do { \
const MGAvertex *tmp = a; \
a = b; \
b = tmp; \
} while (0)
void TAG (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3)
{
int area;
int x1, y1, x2, y2, x3, y3;
int eMaj_dx, eMaj_dy, eBot_dx, eBot_dy, eTop_dx, eTop_dy;
#ifdef INTERP_RGB
#define FIFO_CNT_RGB 3
int eMaj_dr, eBot_dr, eMaj_dg, eBot_dg, eMaj_db, eBot_db;
int drdx, drdy, dgdx, dgdy, dbdx, dbdy;
#else
#define FIFO_CNT_RGB 0
#endif
#ifdef INTERP_Z
#define FIFO_CNT_Z 1
int dzdx, dzdy;
int eMaj_dz, eBot_dz;
int z1, z2, z3;
#else
#define FIFO_CNT_Z 0
#endif
#if defined(INTERP_Z) || defined(INTERP_RGB)
#ifndef INTERP_RGB
int red = v3->color[0];
int green = v3->color[1];
int blue = v3->color[2];
#endif
#else
unsigned long color = mga_mixrgb_full(v3->color);
#endif
int sgn = 0;
/* sort along the vertical axis */
if (v2->win[1] < v1->win[1]) {
TRI_SWAP(v1, v2);
#ifdef CULL
cull = -cull;
#endif
}
if (v3->win[1] < v1->win[1]) {
TRI_SWAP(v1, v3);
TRI_SWAP(v2, v3);
} else if (v3->win[1] < v2->win[1]) {
TRI_SWAP(v2, v3);
#ifdef CULL
cull = -cull;
#endif
}
x1 = v1->win[0];
y1 = v1->win[1];
x2 = v2->win[0];
y2 = v2->win[1];
x3 = v3->win[0];
y3 = v3->win[1];
/* compute deltas for each edge */
eMaj_dx = x3 - x1;
eMaj_dy = y3 - y1;
eBot_dx = x2 - x1;
eBot_dy = y2 - y1;
eTop_dx = x3 - x2;
eTop_dy = y3 - y2;
/* compute area */
if ((area = eMaj_dx * eBot_dy - eBot_dx * eMaj_dy) == 0) {
return;
}
#ifdef CULL
if ((area * cull) > 0) {
return;
}
#endif
mga_select();
/* set engine state */
#ifdef SETUP_CODE
SETUP_CODE
#endif
/* draw lower triangle */
#if defined(INTERP_Z) || defined(INTERP_RGB)
mga_fifo(1);
#else
mga_fifo(2);
mga_outl(M_FCOL, color);
#endif
mga_outl(M_YDST, y1);
#ifdef INTERP_Z
z1 = v1->win[2];
z2 = v2->win[2];
z3 = v3->win[2];
/* compute d?/dx and d?/dy derivatives */
eMaj_dz = z3 - z1;
eBot_dz = z2 - z1;
dzdx = ((long long)(eMaj_dz * eBot_dy - eMaj_dy * eBot_dz)<<15) / area;
dzdy = ((long long)(eMaj_dx * eBot_dz - eMaj_dz * eBot_dx)<<15) / area;
#ifndef INTERP_RGB
mga_fifo(11);
mga_outl(M_DR2, dzdx);
mga_outl(M_DR3, dzdy);
mga_outl(M_DR4, red<<15);
mga_outl(M_DR6, 0);
mga_outl(M_DR7, 0);
mga_outl(M_DR8, green<<15);
mga_outl(M_DR10, 0);
mga_outl(M_DR11, 0);
mga_outl(M_DR12, blue<<15);
mga_outl(M_DR14, 0);
mga_outl(M_DR15, 0);
#else
mga_fifo(2);
mga_outl(M_DR2, dzdx);
mga_outl(M_DR3, dzdy);
#endif
#endif
#ifdef INTERP_RGB
/* compute color deltas */
eMaj_dr = v3->color[0] - v1->color[0];
eBot_dr = v2->color[0] - v1->color[0];
eMaj_dg = v3->color[1] - v1->color[1];
eBot_dg = v2->color[1] - v1->color[1];
eMaj_db = v3->color[2] - v1->color[2];
eBot_db = v2->color[2] - v1->color[2];
/* compute color increments */
drdx = ((long long)(eMaj_dr * eBot_dy - eMaj_dy * eBot_dr)<<15) / area;
drdy = ((long long)(eMaj_dx * eBot_dr - eMaj_dr * eBot_dx)<<15) / area;
dgdx = ((long long)(eMaj_dg * eBot_dy - eMaj_dy * eBot_dg)<<15) / area;
dgdy = ((long long)(eMaj_dx * eBot_dg - eMaj_dg * eBot_dx)<<15) / area;
dbdx = ((long long)(eMaj_db * eBot_dy - eMaj_dy * eBot_db)<<15) / area;
dbdy = ((long long)(eMaj_dx * eBot_db - eMaj_db * eBot_dx)<<15) / area;
mga_fifo(6);
mga_outl(M_DR6, drdx);
mga_outl(M_DR7, drdy);
mga_outl(M_DR10, dgdx);
mga_outl(M_DR11, dgdy);
mga_outl(M_DR14, dbdx);
mga_outl(M_DR15, dbdy);
#endif
if (area > 0) { /* major edge on the right */
if (eBot_dy) { /* have lower triangle */
mga_fifo(9 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eBot_dy);
if (x2 < x1) {
mga_outl(M_AR1, eBot_dx + eBot_dy - 1);
mga_outl(M_AR2, eBot_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eBot_dx);
mga_outl(M_AR2, -eBot_dx);
}
mga_outl(M_AR6, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR4, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR5, eMaj_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eMaj_dx);
mga_outl(M_AR5, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eBot_dy);
} else { /* no lower triangle */
mga_fifo(4 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR6, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR4, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR5, eMaj_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eMaj_dx);
mga_outl(M_AR5, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x2);
#ifdef INTERP_Z
mga_outl(M_DR0, z2<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v2->color[0]<<15);
mga_outl(M_DR8, v2->color[1]<<15);
mga_outl(M_DR12, v2->color[2]<<15);
#endif
}
/* draw upper triangle */
if (eTop_dy) {
mga_fifo(5);
mga_outl(M_AR0, eTop_dy);
if (x3 < x2) {
mga_outl(M_AR1, eTop_dx + eTop_dy - 1);
mga_outl(M_AR2, eTop_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eTop_dx);
mga_outl(M_AR2, -eTop_dx);
sgn &= ~M_SDXL;
}
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eTop_dy);
}
} else { /* major edge on the left */
if (eBot_dy) { /* have lower triangle */
mga_fifo(9 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR1, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR2, eMaj_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eMaj_dx);
mga_outl(M_AR2, -eMaj_dx);
}
mga_outl(M_AR6, eBot_dy);
if (x2 < x1) {
mga_outl(M_AR4, eBot_dx + eBot_dy - 1);
mga_outl(M_AR5, eBot_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eBot_dx);
mga_outl(M_AR5, -eBot_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eBot_dy);
} else { /* no lower triangle */
mga_fifo(4 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR1, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR2, eMaj_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eMaj_dx);
mga_outl(M_AR2, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x2<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
}
/* draw upper triangle */
if (eTop_dy) {
mga_fifo(5);
mga_outl(M_AR6, eTop_dy);
if (x3 < x2) {
mga_outl(M_AR4, eTop_dx + eTop_dy - 1);
mga_outl(M_AR5, eTop_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eTop_dx);
mga_outl(M_AR5, -eTop_dx);
sgn &= ~M_SDXR;
}
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eTop_dy);
}
}
}
#undef FIFO_CNT_RGB
#undef FIFO_CNT_Z
#undef TRI_SWAP
#undef SETUP_CODE
#undef INTERP_RGB
#undef INTERP_Z
#undef CULL
#undef TAG
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W triangle template
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
/*
* Triangle Rasterizer Template
*
* This file is #include'd to generate custom triangle rasterizers.
*
* The following macros may be defined to indicate what auxillary information
* must be interplated across the triangle:
* INTERP_Z - if defined, interpolate Z values
* INTERP_RGB - if defined, interpolate RGB values
*
* TAG - function name
* CULL - enable culling for: 0=no, 1=back, -1=front
*
* SETUP_CODE - to be executed once per triangle (usually HW init)
*
* For flatshaded primitives, the provoking vertex is the final one.
* This code was designed for the origin to be in the upper-left corner.
*
* Inspired by triangle rasterizer code written by Brian Paul.
*/
#define TRI_SWAP(a, b) \
do { \
const MGAvertex *tmp = a; \
a = b; \
b = tmp; \
} while (0)
void TAG (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3)
{
int area;
int x1, y1, x2, y2, x3, y3;
int eMaj_dx, eMaj_dy, eBot_dx, eBot_dy, eTop_dx, eTop_dy;
#ifdef INTERP_RGB
#define FIFO_CNT_RGB 3
int eMaj_dr, eBot_dr, eMaj_dg, eBot_dg, eMaj_db, eBot_db;
int drdx, drdy, dgdx, dgdy, dbdx, dbdy;
#else
#define FIFO_CNT_RGB 0
#endif
#ifdef INTERP_Z
#define FIFO_CNT_Z 1
int dzdx, dzdy;
int eMaj_dz, eBot_dz;
int z1, z2, z3;
#else
#define FIFO_CNT_Z 0
#endif
#if defined(INTERP_Z) || defined(INTERP_RGB)
#ifndef INTERP_RGB
int red = v3->color[0];
int green = v3->color[1];
int blue = v3->color[2];
#endif
#else
unsigned long color = mga_mixrgb_full(v3->color);
#endif
int sgn = 0;
/* sort along the vertical axis */
if (v2->win[1] < v1->win[1]) {
TRI_SWAP(v1, v2);
#ifdef CULL
cull = -cull;
#endif
}
if (v3->win[1] < v1->win[1]) {
TRI_SWAP(v1, v3);
TRI_SWAP(v2, v3);
} else if (v3->win[1] < v2->win[1]) {
TRI_SWAP(v2, v3);
#ifdef CULL
cull = -cull;
#endif
}
x1 = v1->win[0];
y1 = v1->win[1];
x2 = v2->win[0];
y2 = v2->win[1];
x3 = v3->win[0];
y3 = v3->win[1];
/* compute deltas for each edge */
eMaj_dx = x3 - x1;
eMaj_dy = y3 - y1;
eBot_dx = x2 - x1;
eBot_dy = y2 - y1;
eTop_dx = x3 - x2;
eTop_dy = y3 - y2;
/* compute area */
if ((area = eMaj_dx * eBot_dy - eBot_dx * eMaj_dy) == 0) {
return;
}
#ifdef CULL
if ((area * cull) > 0) {
return;
}
#endif
mga_select();
/* set engine state */
#ifdef SETUP_CODE
SETUP_CODE
#endif
/* draw lower triangle */
#if defined(INTERP_Z) || defined(INTERP_RGB)
mga_fifo(1);
#else
mga_fifo(2);
mga_outl(M_FCOL, color);
#endif
mga_outl(M_YDST, y1);
#ifdef INTERP_Z
z1 = v1->win[2];
z2 = v2->win[2];
z3 = v3->win[2];
/* compute d?/dx and d?/dy derivatives */
eMaj_dz = z3 - z1;
eBot_dz = z2 - z1;
dzdx = ((long long)(eMaj_dz * eBot_dy - eMaj_dy * eBot_dz)<<15) / area;
dzdy = ((long long)(eMaj_dx * eBot_dz - eMaj_dz * eBot_dx)<<15) / area;
#ifndef INTERP_RGB
mga_fifo(11);
mga_outl(M_DR2, dzdx);
mga_outl(M_DR3, dzdy);
mga_outl(M_DR4, red<<15);
mga_outl(M_DR6, 0);
mga_outl(M_DR7, 0);
mga_outl(M_DR8, green<<15);
mga_outl(M_DR10, 0);
mga_outl(M_DR11, 0);
mga_outl(M_DR12, blue<<15);
mga_outl(M_DR14, 0);
mga_outl(M_DR15, 0);
#else
mga_fifo(2);
mga_outl(M_DR2, dzdx);
mga_outl(M_DR3, dzdy);
#endif
#endif
#ifdef INTERP_RGB
/* compute color deltas */
eMaj_dr = v3->color[0] - v1->color[0];
eBot_dr = v2->color[0] - v1->color[0];
eMaj_dg = v3->color[1] - v1->color[1];
eBot_dg = v2->color[1] - v1->color[1];
eMaj_db = v3->color[2] - v1->color[2];
eBot_db = v2->color[2] - v1->color[2];
/* compute color increments */
drdx = ((long long)(eMaj_dr * eBot_dy - eMaj_dy * eBot_dr)<<15) / area;
drdy = ((long long)(eMaj_dx * eBot_dr - eMaj_dr * eBot_dx)<<15) / area;
dgdx = ((long long)(eMaj_dg * eBot_dy - eMaj_dy * eBot_dg)<<15) / area;
dgdy = ((long long)(eMaj_dx * eBot_dg - eMaj_dg * eBot_dx)<<15) / area;
dbdx = ((long long)(eMaj_db * eBot_dy - eMaj_dy * eBot_db)<<15) / area;
dbdy = ((long long)(eMaj_dx * eBot_db - eMaj_db * eBot_dx)<<15) / area;
mga_fifo(6);
mga_outl(M_DR6, drdx);
mga_outl(M_DR7, drdy);
mga_outl(M_DR10, dgdx);
mga_outl(M_DR11, dgdy);
mga_outl(M_DR14, dbdx);
mga_outl(M_DR15, dbdy);
#endif
if (area > 0) { /* major edge on the right */
if (eBot_dy) { /* have lower triangle */
mga_fifo(9 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eBot_dy);
if (x2 < x1) {
mga_outl(M_AR1, eBot_dx + eBot_dy - 1);
mga_outl(M_AR2, eBot_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eBot_dx);
mga_outl(M_AR2, -eBot_dx);
}
mga_outl(M_AR6, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR4, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR5, eMaj_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eMaj_dx);
mga_outl(M_AR5, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eBot_dy);
} else { /* no lower triangle */
mga_fifo(4 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR6, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR4, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR5, eMaj_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eMaj_dx);
mga_outl(M_AR5, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x2);
#ifdef INTERP_Z
mga_outl(M_DR0, z2<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v2->color[0]<<15);
mga_outl(M_DR8, v2->color[1]<<15);
mga_outl(M_DR12, v2->color[2]<<15);
#endif
}
/* draw upper triangle */
if (eTop_dy) {
mga_fifo(5);
mga_outl(M_AR0, eTop_dy);
if (x3 < x2) {
mga_outl(M_AR1, eTop_dx + eTop_dy - 1);
mga_outl(M_AR2, eTop_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eTop_dx);
mga_outl(M_AR2, -eTop_dx);
sgn &= ~M_SDXL;
}
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eTop_dy);
}
} else { /* major edge on the left */
if (eBot_dy) { /* have lower triangle */
mga_fifo(9 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR1, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR2, eMaj_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eMaj_dx);
mga_outl(M_AR2, -eMaj_dx);
}
mga_outl(M_AR6, eBot_dy);
if (x2 < x1) {
mga_outl(M_AR4, eBot_dx + eBot_dy - 1);
mga_outl(M_AR5, eBot_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eBot_dx);
mga_outl(M_AR5, -eBot_dx);
}
mga_outl(M_FXBNDRY, (x1<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eBot_dy);
} else { /* no lower triangle */
mga_fifo(4 + FIFO_CNT_Z + FIFO_CNT_RGB);
mga_outl(M_AR0, eMaj_dy);
if (x3 < x1) {
mga_outl(M_AR1, eMaj_dx + eMaj_dy - 1);
mga_outl(M_AR2, eMaj_dx);
sgn |= M_SDXL;
} else {
mga_outl(M_AR1, -eMaj_dx);
mga_outl(M_AR2, -eMaj_dx);
}
mga_outl(M_FXBNDRY, (x2<<16) | x1);
#ifdef INTERP_Z
mga_outl(M_DR0, z1<<15);
#endif
#ifdef INTERP_RGB
mga_outl(M_DR4, v1->color[0]<<15);
mga_outl(M_DR8, v1->color[1]<<15);
mga_outl(M_DR12, v1->color[2]<<15);
#endif
}
/* draw upper triangle */
if (eTop_dy) {
mga_fifo(5);
mga_outl(M_AR6, eTop_dy);
if (x3 < x2) {
mga_outl(M_AR4, eTop_dx + eTop_dy - 1);
mga_outl(M_AR5, eTop_dx);
sgn |= M_SDXR;
} else {
mga_outl(M_AR4, -eTop_dx);
mga_outl(M_AR5, -eTop_dx);
sgn &= ~M_SDXR;
}
mga_outl(M_SGN, sgn);
mga_outl(M_LEN | M_EXEC, eTop_dy);
}
}
}
#undef FIFO_CNT_RGB
#undef FIFO_CNT_Z
#undef TRI_SWAP
#undef SETUP_CODE
#undef INTERP_RGB
#undef INTERP_Z
#undef CULL
#undef TAG

File diff suppressed because it is too large Load diff

View file

@ -1,91 +1,91 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef MGA_H_included
#define MGA_H_included
#define MGA_GET_CARD_NAME 0x0100
#define MGA_GET_VRAM 0x0101
#define MGA_GET_CI_PREC 0x0200
#define MGA_GET_HPIXELS 0x0201
#define MGA_GET_SCREEN_SIZE 0x0202
int mga_open (int width, int height, int bpp, int buffers, int zbuffer, int refresh);
void mga_clear (int front, int back, int zed, int left, int top, int width, int height, int color, unsigned short z);
int mga_get (int pname, int *params);
void mga_close (int restore, int unmap);
extern void (*mga_putpixel) (unsigned int offset, int color);
extern int (*mga_getpixel) (unsigned int offset);
extern void (*mga_getrgba) (unsigned int offset, unsigned char rgba[4]);
extern int (*mga_mixrgb) (const unsigned char rgb[]);
#define MGA_BACKBUFFER !0
#define MGA_FRONTBUFFER 0
void mga_set_readbuffer (int buffer);
void mga_set_writebuffer (int buffer);
void mga_swapbuffers (int swapinterval);
unsigned short mga_getz (int offset);
void mga_setz (int offset, unsigned short z);
void mga_wait_idle (void);
/*
* vertex structure, used for primitive rendering
*/
typedef struct {
int win[4]; /* X, Y, Z, ? */
unsigned char color[4]; /* R, G, B, A */
} MGAvertex;
void mga_draw_line_rgb_flat (const MGAvertex *v1, const MGAvertex *v2);
void mga_draw_line_rgb_flat_zless (const MGAvertex *v1, const MGAvertex *v2);
void mga_draw_line_rgb_iter (const MGAvertex *v1, const MGAvertex *v2);
void mga_draw_line_rgb_iter_zless (const MGAvertex *v1, const MGAvertex *v2);
void mga_draw_tri_rgb_flat (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3);
void mga_draw_tri_rgb_flat_zless (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3);
void mga_draw_tri_rgb_iter (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3);
void mga_draw_tri_rgb_iter_zless (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3);
void mga_draw_rect_rgb_flat (int left, int top, int width, int height, int color);
void mga_draw_rect_rgb_tx32 (int left, int top, int width, int height, const unsigned long *bitmap);
void mga_draw_rect_rgb_tx24 (int left, int top, int width, int height, const unsigned long *bitmap);
void mga_draw_span_rgb_tx32 (int left, int top, int width, const unsigned long *bitmap);
void mga_draw_span_rgb_tx24 (int left, int top, int width, const unsigned long *bitmap);
void mga_iload_32RGB (int left, int top, int width, int height, const unsigned long *bitmap);
void mga_iload_24RGB (int left, int top, int width, int height, const unsigned long *bitmap);
#endif
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef MGA_H_included
#define MGA_H_included
#define MGA_GET_CARD_NAME 0x0100
#define MGA_GET_VRAM 0x0101
#define MGA_GET_CI_PREC 0x0200
#define MGA_GET_HPIXELS 0x0201
#define MGA_GET_SCREEN_SIZE 0x0202
int mga_open (int width, int height, int bpp, int buffers, int zbuffer, int refresh);
void mga_clear (int front, int back, int zed, int left, int top, int width, int height, int color, unsigned short z);
int mga_get (int pname, int *params);
void mga_close (int restore, int unmap);
extern void (*mga_putpixel) (unsigned int offset, int color);
extern int (*mga_getpixel) (unsigned int offset);
extern void (*mga_getrgba) (unsigned int offset, unsigned char rgba[4]);
extern int (*mga_mixrgb) (const unsigned char rgb[]);
#define MGA_BACKBUFFER !0
#define MGA_FRONTBUFFER 0
void mga_set_readbuffer (int buffer);
void mga_set_writebuffer (int buffer);
void mga_swapbuffers (int swapinterval);
unsigned short mga_getz (int offset);
void mga_setz (int offset, unsigned short z);
void mga_wait_idle (void);
/*
* vertex structure, used for primitive rendering
*/
typedef struct {
int win[4]; /* X, Y, Z, ? */
unsigned char color[4]; /* R, G, B, A */
} MGAvertex;
void mga_draw_line_rgb_flat (const MGAvertex *v1, const MGAvertex *v2);
void mga_draw_line_rgb_flat_zless (const MGAvertex *v1, const MGAvertex *v2);
void mga_draw_line_rgb_iter (const MGAvertex *v1, const MGAvertex *v2);
void mga_draw_line_rgb_iter_zless (const MGAvertex *v1, const MGAvertex *v2);
void mga_draw_tri_rgb_flat (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3);
void mga_draw_tri_rgb_flat_zless (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3);
void mga_draw_tri_rgb_iter (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3);
void mga_draw_tri_rgb_iter_zless (int cull, const MGAvertex *v1, const MGAvertex *v2, const MGAvertex *v3);
void mga_draw_rect_rgb_flat (int left, int top, int width, int height, int color);
void mga_draw_rect_rgb_tx32 (int left, int top, int width, int height, const unsigned long *bitmap);
void mga_draw_rect_rgb_tx24 (int left, int top, int width, int height, const unsigned long *bitmap);
void mga_draw_span_rgb_tx32 (int left, int top, int width, const unsigned long *bitmap);
void mga_draw_span_rgb_tx24 (int left, int top, int width, const unsigned long *bitmap);
void mga_iload_32RGB (int left, int top, int width, int height, const unsigned long *bitmap);
void mga_iload_24RGB (int left, int top, int width, int height, const unsigned long *bitmap);
#endif

View file

@ -1,416 +1,416 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W HW mapping
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <crt0.h>
#include <dpmi.h>
#include <pc.h>
#include <string.h>
#include <sys/nearptr.h>
#include <sys/segments.h>
#include "../internal.h"
#include "mga_reg.h"
#include "mga_hw.h"
/* Hack alert:
* these should really be externs
*/
/* PCI access routines */
static int pci_find_device (int deviceID, int vendorID, int deviceIndex, int *handle);
static unsigned long pci_read_long (int handle, int index);
static void pci_write_long (int handle, int index, unsigned long value);
/* PCI device identifiers */
#define MATROX_VENDOR_ID 0x102B
typedef enum {
MATROX_MILL_ID = 0x0519
} MATROX_ID;
static MATROX_ID matrox_id_list[] = {
MATROX_MILL_ID,
0
};
/* internal hardware data structures */
#if !MGA_FARPTR
static int dirty;
#endif
static int bus_id;
static unsigned long reg40;
static unsigned long io_mem_base[4], linear_base;
static unsigned long io_mem_size[4], linear_size;
static MATROX_ID matrox_id;
/* interface structures containing hardware pointer data */
MGA_HWPTR mgaptr;
/* Desc: create MMAP
*
* In :
* Out :
*
* Note:
*/
static int _create_mmap (__dpmi_paddr *m, unsigned long base, unsigned long size)
{
#if MGA_FARPTR
int sel;
if (_create_selector(&sel, base, size)) {
return -1;
}
m->selector = sel;
m->offset32 = 0;
#else
m->selector = _my_ds();
if (_create_linear_mapping(&m->offset32, base, size)) {
return -1;
}
m->offset32 -= __djgpp_base_address;
#endif
return 0;
}
/* Desc: destroy MMAP
*
* In :
* Out :
*
* Note:
*/
static void _destroy_mmap (__dpmi_paddr *m)
{
#if MGA_FARPTR
int sel = m->selector;
_remove_selector(&sel);
#else
m->offset32 += __djgpp_base_address;
_remove_linear_mapping(&m->offset32);
#endif
m->selector = 0;
m->offset32 = 0;
}
/* Desc: Counts amount of installed RAM
*
* In :
* Out :
*
* Note:
*/
static int _mga_get_vram (MATROX_ID chip, unsigned long base)
{
int ProbeSize = 8;
int SizeFound = 2;
unsigned char tmp;
int i;
__dpmi_paddr fb;
switch (chip) {
case MATROX_MILL_ID:
ProbeSize = 8;
break;
}
if (_create_mmap(&fb, base, ProbeSize*1024*1024)) {
return 0;
}
/* turn MGA mode on - enable linear frame buffer (CRTCEXT3) */
mga_select();
mga_outb(M_CRTC_EXT_INDEX, 3);
tmp = mga_inb(M_CRTC_EXT_DATA);
mga_outb(M_CRTC_EXT_DATA, tmp | M_MGAMODE);
/* write, read and compare method */
for (i=ProbeSize; i>2; i-= 2) {
hwptr_pokeb(fb, i*1024*1024 - 1, 0xAA);
mga_select();
mga_outb(M_CRTC_INDEX, 0); /* flush the cache */
mga_inl(M_STATUS); /* delay */
mga_inl(M_STATUS); /* delay */
mga_inl(M_STATUS); /* delay */
if (hwptr_peekb(fb, i*1024*1024 - 1) == 0xAA) {
SizeFound = i;
break;
}
}
/* restore CRTCEXT3 state */
mga_select();
mga_outb(M_CRTC_EXT_INDEX, 3);
mga_outb(M_CRTC_EXT_DATA, tmp);
_destroy_mmap(&fb);
return SizeFound*1024*1024;
}
/* Desc: Frees all resources allocated by MGA init code.
*
* In :
* Out :
*
* Note:
*/
void mga_hw_fini (void)
{
int i;
pci_write_long(bus_id, 0x40, reg40);
for (i=0; i<4; i++) {
_destroy_mmap(&mgaptr.io_mem_map[i]);
}
_destroy_mmap(&mgaptr.linear_map);
#if !MGA_FARPTR
if (dirty) {
__djgpp_nearptr_disable();
dirty = FALSE;
}
#endif
matrox_id = 0;
}
/* Desc: Attempts to detect MGA.
*
* In :
* Out :
*
* Note: The first thing ever to be called. This is in charge of filling in
* the driver header with all the required information and function
* pointers. We do not yet have access to the video memory, so we can't
* talk directly to the card.
*/
int mga_hw_init (unsigned long *vram, int *interleave, char *name)
{
int i;
unsigned long pci_base[2];
if (matrox_id) {
return matrox_id;
}
#if !MGA_FARPTR
/* enable nearptr access */
if (_crt0_startup_flags & _CRT0_FLAG_NEARPTR) {
dirty = FALSE;
} else {
if (__djgpp_nearptr_enable() == 0)
return NULL;
dirty = TRUE;
}
#endif
/* find PCI device */
matrox_id = 0;
for (bus_id=0, i=0; matrox_id_list[i]; i++) {
if (pci_find_device(matrox_id_list[i], MATROX_VENDOR_ID, 0, &bus_id)) {
matrox_id = matrox_id_list[i];
break;
}
}
/* set up the card name */
switch (matrox_id) {
case MATROX_MILL_ID:
if (name) strcpy(name, "Millennium");
break;
default:
matrox_id = 0;
return -1;
}
reg40 = pci_read_long(bus_id, 0x40);
#if 0 /* overclock a little :) */
{
int rfhcnt = (reg40 >> 16) & 0xF;
if ((reg40 & 0x200000) && (rfhcnt < 0xC)) {
pci_write_long(bus_id, 0x40, (reg40 & 0xFFF0FFFF) | 0x000C0000);
}
}
#endif
/* read hardware configuration data */
for (i=0; i<2; i++)
pci_base[i] = pci_read_long(bus_id, 16+i*4);
/* work out the linear framebuffer and MMIO addresses */
if (matrox_id == MATROX_MILL_ID) {
if (pci_base[0])
io_mem_base[0] = pci_base[0] & 0xFFFFC000;
if (pci_base[1])
linear_base = pci_base[1] & 0xFF800000;
}
if (!linear_base || !io_mem_base[0])
return NULL;
/* deal with the memory mapping crap */
io_mem_size[0] = 0x4000;
for (i=0; i<4; i++) {
if (io_mem_base[i]) {
if (_create_mmap(&mgaptr.io_mem_map[i], io_mem_base[i], io_mem_size[i])) {
mga_hw_fini();
return NULL;
}
}
}
*vram = linear_size = _mga_get_vram(matrox_id, linear_base);
if (_create_mmap(&mgaptr.linear_map, linear_base, linear_size)) {
mga_hw_fini();
return NULL;
}
/* fill in user data */
*interleave = linear_size > 2*1024*1024;
return matrox_id;
}
/* PCI routines added by SET */
#define PCIAddr 0xCF8
#define PCIData 0xCFC
#define PCIEnable 0x80000000
/* FindPCIDevice:
* Replacement for the INT 1A - PCI BIOS v2.0c+ - FIND PCI DEVICE, AX = B102h
*
* Note: deviceIndex is because a card can hold more than one PCI chip.
*
* Searches the board of the vendor supplied in vendorID with
* identification number deviceID and index deviceIndex (normally 0).
* The value returned in handle can be used to access the PCI registers
* of this board.
*
* Return: 1 if found 0 if not found.
*/
static int pci_find_device (int deviceID, int vendorID, int deviceIndex, int *handle)
{
int model, vendor, card, device;
unsigned value, full_id, bus, busMax;
deviceIndex <<= 8;
/* for each PCI bus */
for (bus=0, busMax=0x10000; bus<busMax; bus+=0x10000) {
/* for each hardware device */
for (device=0, card=0; card<32; card++, device+=0x800) {
value = PCIEnable | bus | deviceIndex | device;
outportl(PCIAddr, value);
full_id = inportl(PCIData);
/* get the vendor and model ID */
vendor = full_id & 0xFFFF;
model = full_id >> 16;
if (vendor != 0xFFFF) {
/* is this the one we want? */
if ((deviceID == model) && (vendorID == vendor)) {
*handle = value;
return 1;
}
/* is it a bridge to a secondary bus? */
outportl(PCIAddr, value | 8);
if (((inportl(PCIData) >> 16) == 0x0600) || (full_id==0x00011011))
busMax += 0x10000;
}
}
}
return 0;
}
/* Desc:
*
* In :
* Out :
*
* Note:
*/
static unsigned long pci_read_long (int handle, int index)
{
outportl(PCIAddr, PCIEnable | handle | index);
return inportl(PCIData);
}
/* Desc:
*
* In :
* Out :
*
* Note:
*/
static void pci_write_long (int handle, int index, unsigned long value)
{
outportl(PCIAddr, PCIEnable | handle | index);
outportl(PCIData, value);
}
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.4 for Mesa -- MGA2064W HW mapping
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <crt0.h>
#include <dpmi.h>
#include <pc.h>
#include <string.h>
#include <sys/nearptr.h>
#include <sys/segments.h>
#include "../internal.h"
#include "mga_reg.h"
#include "mga_hw.h"
/* Hack alert:
* these should really be externs
*/
/* PCI access routines */
static int pci_find_device (int deviceID, int vendorID, int deviceIndex, int *handle);
static unsigned long pci_read_long (int handle, int index);
static void pci_write_long (int handle, int index, unsigned long value);
/* PCI device identifiers */
#define MATROX_VENDOR_ID 0x102B
typedef enum {
MATROX_MILL_ID = 0x0519
} MATROX_ID;
static MATROX_ID matrox_id_list[] = {
MATROX_MILL_ID,
0
};
/* internal hardware data structures */
#if !MGA_FARPTR
static int dirty;
#endif
static int bus_id;
static unsigned long reg40;
static unsigned long io_mem_base[4], linear_base;
static unsigned long io_mem_size[4], linear_size;
static MATROX_ID matrox_id;
/* interface structures containing hardware pointer data */
MGA_HWPTR mgaptr;
/* Desc: create MMAP
*
* In :
* Out :
*
* Note:
*/
static int _create_mmap (__dpmi_paddr *m, unsigned long base, unsigned long size)
{
#if MGA_FARPTR
int sel;
if (_create_selector(&sel, base, size)) {
return -1;
}
m->selector = sel;
m->offset32 = 0;
#else
m->selector = _my_ds();
if (_create_linear_mapping(&m->offset32, base, size)) {
return -1;
}
m->offset32 -= __djgpp_base_address;
#endif
return 0;
}
/* Desc: destroy MMAP
*
* In :
* Out :
*
* Note:
*/
static void _destroy_mmap (__dpmi_paddr *m)
{
#if MGA_FARPTR
int sel = m->selector;
_remove_selector(&sel);
#else
m->offset32 += __djgpp_base_address;
_remove_linear_mapping(&m->offset32);
#endif
m->selector = 0;
m->offset32 = 0;
}
/* Desc: Counts amount of installed RAM
*
* In :
* Out :
*
* Note:
*/
static int _mga_get_vram (MATROX_ID chip, unsigned long base)
{
int ProbeSize = 8;
int SizeFound = 2;
unsigned char tmp;
int i;
__dpmi_paddr fb;
switch (chip) {
case MATROX_MILL_ID:
ProbeSize = 8;
break;
}
if (_create_mmap(&fb, base, ProbeSize*1024*1024)) {
return 0;
}
/* turn MGA mode on - enable linear frame buffer (CRTCEXT3) */
mga_select();
mga_outb(M_CRTC_EXT_INDEX, 3);
tmp = mga_inb(M_CRTC_EXT_DATA);
mga_outb(M_CRTC_EXT_DATA, tmp | M_MGAMODE);
/* write, read and compare method */
for (i=ProbeSize; i>2; i-= 2) {
hwptr_pokeb(fb, i*1024*1024 - 1, 0xAA);
mga_select();
mga_outb(M_CRTC_INDEX, 0); /* flush the cache */
mga_inl(M_STATUS); /* delay */
mga_inl(M_STATUS); /* delay */
mga_inl(M_STATUS); /* delay */
if (hwptr_peekb(fb, i*1024*1024 - 1) == 0xAA) {
SizeFound = i;
break;
}
}
/* restore CRTCEXT3 state */
mga_select();
mga_outb(M_CRTC_EXT_INDEX, 3);
mga_outb(M_CRTC_EXT_DATA, tmp);
_destroy_mmap(&fb);
return SizeFound*1024*1024;
}
/* Desc: Frees all resources allocated by MGA init code.
*
* In :
* Out :
*
* Note:
*/
void mga_hw_fini (void)
{
int i;
pci_write_long(bus_id, 0x40, reg40);
for (i=0; i<4; i++) {
_destroy_mmap(&mgaptr.io_mem_map[i]);
}
_destroy_mmap(&mgaptr.linear_map);
#if !MGA_FARPTR
if (dirty) {
__djgpp_nearptr_disable();
dirty = FALSE;
}
#endif
matrox_id = 0;
}
/* Desc: Attempts to detect MGA.
*
* In :
* Out :
*
* Note: The first thing ever to be called. This is in charge of filling in
* the driver header with all the required information and function
* pointers. We do not yet have access to the video memory, so we can't
* talk directly to the card.
*/
int mga_hw_init (unsigned long *vram, int *interleave, char *name)
{
int i;
unsigned long pci_base[2];
if (matrox_id) {
return matrox_id;
}
#if !MGA_FARPTR
/* enable nearptr access */
if (_crt0_startup_flags & _CRT0_FLAG_NEARPTR) {
dirty = FALSE;
} else {
if (__djgpp_nearptr_enable() == 0)
return 0;
dirty = TRUE;
}
#endif
/* find PCI device */
matrox_id = 0;
for (bus_id=0, i=0; matrox_id_list[i]; i++) {
if (pci_find_device(matrox_id_list[i], MATROX_VENDOR_ID, 0, &bus_id)) {
matrox_id = matrox_id_list[i];
break;
}
}
/* set up the card name */
switch (matrox_id) {
case MATROX_MILL_ID:
if (name) strcpy(name, "Millennium");
break;
default:
matrox_id = 0;
return -1;
}
reg40 = pci_read_long(bus_id, 0x40);
#if 0 /* overclock a little :) */
{
int rfhcnt = (reg40 >> 16) & 0xF;
if ((reg40 & 0x200000) && (rfhcnt < 0xC)) {
pci_write_long(bus_id, 0x40, (reg40 & 0xFFF0FFFF) | 0x000C0000);
}
}
#endif
/* read hardware configuration data */
for (i=0; i<2; i++)
pci_base[i] = pci_read_long(bus_id, 16+i*4);
/* work out the linear framebuffer and MMIO addresses */
if (matrox_id == MATROX_MILL_ID) {
if (pci_base[0])
io_mem_base[0] = pci_base[0] & 0xFFFFC000;
if (pci_base[1])
linear_base = pci_base[1] & 0xFF800000;
}
if (!linear_base || !io_mem_base[0])
return 0;
/* deal with the memory mapping crap */
io_mem_size[0] = 0x4000;
for (i=0; i<4; i++) {
if (io_mem_base[i]) {
if (_create_mmap(&mgaptr.io_mem_map[i], io_mem_base[i], io_mem_size[i])) {
mga_hw_fini();
return 0;
}
}
}
*vram = linear_size = _mga_get_vram(matrox_id, linear_base);
if (_create_mmap(&mgaptr.linear_map, linear_base, linear_size)) {
mga_hw_fini();
return 0;
}
/* fill in user data */
*interleave = linear_size > 2*1024*1024;
return matrox_id;
}
/* PCI routines added by SET */
#define PCIAddr 0xCF8
#define PCIData 0xCFC
#define PCIEnable 0x80000000
/* FindPCIDevice:
* Replacement for the INT 1A - PCI BIOS v2.0c+ - FIND PCI DEVICE, AX = B102h
*
* Note: deviceIndex is because a card can hold more than one PCI chip.
*
* Searches the board of the vendor supplied in vendorID with
* identification number deviceID and index deviceIndex (normally 0).
* The value returned in handle can be used to access the PCI registers
* of this board.
*
* Return: 1 if found 0 if not found.
*/
static int pci_find_device (int deviceID, int vendorID, int deviceIndex, int *handle)
{
int model, vendor, card, device;
unsigned value, full_id, bus, busMax;
deviceIndex <<= 8;
/* for each PCI bus */
for (bus=0, busMax=0x10000; bus<busMax; bus+=0x10000) {
/* for each hardware device */
for (device=0, card=0; card<32; card++, device+=0x800) {
value = PCIEnable | bus | deviceIndex | device;
outportl(PCIAddr, value);
full_id = inportl(PCIData);
/* get the vendor and model ID */
vendor = full_id & 0xFFFF;
model = full_id >> 16;
if (vendor != 0xFFFF) {
/* is this the one we want? */
if ((deviceID == model) && (vendorID == vendor)) {
*handle = value;
return 1;
}
/* is it a bridge to a secondary bus? */
outportl(PCIAddr, value | 8);
if (((inportl(PCIData) >> 16) == 0x0600) || (full_id==0x00011011))
busMax += 0x10000;
}
}
}
return 0;
}
/* Desc:
*
* In :
* Out :
*
* Note:
*/
static unsigned long pci_read_long (int handle, int index)
{
outportl(PCIAddr, PCIEnable | handle | index);
return inportl(PCIData);
}
/* Desc:
*
* In :
* Out :
*
* Note:
*/
static void pci_write_long (int handle, int index, unsigned long value)
{
outportl(PCIAddr, PCIEnable | handle | index);
outportl(PCIData, value);
}

View file

@ -1,113 +1,113 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W HW mapping
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef MGA_HW_included
#define MGA_HW_included
/* set this to zero to use near pointers */
#define MGA_FARPTR 1
/* access macros */
#if MGA_FARPTR
#include <sys/farptr.h>
#define hwptr_pokeb(ptr, off, val) _farpokeb((ptr).selector, (ptr).offset32+(off), (val))
#define hwptr_pokew(ptr, off, val) _farpokew((ptr).selector, (ptr).offset32+(off), (val))
#define hwptr_pokel(ptr, off, val) _farpokel((ptr).selector, (ptr).offset32+(off), (val))
#define hwptr_peekb(ptr, off) _farpeekb((ptr).selector, (ptr).offset32+(off))
#define hwptr_peekw(ptr, off) _farpeekw((ptr).selector, (ptr).offset32+(off))
#define hwptr_peekl(ptr, off) _farpeekl((ptr).selector, (ptr).offset32+(off))
#define hwptr_select(ptr) _farsetsel((ptr).selector)
#define hwptr_unselect(ptr) (ptr).selector = _fargetsel()
#define hwptr_nspokeb(ptr, off, val) _farnspokeb((ptr).offset32+(off), (val))
#define hwptr_nspokew(ptr, off, val) _farnspokew((ptr).offset32+(off), (val))
#define hwptr_nspokel(ptr, off, val) _farnspokel((ptr).offset32+(off), (val))
#define hwptr_nspeekb(ptr, off) _farnspeekb((ptr).offset32+(off))
#define hwptr_nspeekw(ptr, off) _farnspeekw((ptr).offset32+(off))
#define hwptr_nspeekl(ptr, off) _farnspeekl((ptr).offset32+(off))
#else
#define hwptr_pokeb(ptr, off, val) *((volatile unsigned char *)((ptr).offset32+(off))) = (val)
#define hwptr_pokew(ptr, off, val) *((volatile unsigned short *)((ptr).offset32+(off))) = (val)
#define hwptr_pokel(ptr, off, val) *((volatile unsigned long *)((ptr).offset32+(off))) = (val)
#define hwptr_peekb(ptr, off) (*((volatile unsigned char *)((ptr).offset32+(off))))
#define hwptr_peekw(ptr, off) (*((volatile unsigned short *)((ptr).offset32+(off))))
#define hwptr_peekl(ptr, off) (*((volatile unsigned long *)((ptr).offset32+(off))))
#define hwptr_select(ptr)
#define hwptr_unselect(ptr)
#define hwptr_nspokeb(ptr, off, val) *((volatile unsigned char *)((ptr).offset32+(off))) = (val)
#define hwptr_nspokew(ptr, off, val) *((volatile unsigned short *)((ptr).offset32+(off))) = (val)
#define hwptr_nspokel(ptr, off, val) *((volatile unsigned long *)((ptr).offset32+(off))) = (val)
#define hwptr_nspeekb(ptr, off) (*((volatile unsigned char *)((ptr).offset32+(off))))
#define hwptr_nspeekw(ptr, off) (*((volatile unsigned short *)((ptr).offset32+(off))))
#define hwptr_nspeekl(ptr, off) (*((volatile unsigned long *)((ptr).offset32+(off))))
#endif
/* helpers for accessing the Matrox registers */
#define mga_select() hwptr_select(mgaptr.io_mem_map[0])
#define mga_inb(addr) hwptr_nspeekb(mgaptr.io_mem_map[0], addr)
#define mga_inw(addr) hwptr_nspeekw(mgaptr.io_mem_map[0], addr)
#define mga_inl(addr) hwptr_nspeekl(mgaptr.io_mem_map[0], addr)
#define mga_outb(addr, val) hwptr_nspokeb(mgaptr.io_mem_map[0], addr, val)
#define mga_outw(addr, val) hwptr_nspokew(mgaptr.io_mem_map[0], addr, val)
#define mga_outl(addr, val) hwptr_nspokel(mgaptr.io_mem_map[0], addr, val)
typedef struct MGA_HWPTR {
__dpmi_paddr io_mem_map[4], linear_map;
} MGA_HWPTR;
extern MGA_HWPTR mgaptr;
void mga_hw_fini (void);
int mga_hw_init (unsigned long *vram, int *interleave, char *name);
#endif
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W HW mapping
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef MGA_HW_included
#define MGA_HW_included
/* set this to zero to use near pointers */
#define MGA_FARPTR 1
/* access macros */
#if MGA_FARPTR
#include <sys/farptr.h>
#define hwptr_pokeb(ptr, off, val) _farpokeb((ptr).selector, (ptr).offset32+(off), (val))
#define hwptr_pokew(ptr, off, val) _farpokew((ptr).selector, (ptr).offset32+(off), (val))
#define hwptr_pokel(ptr, off, val) _farpokel((ptr).selector, (ptr).offset32+(off), (val))
#define hwptr_peekb(ptr, off) _farpeekb((ptr).selector, (ptr).offset32+(off))
#define hwptr_peekw(ptr, off) _farpeekw((ptr).selector, (ptr).offset32+(off))
#define hwptr_peekl(ptr, off) _farpeekl((ptr).selector, (ptr).offset32+(off))
#define hwptr_select(ptr) _farsetsel((ptr).selector)
#define hwptr_unselect(ptr) (ptr).selector = _fargetsel()
#define hwptr_nspokeb(ptr, off, val) _farnspokeb((ptr).offset32+(off), (val))
#define hwptr_nspokew(ptr, off, val) _farnspokew((ptr).offset32+(off), (val))
#define hwptr_nspokel(ptr, off, val) _farnspokel((ptr).offset32+(off), (val))
#define hwptr_nspeekb(ptr, off) _farnspeekb((ptr).offset32+(off))
#define hwptr_nspeekw(ptr, off) _farnspeekw((ptr).offset32+(off))
#define hwptr_nspeekl(ptr, off) _farnspeekl((ptr).offset32+(off))
#else
#define hwptr_pokeb(ptr, off, val) *((volatile unsigned char *)((ptr).offset32+(off))) = (val)
#define hwptr_pokew(ptr, off, val) *((volatile unsigned short *)((ptr).offset32+(off))) = (val)
#define hwptr_pokel(ptr, off, val) *((volatile unsigned long *)((ptr).offset32+(off))) = (val)
#define hwptr_peekb(ptr, off) (*((volatile unsigned char *)((ptr).offset32+(off))))
#define hwptr_peekw(ptr, off) (*((volatile unsigned short *)((ptr).offset32+(off))))
#define hwptr_peekl(ptr, off) (*((volatile unsigned long *)((ptr).offset32+(off))))
#define hwptr_select(ptr)
#define hwptr_unselect(ptr)
#define hwptr_nspokeb(ptr, off, val) *((volatile unsigned char *)((ptr).offset32+(off))) = (val)
#define hwptr_nspokew(ptr, off, val) *((volatile unsigned short *)((ptr).offset32+(off))) = (val)
#define hwptr_nspokel(ptr, off, val) *((volatile unsigned long *)((ptr).offset32+(off))) = (val)
#define hwptr_nspeekb(ptr, off) (*((volatile unsigned char *)((ptr).offset32+(off))))
#define hwptr_nspeekw(ptr, off) (*((volatile unsigned short *)((ptr).offset32+(off))))
#define hwptr_nspeekl(ptr, off) (*((volatile unsigned long *)((ptr).offset32+(off))))
#endif
/* helpers for accessing the Matrox registers */
#define mga_select() hwptr_select(mgaptr.io_mem_map[0])
#define mga_inb(addr) hwptr_nspeekb(mgaptr.io_mem_map[0], addr)
#define mga_inw(addr) hwptr_nspeekw(mgaptr.io_mem_map[0], addr)
#define mga_inl(addr) hwptr_nspeekl(mgaptr.io_mem_map[0], addr)
#define mga_outb(addr, val) hwptr_nspokeb(mgaptr.io_mem_map[0], addr, val)
#define mga_outw(addr, val) hwptr_nspokew(mgaptr.io_mem_map[0], addr, val)
#define mga_outl(addr, val) hwptr_nspokel(mgaptr.io_mem_map[0], addr, val)
typedef struct MGA_HWPTR {
__dpmi_paddr io_mem_map[4], linear_map;
} MGA_HWPTR;
extern MGA_HWPTR mgaptr;
void mga_hw_fini (void);
int mga_hw_init (unsigned long *vram, int *interleave, char *name);
#endif

View file

@ -1,231 +1,231 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W mode switching
*
* Copyright (c) 2003 - 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/farptr.h>
#include <sys/movedata.h>
#include <sys/segments.h>
#include "../internal.h"
#include "mga_mode.h"
static MGA_MODE oldmode;
static MGA_MODE modes[64];
/*
* 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
/* Desc: get available modes
*
* In : -
* Out : linear modes list ptr
*
* Note: shouldn't use VESA...
*/
static MGA_MODE *_mga_mode_check (void)
{
__dpmi_regs r;
word16 *p;
MGA_MODE *q;
char vesa_info[512], tmp[512];
_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 NULL;
}
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 8:
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 && (tmp[M_ATTR]&0x80)) {
q->xres = _16_ tmp[M_XRES];
q->yres = _16_ tmp[M_YRES];
q->mode |= 0x4000;
q++;
}
} while (TRUE);
return modes;
}
/* Desc: save current mode
*
* In : ptr to mode structure
* Out : 0 if success
*
* Note: shouldn't use VESA...
*/
static int _mga_mode_save (MGA_MODE *p)
{
__asm("\n\
movw $0x4f03, %%ax \n\
int $0x10 \n\
movl %%ebx, %0 \n\
":"=g"(p->mode)::"%eax", "%ebx");
return 0;
}
/* Desc: switch to specified mode
*
* In : ptr to mode structure, refresh rate
* Out : 0 if success
*
* Note: shouldn't use VESA...
*/
int mga_mode_switch (MGA_MODE *p, int refresh)
{
if (oldmode.mode == 0) {
_mga_mode_save(&oldmode);
}
__asm("movw $0x4f02, %%ax; int $0x10"::"b"(p->mode):"%eax");
return 0;
(void)refresh; /* silence compiler warning */
}
/* Desc: restore to the mode prior to first call to `mga_switch'
*
* In : -
* Out : 0 if success
*
* Note: shouldn't use VESA...
*/
int mga_mode_restore (void)
{
if (oldmode.mode != 0) {
__asm("movw $0x4f02, %%ax; int $0x10"::"b"(oldmode.mode):"%eax");
oldmode.mode = 0;
}
return 0;
}
/* Desc: return suitable mode
*
* In : width, height, bpp
* Out : ptr to mode structure
*
* Note: -
*/
MGA_MODE *mga_mode_find (int width, int height, int bpp)
{
static MGA_MODE *q = NULL;
MGA_MODE *p;
unsigned int min;
if (q == NULL) {
if ((q = _mga_mode_check()) == NULL) {
return NULL;
}
}
/* search for a mode that fits our request */
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;
}
}
}
return p;
}
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W mode switching
*
* Copyright (c) 2003 - 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/farptr.h>
#include <sys/movedata.h>
#include <sys/segments.h>
#include "../internal.h"
#include "mga_mode.h"
static MGA_MODE oldmode;
static MGA_MODE modes[64];
/*
* 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
/* Desc: get available modes
*
* In : -
* Out : linear modes list ptr
*
* Note: shouldn't use VESA...
*/
static MGA_MODE *_mga_mode_check (void)
{
__dpmi_regs r;
word16 *p;
MGA_MODE *q;
char vesa_info[512], tmp[512];
_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 NULL;
}
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 8:
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 && (tmp[M_ATTR]&0x80)) {
q->xres = _16_ tmp[M_XRES];
q->yres = _16_ tmp[M_YRES];
q->mode |= 0x4000;
q++;
}
} while (TRUE);
return modes;
}
/* Desc: save current mode
*
* In : ptr to mode structure
* Out : 0 if success
*
* Note: shouldn't use VESA...
*/
static int _mga_mode_save (MGA_MODE *p)
{
__asm("\n\
movw $0x4f03, %%ax \n\
int $0x10 \n\
movl %%ebx, %0 \n\
":"=g"(p->mode)::"%eax", "%ebx");
return 0;
}
/* Desc: switch to specified mode
*
* In : ptr to mode structure, refresh rate
* Out : 0 if success
*
* Note: shouldn't use VESA...
*/
int mga_mode_switch (MGA_MODE *p, int refresh)
{
if (oldmode.mode == 0) {
_mga_mode_save(&oldmode);
}
__asm("movw $0x4f02, %%ax; int $0x10"::"b"(p->mode):"%eax");
return 0;
(void)refresh; /* silence compiler warning */
}
/* Desc: restore to the mode prior to first call to `mga_switch'
*
* In : -
* Out : 0 if success
*
* Note: shouldn't use VESA...
*/
int mga_mode_restore (void)
{
if (oldmode.mode != 0) {
__asm("movw $0x4f02, %%ax; int $0x10"::"b"(oldmode.mode):"%eax");
oldmode.mode = 0;
}
return 0;
}
/* Desc: return suitable mode
*
* In : width, height, bpp
* Out : ptr to mode structure
*
* Note: -
*/
MGA_MODE *mga_mode_find (int width, int height, int bpp)
{
static MGA_MODE *q = NULL;
MGA_MODE *p;
unsigned int min;
if (q == NULL) {
if ((q = _mga_mode_check()) == NULL) {
return NULL;
}
}
/* search for a mode that fits our request */
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;
}
}
}
return p;
}

View file

@ -1,47 +1,47 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W mode switching
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef MGA_MODE_included
#define MGA_MODE_included
typedef struct MGA_MODE {
int mode;
int xres, yres;
int bpp;
} MGA_MODE;
int mga_mode_switch (MGA_MODE *p, int refresh);
int mga_mode_restore (void);
MGA_MODE *mga_mode_find (int width, int height, int bpp);
#endif
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W mode switching
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef MGA_MODE_included
#define MGA_MODE_included
typedef struct MGA_MODE {
int mode;
int xres, yres;
int bpp;
} MGA_MODE;
int mga_mode_switch (MGA_MODE *p, int refresh);
int mga_mode_restore (void);
MGA_MODE *mga_mode_find (int width, int height, int bpp);
#endif

View file

@ -1,207 +1,207 @@
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W register mnemonics
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef MGA_REG_H_included
#define MGA_REG_H_included
/* Matrox hardware registers: */
#define M_AR0 0x1C60
#define M_AR1 0x1C64
#define M_AR2 0x1C68
#define M_AR3 0x1C6C
#define M_AR4 0x1C70
#define M_AR5 0x1C74
#define M_AR6 0x1C78
#define M_BCOL 0x1C20
#define M_CXBNDRY 0x1C80
#define M_CXLEFT 0x1CA0
#define M_CXRIGHT 0x1CA4
#define M_DR0 0x1CC0
#define M_DR2 0x1CC8
#define M_DR3 0x1CCC
#define M_DR4 0x1CD0
#define M_DR6 0x1CD8
#define M_DR7 0x1CDC
#define M_DR8 0x1CE0
#define M_DR10 0x1CE8
#define M_DR11 0x1CEC
#define M_DR12 0x1CF0
#define M_DR14 0x1CF8
#define M_DR15 0x1CFC
#define M_DWGCTL 0x1C00
#define M_FCOL 0x1C24
#define M_FIFOSTATUS 0x1E10
#define M_FXBNDRY 0x1C84
#define M_FXLEFT 0x1CA8
#define M_FXRIGHT 0x1CAC
#define M_ICLEAR 0x1E18
#define M_IEN 0x1E1C
#define M_LEN 0x1C5C
#define M_MACCESS 0x1C04
#define M_OPMODE 0x1E54
#define M_PAT0 0x1C10
#define M_PAT1 0x1C14
#define M_PITCH 0x1C8C
#define M_PLNWT 0x1C1C
#define M_RESET 0x1E40
#define M_SGN 0x1C58
#define M_SHIFT 0x1C50
#define M_SRC0 0x1C30
#define M_SRC1 0x1C34
#define M_SRC2 0x1C38
#define M_SRC3 0x1C3C
#define M_STATUS 0x1E14
#define M_VCOUNT 0x1E20
#define M_XDST 0x1CB0
#define M_XYEND 0x1C44
#define M_XYSTRT 0x1C40
#define M_YBOT 0x1C9C
#define M_YDST 0x1C90
#define M_YDSTLEN 0x1C88
#define M_YDSTORG 0x1C94
#define M_YTOP 0x1C98
#define M_ZORG 0x1C0C
#define M_EXEC 0x0100
/* DWGCTL: opcod */
#define M_DWG_LINE_OPEN 0x0
#define M_DWG_AUTOLINE_OPEN 0x1
#define M_DWG_LINE_CLOSE 0x2
#define M_DWG_AUTOLINE_CLOSE 0x3
#define M_DWG_TRAP 0x4
#define M_DWG_TEXTURE_TRAP 0x5
#define M_DWG_BITBLT 0x8
#define M_DWG_FBITBLT 0xC
#define M_DWG_ILOAD 0x9
#define M_DWG_ILOAD_SCALE 0xD
#define M_DWG_ILOAD_FILTER 0xF
#define M_DWG_IDUMP 0xA
/* DWGCTL: atype */
#define M_DWG_RPL (0x0 << 4)
#define M_DWG_RSTR (0x1 << 4)
#define M_DWG_ZI (0x3 << 4)
#define M_DWG_BLK (0x4 << 4)
#define M_DWG_I (0x7 << 4)
/* DWGCTL: linear */
#define M_DWG_LINEAR (0x1 << 7)
/* DWGCTL: zmode */
#define M_DWG_NOZCMP (0x0 << 8)
#define M_DWG_ZE (0x2 << 8)
#define M_DWG_ZNE (0x3 << 8)
#define M_DWG_ZLT (0x4 << 8)
#define M_DWG_ZLTE (0x5 << 8)
#define M_DWG_ZGT (0x6 << 8)
#define M_DWG_ZGTE (0x7 << 8)
/* DWGCTL: solid */
#define M_DWG_SOLID (0x1 << 11)
/* DWGCTL: arzero */
#define M_DWG_ARZERO (0x1 << 12)
/* DWGCTL: sgnzero */
#define M_DWG_SGNZERO (0x1 << 13)
/* DWGCTL: shiftzero */
#define M_DWG_SHFTZERO (0x1 << 14)
/* DWGCTL: bop */
#define M_DWG_BOP_XOR (0x6 << 16)
#define M_DWG_BOP_AND (0x8 << 16)
#define M_DWG_BOP_SRC (0xC << 16)
#define M_DWG_BOP_OR (0xE << 16)
/* DWGCTL: trans */
#define M_DWG_TRANS_0 (0x0 << 20)
#define M_DWG_TRANS_1 (0x1 << 20)
#define M_DWG_TRANS_2 (0x2 << 20)
#define M_DWG_TRANS_3 (0x3 << 20)
#define M_DWG_TRANS_4 (0x4 << 20)
#define M_DWG_TRANS_5 (0x5 << 20)
#define M_DWG_TRANS_6 (0x6 << 20)
#define M_DWG_TRANS_7 (0x7 << 20)
#define M_DWG_TRANS_8 (0x8 << 20)
#define M_DWG_TRANS_9 (0x9 << 20)
#define M_DWG_TRANS_A (0xA << 20)
#define M_DWG_TRANS_B (0xB << 20)
#define M_DWG_TRANS_C (0xC << 20)
#define M_DWG_TRANS_D (0xD << 20)
#define M_DWG_TRANS_E (0xE << 20)
#define M_DWG_TRANS_F (0xF << 20)
/* DWGCTL: bltmod */
#define M_DWG_BMONOLEF (0x0 << 25)
#define M_DWG_BMONOWF (0x4 << 25)
#define M_DWG_BPLAN (0x1 << 25)
#define M_DWG_BFCOL (0x2 << 25)
#define M_DWG_BUYUV (0xE << 25)
#define M_DWG_BU32BGR (0x3 << 25)
#define M_DWG_BU32RGB (0x7 << 25)
#define M_DWG_BU24BGR (0xB << 25)
#define M_DWG_BU24RGB (0xF << 25)
/* DWGCTL: pattern */
#define M_DWG_PATTERN (0x1 << 29)
/* DWGCTL: transc */
#define M_DWG_TRANSC (0x1 << 30)
/* OPMODE: */
#define M_DMA_GENERAL (0x0 << 2)
#define M_DMA_BLIT (0x1 << 2)
#define M_DMA_VECTOR (0x2 << 2)
/* SGN: */
#define M_SDXL (0x1 << 1)
#define M_SDXR (0x1 << 5)
/* VGAREG */
#define M_CRTC_INDEX 0x1FD4
#define M_CRTC_DATA 0x1FD5
#define M_CRTC_EXT_INDEX 0x1FDE
#define M_CRTC_EXT_DATA 0x1FDF
#define M_MISC_R 0x1FCC
#define M_MISC_W 0x1FC2
/* CRTCEXT3: */
#define M_MGAMODE (0x1 << 7)
#endif
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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.3 for Mesa -- MGA2064W register mnemonics
*
* Copyright (c) 2003 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef MGA_REG_H_included
#define MGA_REG_H_included
/* Matrox hardware registers: */
#define M_AR0 0x1C60
#define M_AR1 0x1C64
#define M_AR2 0x1C68
#define M_AR3 0x1C6C
#define M_AR4 0x1C70
#define M_AR5 0x1C74
#define M_AR6 0x1C78
#define M_BCOL 0x1C20
#define M_CXBNDRY 0x1C80
#define M_CXLEFT 0x1CA0
#define M_CXRIGHT 0x1CA4
#define M_DR0 0x1CC0
#define M_DR2 0x1CC8
#define M_DR3 0x1CCC
#define M_DR4 0x1CD0
#define M_DR6 0x1CD8
#define M_DR7 0x1CDC
#define M_DR8 0x1CE0
#define M_DR10 0x1CE8
#define M_DR11 0x1CEC
#define M_DR12 0x1CF0
#define M_DR14 0x1CF8
#define M_DR15 0x1CFC
#define M_DWGCTL 0x1C00
#define M_FCOL 0x1C24
#define M_FIFOSTATUS 0x1E10
#define M_FXBNDRY 0x1C84
#define M_FXLEFT 0x1CA8
#define M_FXRIGHT 0x1CAC
#define M_ICLEAR 0x1E18
#define M_IEN 0x1E1C
#define M_LEN 0x1C5C
#define M_MACCESS 0x1C04
#define M_OPMODE 0x1E54
#define M_PAT0 0x1C10
#define M_PAT1 0x1C14
#define M_PITCH 0x1C8C
#define M_PLNWT 0x1C1C
#define M_RESET 0x1E40
#define M_SGN 0x1C58
#define M_SHIFT 0x1C50
#define M_SRC0 0x1C30
#define M_SRC1 0x1C34
#define M_SRC2 0x1C38
#define M_SRC3 0x1C3C
#define M_STATUS 0x1E14
#define M_VCOUNT 0x1E20
#define M_XDST 0x1CB0
#define M_XYEND 0x1C44
#define M_XYSTRT 0x1C40
#define M_YBOT 0x1C9C
#define M_YDST 0x1C90
#define M_YDSTLEN 0x1C88
#define M_YDSTORG 0x1C94
#define M_YTOP 0x1C98
#define M_ZORG 0x1C0C
#define M_EXEC 0x0100
/* DWGCTL: opcod */
#define M_DWG_LINE_OPEN 0x0
#define M_DWG_AUTOLINE_OPEN 0x1
#define M_DWG_LINE_CLOSE 0x2
#define M_DWG_AUTOLINE_CLOSE 0x3
#define M_DWG_TRAP 0x4
#define M_DWG_TEXTURE_TRAP 0x5
#define M_DWG_BITBLT 0x8
#define M_DWG_FBITBLT 0xC
#define M_DWG_ILOAD 0x9
#define M_DWG_ILOAD_SCALE 0xD
#define M_DWG_ILOAD_FILTER 0xF
#define M_DWG_IDUMP 0xA
/* DWGCTL: atype */
#define M_DWG_RPL (0x0 << 4)
#define M_DWG_RSTR (0x1 << 4)
#define M_DWG_ZI (0x3 << 4)
#define M_DWG_BLK (0x4 << 4)
#define M_DWG_I (0x7 << 4)
/* DWGCTL: linear */
#define M_DWG_LINEAR (0x1 << 7)
/* DWGCTL: zmode */
#define M_DWG_NOZCMP (0x0 << 8)
#define M_DWG_ZE (0x2 << 8)
#define M_DWG_ZNE (0x3 << 8)
#define M_DWG_ZLT (0x4 << 8)
#define M_DWG_ZLTE (0x5 << 8)
#define M_DWG_ZGT (0x6 << 8)
#define M_DWG_ZGTE (0x7 << 8)
/* DWGCTL: solid */
#define M_DWG_SOLID (0x1 << 11)
/* DWGCTL: arzero */
#define M_DWG_ARZERO (0x1 << 12)
/* DWGCTL: sgnzero */
#define M_DWG_SGNZERO (0x1 << 13)
/* DWGCTL: shiftzero */
#define M_DWG_SHFTZERO (0x1 << 14)
/* DWGCTL: bop */
#define M_DWG_BOP_XOR (0x6 << 16)
#define M_DWG_BOP_AND (0x8 << 16)
#define M_DWG_BOP_SRC (0xC << 16)
#define M_DWG_BOP_OR (0xE << 16)
/* DWGCTL: trans */
#define M_DWG_TRANS_0 (0x0 << 20)
#define M_DWG_TRANS_1 (0x1 << 20)
#define M_DWG_TRANS_2 (0x2 << 20)
#define M_DWG_TRANS_3 (0x3 << 20)
#define M_DWG_TRANS_4 (0x4 << 20)
#define M_DWG_TRANS_5 (0x5 << 20)
#define M_DWG_TRANS_6 (0x6 << 20)
#define M_DWG_TRANS_7 (0x7 << 20)
#define M_DWG_TRANS_8 (0x8 << 20)
#define M_DWG_TRANS_9 (0x9 << 20)
#define M_DWG_TRANS_A (0xA << 20)
#define M_DWG_TRANS_B (0xB << 20)
#define M_DWG_TRANS_C (0xC << 20)
#define M_DWG_TRANS_D (0xD << 20)
#define M_DWG_TRANS_E (0xE << 20)
#define M_DWG_TRANS_F (0xF << 20)
/* DWGCTL: bltmod */
#define M_DWG_BMONOLEF (0x0 << 25)
#define M_DWG_BMONOWF (0x4 << 25)
#define M_DWG_BPLAN (0x1 << 25)
#define M_DWG_BFCOL (0x2 << 25)
#define M_DWG_BUYUV (0xE << 25)
#define M_DWG_BU32BGR (0x3 << 25)
#define M_DWG_BU32RGB (0x7 << 25)
#define M_DWG_BU24BGR (0xB << 25)
#define M_DWG_BU24RGB (0xF << 25)
/* DWGCTL: pattern */
#define M_DWG_PATTERN (0x1 << 29)
/* DWGCTL: transc */
#define M_DWG_TRANSC (0x1 << 30)
/* OPMODE: */
#define M_DMA_GENERAL (0x0 << 2)
#define M_DMA_BLIT (0x1 << 2)
#define M_DMA_VECTOR (0x2 << 2)
/* SGN: */
#define M_SDXL (0x1 << 1)
#define M_SDXR (0x1 << 5)
/* VGAREG */
#define M_CRTC_INDEX 0x1FD4
#define M_CRTC_DATA 0x1FD5
#define M_CRTC_EXT_INDEX 0x1FDE
#define M_CRTC_EXT_DATA 0x1FDF
#define M_MISC_R 0x1FCC
#define M_MISC_W 0x1FC2
/* CRTCEXT3: */
#define M_MGAMODE (0x1 << 7)
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,47 +1,47 @@
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef VESA_H_included
#define VESA_H_included
#include "internal.h"
extern void *vesa_swbank;
extern void vesa_b_dump_virtual (void);
extern void vesa_l_dump_virtual (void);
extern void vesa_l_dump_virtual_mmx (void);
extern vl_driver VESA;
#endif
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef VESA_H_included
#define VESA_H_included
#include "internal.h"
extern void *vesa_swbank;
extern void vesa_b_dump_virtual (void);
extern void vesa_l_dump_virtual (void);
extern void vesa_l_dump_virtual_mmx (void);
extern vl_driver VESA;
#endif

View file

@ -1,235 +1,235 @@
/*
* Mesa 3-D graphics library
* Version: 4.1
*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <pc.h>
#include <stdlib.h>
#include "video.h"
#include "vga.h"
static vl_mode modes[] = {
{0x13 | 0x4000, 320, 200, 320, 8, -1, 320*200},
{0xffff, -1, -1, -1, -1, -1, -1}
};
static word16 vga_ver;
static int linear_selector;
static int oldmode = -1;
#define vga_color_precision 6
/* Desc: Attempts to detect VGA, check video modes and create selectors.
*
* In : -
* Out : mode array
*
* Note: -
*/
static vl_mode *vga_init (void)
{
int rv = 0;
if (vga_ver) {
return modes;
}
__asm("\n\
movw $0x1a00, %%ax \n\
int $0x10 \n\
cmpb $0x1a, %%al \n\
jne 0f \n\
cmpb $0x07, %%bl \n\
jb 0f \n\
andl $0xff, %%ebx \n\
movl %%ebx, %0 \n\
0:":"=g"(rv)::"%eax", "%ebx");
if (rv == 0) {
return NULL;
}
if (_create_selector(&linear_selector, 0xa0000, 0x10000)) {
return NULL;
}
modes[0].sel = linear_selector;
vga_ver = rv;
return modes;
}
/* Desc: Frees all resources allocated by VGA init code.
*
* In : -
* Out : -
*
* Note: -
*/
static void vga_fini (void)
{
if (vga_ver) {
_remove_selector(&linear_selector);
}
}
/* Desc: Attempts to enter specified video mode.
*
* In : ptr to mode structure, refresh rate
* Out : 0 if success
*
* Note: -
*/
static int vga_entermode (vl_mode *p, int refresh)
{
if (!(p->mode & 0x4000)) {
return -1;
}
VGA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
if (oldmode == -1) {
__asm("\n\
movb $0x0f, %%ah \n\
int $0x10 \n\
andl $0xff, %%eax \n\
movl %%eax, %0 \n\
":"=g"(oldmode)::"%eax", "%ebx");
}
__asm("int $0x10"::"a"(p->mode&0xff));
return 0;
(void)refresh; /* silence compiler warning */
}
/* Desc: Restores to the mode prior to first call to vga_entermode.
*
* In : -
* Out : -
*
* Note: -
*/
static void vga_restore (void)
{
if (oldmode != -1) {
__asm("int $0x10"::"a"(oldmode));
}
}
/* Desc: set one palette entry
*
* In : color index, R, G, B
* Out : -
*
* Note: uses integer values
*/
static void vga_setCI_i (int index, int red, int green, int blue)
{
#if 0
__asm("\n\
movw $0x1010, %%ax \n\
movb %1, %%dh \n\
movb %2, %%ch \n\
int $0x10 \n\
"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
#else
outportb(0x03C8, index);
outportb(0x03C9, red);
outportb(0x03C9, green);
outportb(0x03C9, blue);
#endif
}
/* Desc: set one palette entry
*
* In : color index, R, G, B
* Out : -
*
* Note: uses normalized values
*/
static void vga_setCI_f (int index, float red, float green, float blue)
{
float max = (1 << vga_color_precision) - 1;
vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
}
/* Desc: state retrieval
*
* In : parameter name, ptr to storage
* Out : 0 if request successfully processed
*
* Note: -
*/
static int vga_get (int pname, int *params)
{
switch (pname) {
case VL_GET_CI_PREC:
params[0] = vga_color_precision;
break;
default:
return -1;
}
return 0;
}
/*
* the driver
*/
vl_driver VGA = {
vga_init,
vga_entermode,
NULL,
vga_setCI_f,
vga_setCI_i,
vga_get,
vga_restore,
vga_fini
};
/*
* Mesa 3-D graphics library
* Version: 4.1
*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <pc.h>
#include <stdlib.h>
#include "video.h"
#include "vga.h"
static vl_mode modes[] = {
{0x13 | 0x4000, 320, 200, 320, 8, -1, 320*200},
{0xffff, -1, -1, -1, -1, -1, -1}
};
static word16 vga_ver;
static int linear_selector;
static int oldmode = -1;
#define vga_color_precision 6
/* Desc: Attempts to detect VGA, check video modes and create selectors.
*
* In : -
* Out : mode array
*
* Note: -
*/
static vl_mode *vga_init (void)
{
int rv = 0;
if (vga_ver) {
return modes;
}
__asm("\n\
movw $0x1a00, %%ax \n\
int $0x10 \n\
cmpb $0x1a, %%al \n\
jne 0f \n\
cmpb $0x07, %%bl \n\
jb 0f \n\
andl $0xff, %%ebx \n\
movl %%ebx, %0 \n\
0:":"=g"(rv)::"%eax", "%ebx");
if (rv == 0) {
return NULL;
}
if (_create_selector(&linear_selector, 0xa0000, 0x10000)) {
return NULL;
}
modes[0].sel = linear_selector;
vga_ver = rv;
return modes;
}
/* Desc: Frees all resources allocated by VGA init code.
*
* In : -
* Out : -
*
* Note: -
*/
static void vga_fini (void)
{
if (vga_ver) {
_remove_selector(&linear_selector);
}
}
/* Desc: Attempts to enter specified video mode.
*
* In : ptr to mode structure, refresh rate
* Out : 0 if success
*
* Note: -
*/
static int vga_entermode (vl_mode *p, int refresh)
{
if (!(p->mode & 0x4000)) {
return -1;
}
VGA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
if (oldmode == -1) {
__asm("\n\
movb $0x0f, %%ah \n\
int $0x10 \n\
andl $0xff, %%eax \n\
movl %%eax, %0 \n\
":"=g"(oldmode)::"%eax", "%ebx");
}
__asm("int $0x10"::"a"(p->mode&0xff));
return 0;
(void)refresh; /* silence compiler warning */
}
/* Desc: Restores to the mode prior to first call to vga_entermode.
*
* In : -
* Out : -
*
* Note: -
*/
static void vga_restore (void)
{
if (oldmode != -1) {
__asm("int $0x10"::"a"(oldmode));
}
}
/* Desc: set one palette entry
*
* In : color index, R, G, B
* Out : -
*
* Note: uses integer values
*/
static void vga_setCI_i (int index, int red, int green, int blue)
{
#if 0
__asm("\n\
movw $0x1010, %%ax \n\
movb %1, %%dh \n\
movb %2, %%ch \n\
int $0x10 \n\
"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
#else
outportb(0x03C8, index);
outportb(0x03C9, red);
outportb(0x03C9, green);
outportb(0x03C9, blue);
#endif
}
/* Desc: set one palette entry
*
* In : color index, R, G, B
* Out : -
*
* Note: uses normalized values
*/
static void vga_setCI_f (int index, float red, float green, float blue)
{
float max = (1 << vga_color_precision) - 1;
vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
}
/* Desc: state retrieval
*
* In : parameter name, ptr to storage
* Out : 0 if request successfully processed
*
* Note: -
*/
static int vga_get (int pname, int *params)
{
switch (pname) {
case VL_GET_CI_PREC:
params[0] = vga_color_precision;
break;
default:
return -1;
}
return 0;
}
/*
* the driver
*/
vl_driver VGA = {
vga_init,
vga_entermode,
NULL,
vga_setCI_f,
vga_setCI_i,
vga_get,
vga_restore,
vga_fini
};

View file

@ -1,42 +1,42 @@
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef VGA_H_included
#define VGA_H_included
#include "internal.h"
#include "vesa.h"
extern vl_driver VGA;
#endif
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef VGA_H_included
#define VGA_H_included
#include "internal.h"
#include "vesa.h"
extern vl_driver VGA;
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,64 +1,64 @@
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef VIDEO_H_included
#define VIDEO_H_included
typedef int fixed;
#define VL_GET_CARD_NAME 0x0100
#define VL_GET_VRAM 0x0101
#define VL_GET_CI_PREC 0x0200
#define VL_GET_HPIXELS 0x0201
#define VL_GET_SCREEN_SIZE 0x0202
extern int (*vl_mixfix) (fixed r, fixed g, fixed b);
extern int (*vl_mixrgb) (const unsigned char rgb[]);
extern int (*vl_mixrgba) (const unsigned char rgba[]);
extern void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]);
extern void (*vl_clear) (int color);
extern void (*vl_rect) (int x, int y, int width, int height, int color);
extern void (*vl_flip) (void);
extern void (*vl_putpixel) (unsigned int offset, int color);
extern int (*vl_getpixel) (unsigned int offset);
void vl_setCI (int index, float red, float green, float blue);
int vl_sync_buffer (void **buffer, int x, int y, int width, int height);
int vl_get (int pname, int *params);
void vl_video_exit (void);
int vl_video_init (int width, int height, int bpp, int rgb, int refresh);
#endif
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef VIDEO_H_included
#define VIDEO_H_included
typedef int fixed;
#define VL_GET_CARD_NAME 0x0100
#define VL_GET_VRAM 0x0101
#define VL_GET_CI_PREC 0x0200
#define VL_GET_HPIXELS 0x0201
#define VL_GET_SCREEN_SIZE 0x0202
extern int (*vl_mixfix) (fixed r, fixed g, fixed b);
extern int (*vl_mixrgb) (const unsigned char rgb[]);
extern int (*vl_mixrgba) (const unsigned char rgba[]);
extern void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]);
extern void (*vl_clear) (int color);
extern void (*vl_rect) (int x, int y, int width, int height, int color);
extern void (*vl_flip) (void);
extern void (*vl_putpixel) (unsigned int offset, int color);
extern int (*vl_getpixel) (unsigned int offset);
void vl_setCI (int index, float red, float green, float blue);
int vl_sync_buffer (void **buffer, int x, int y, int width, int height);
int vl_get (int pname, int *params);
void vl_video_exit (void);
int vl_video_init (int width, int height, int bpp, int rgb, int refresh);
#endif

View file

@ -1,489 +1,489 @@
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
.file "virtual.S"
/*
* extern void *vl_current_draw_buffer;
* extern int vl_current_width, vl_current_bytes;
*/
.text
/* Desc: void v_clear8 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear8
_v_clear8:
movl 4(%esp), %eax
movb %al, %ah
pushw %ax
pushw %ax
popl %eax
jmp _v_clear_common
/* Desc: void v_clear16 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear16
_v_clear16:
movl 4(%esp), %eax
pushw %ax
pushw %ax
popl %eax
jmp _v_clear_common
/* Desc: void v_clear32 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear32
_v_clear32:
movl 4(%esp), %eax
.balign 4
_v_clear_common:
movl _vl_current_bytes, %ecx
movl _vl_current_draw_buffer, %edx
shrl $2, %ecx
.balign 4
0:
movl %eax, (%edx)
addl $4, %edx
decl %ecx
jnz 0b
ret
/* Desc: void v_clear8_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear8_mmx
_v_clear8_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
punpcklbw %mm0, %mm0
punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
#endif
/* Desc: void v_clear16_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear16_mmx
_v_clear16_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
#endif
/* Desc: void v_clear32_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear32_mmx
_v_clear32_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
.balign 4
_v_clear_common_mmx:
punpckldq %mm0, %mm0
movl _vl_current_bytes, %ecx
movl _vl_current_draw_buffer, %edx
shrl $3, %ecx
.balign 4
0:
movq %mm0, (%edx)
addl $8, %edx
decl %ecx
jnz 0b
emms
#endif
ret
/* Desc: void v_clear24 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear24
_v_clear24:
movl $0xaaaaaaab, %eax
mull _vl_current_bytes
movl 4(%esp), %eax
movl %edx, %ecx
pushl %ebx
movl _vl_current_draw_buffer, %edx
shrl %ecx
movb 10(%esp), %bl
.balign 4
0:
movw %ax, (%edx)
movb %bl, 2(%edx)
addl $3, %edx
decl %ecx
jnz 0b
popl %ebx
ret
/* Desc: void v_clear24_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear24_mmx
_v_clear24_mmx:
#ifdef USE_MMX_ASM
movl 4(%esp), %eax
movl %eax, %edx
movl %eax, %ecx
shll $16, %edx
rorl $8, %ecx
movw %cx, %dx
rorl $16, %ecx
movb %dh, %cl
shll $8, %eax
movb %ch, %al
rorl $8, %eax
pushl %edx
pushl %eax
movq (%esp), %mm0
pushl %ecx
movq (%esp), %mm1
pushl %edx
movq (%esp), %mm2
movl $0xaaaaaaab, %eax
mull _vl_current_bytes
movl %edx, %ecx
movl _vl_current_draw_buffer, %edx
shrl $4, %ecx
.balign 4
0:
movq %mm0, (%edx)
movq %mm1, 8(%edx)
movq %mm2, 16(%edx)
addl $24, %edx
decl %ecx
jnz 0b
emms
addl $16, %esp
#endif
ret
/* Desc: void v_rect8 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect8
_v_rect8:
cld
pushl %esi
pushl %edi
movl 28(%esp), %eax
movl _vl_current_width, %esi
movl 16(%esp), %edi
movb %al, %ah
movl 20(%esp), %ecx
imull %esi, %edi
movl 24(%esp), %edx
subl %ecx, %esi
addl 12(%esp), %edi
pushw %ax
pushw %ax
pushl %ds
popl %es
addl _vl_current_draw_buffer, %edi
popl %eax
pushl %ebx
movl %ecx, %ebx
andl $3, %ebx
.balign 4
0:
pushl %ecx
.balign 4
1:
shrl $2, %ecx
rep; stosl
testl %ebx, %ebx
jz 2f
movl %ebx, %ecx
rep; stosb
.balign 4
2:
popl %ecx
addl %esi, %edi
decl %edx
jnz 0b
popl %ebx
popl %edi
popl %esi
ret
/* Desc: void v_rect16 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect16
_v_rect16:
cld
pushl %esi
pushl %edi
movl 28(%esp), %eax
movl _vl_current_width, %esi
movl 16(%esp), %edi
movl 20(%esp), %ecx
imull %esi, %edi
movl 24(%esp), %edx
subl %ecx, %esi
addl 12(%esp), %edi
pushw %ax
shll %esi
pushw %ax
shll %edi
pushl %ds
popl %es
addl _vl_current_draw_buffer, %edi
popl %eax
.balign 4
0:
pushl %ecx
.balign 4
1:
shrl %ecx
rep; stosl
jnc 2f
stosw
.balign 4
2:
popl %ecx
addl %esi, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
ret
/* Desc: void v_rect24 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect24
_v_rect24:
pushl %esi
pushl %edi
movl 28(%esp), %eax
movl _vl_current_width, %esi
movl 16(%esp), %edi
movl 20(%esp), %ecx
imull %esi, %edi
movl 24(%esp), %edx
subl %ecx, %esi
addl 12(%esp), %edi
leal (%esi, %esi, 2), %esi
pushl %ebx
leal (%edi, %edi, 2), %edi
movl %eax, %ebx
addl _vl_current_draw_buffer, %edi
shrl $16, %ebx
.balign 4
0:
pushl %ecx
.balign 4
1:
movw %ax, (%edi)
movb %bl, 2(%edi)
addl $3, %edi
decl %ecx
jnz 1b
popl %ecx
addl %esi, %edi
decl %edx
jnz 0b
popl %ebx
popl %edi
popl %esi
ret
/* Desc: void v_rect32 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect32
_v_rect32:
pushl %esi
pushl %edi
movl _vl_current_width, %esi
movl 16(%esp), %edi
movl 20(%esp), %ecx
imull %esi, %edi
movl 24(%esp), %edx
subl %ecx, %esi
addl 12(%esp), %edi
shll $2, %esi
shll $2, %edi
movl 28(%esp), %eax
addl _vl_current_draw_buffer, %edi
.balign 4
0:
pushl %ecx
.balign 4
1:
movl %eax, (%edi)
addl $4, %edi
decl %ecx
jnz 1b
popl %ecx
addl %esi, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
ret
/* Desc: void v_putpixel8 (unsigned int offset, int color);
*
* In : offset within buffer, color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_putpixel8
_v_putpixel8:
movl 8(%esp), %ecx
movl 4(%esp), %edx
movl _vl_current_draw_buffer, %eax
movb %cl, (%eax,%edx)
ret
/* Desc: void v_putpixel16 (unsigned int offset, int color);
*
* In : offset within buffer, color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_putpixel16
_v_putpixel16:
movl 8(%esp), %ecx
movl 4(%esp), %edx
movl _vl_current_draw_buffer, %eax
movw %cx, (%eax,%edx,2)
ret
/* Desc: void v_putpixel24 (unsigned int offset, int color);
*
* In : offset within buffer, color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_putpixel24
_v_putpixel24:
movl 4(%esp), %eax
movl 8(%esp), %edx
movl _vl_current_draw_buffer, %ecx
leal (%eax,%eax,2), %eax
movw %dx, (%ecx,%eax)
shrl $16, %edx
movb %dl, 2(%ecx,%eax)
ret
/* Desc: void v_putpixel32 (unsigned int offset, int color);
*
* In : offset within buffer, color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_putpixel32
_v_putpixel32:
movl 8(%esp), %ecx
movl 4(%esp), %edx
movl _vl_current_draw_buffer, %eax
movl %ecx, (%eax,%edx,4)
ret
/*
* 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.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
.file "virtual.S"
/*
* extern void *vl_current_draw_buffer;
* extern int vl_current_width, vl_current_bytes;
*/
.text
/* Desc: void v_clear8 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear8
_v_clear8:
movl 4(%esp), %eax
movb %al, %ah
pushw %ax
pushw %ax
popl %eax
jmp _v_clear_common
/* Desc: void v_clear16 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear16
_v_clear16:
movl 4(%esp), %eax
pushw %ax
pushw %ax
popl %eax
jmp _v_clear_common
/* Desc: void v_clear32 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear32
_v_clear32:
movl 4(%esp), %eax
.balign 4
_v_clear_common:
movl _vl_current_bytes, %ecx
movl _vl_current_draw_buffer, %edx
shrl $2, %ecx
.balign 4
0:
movl %eax, (%edx)
addl $4, %edx
decl %ecx
jnz 0b
ret
/* Desc: void v_clear8_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear8_mmx
_v_clear8_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
punpcklbw %mm0, %mm0
punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
#endif
/* Desc: void v_clear16_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear16_mmx
_v_clear16_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
#endif
/* Desc: void v_clear32_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear32_mmx
_v_clear32_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
.balign 4
_v_clear_common_mmx:
punpckldq %mm0, %mm0
movl _vl_current_bytes, %ecx
movl _vl_current_draw_buffer, %edx
shrl $3, %ecx
.balign 4
0:
movq %mm0, (%edx)
addl $8, %edx
decl %ecx
jnz 0b
emms
#endif
ret
/* Desc: void v_clear24 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear24
_v_clear24:
movl $0xaaaaaaab, %eax
mull _vl_current_bytes
movl 4(%esp), %eax
movl %edx, %ecx
pushl %ebx
movl _vl_current_draw_buffer, %edx
shrl %ecx
movb 10(%esp), %bl
.balign 4
0:
movw %ax, (%edx)
movb %bl, 2(%edx)
addl $3, %edx
decl %ecx
jnz 0b
popl %ebx
ret
/* Desc: void v_clear24_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear24_mmx
_v_clear24_mmx:
#ifdef USE_MMX_ASM
movl 4(%esp), %eax
movl %eax, %edx
movl %eax, %ecx
shll $16, %edx
rorl $8, %ecx
movw %cx, %dx
rorl $16, %ecx
movb %dh, %cl
shll $8, %eax
movb %ch, %al
rorl $8, %eax
pushl %edx
pushl %eax
movq (%esp), %mm0
pushl %ecx
movq (%esp), %mm1
pushl %edx
movq (%esp), %mm2
movl $0xaaaaaaab, %eax
mull _vl_current_bytes
movl %edx, %ecx
movl _vl_current_draw_buffer, %edx
shrl $4, %ecx
.balign 4
0:
movq %mm0, (%edx)
movq %mm1, 8(%edx)
movq %mm2, 16(%edx)
addl $24, %edx
decl %ecx
jnz 0b
emms
addl $16, %esp
#endif
ret
/* Desc: void v_rect8 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect8
_v_rect8:
cld
pushl %esi
pushl %edi
movl 28(%esp), %eax
movl _vl_current_width, %esi
movl 16(%esp), %edi
movb %al, %ah
movl 20(%esp), %ecx
imull %esi, %edi
movl 24(%esp), %edx
subl %ecx, %esi
addl 12(%esp), %edi
pushw %ax
pushw %ax
pushl %ds
popl %es
addl _vl_current_draw_buffer, %edi
popl %eax
pushl %ebx
movl %ecx, %ebx
andl $3, %ebx
.balign 4
0:
pushl %ecx
.balign 4
1:
shrl $2, %ecx
rep; stosl
testl %ebx, %ebx
jz 2f
movl %ebx, %ecx
rep; stosb
.balign 4
2:
popl %ecx
addl %esi, %edi
decl %edx
jnz 0b
popl %ebx
popl %edi
popl %esi
ret
/* Desc: void v_rect16 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect16
_v_rect16:
cld
pushl %esi
pushl %edi
movl 28(%esp), %eax
movl _vl_current_width, %esi
movl 16(%esp), %edi
movl 20(%esp), %ecx
imull %esi, %edi
movl 24(%esp), %edx
subl %ecx, %esi
addl 12(%esp), %edi
pushw %ax
shll %esi
pushw %ax
shll %edi
pushl %ds
popl %es
addl _vl_current_draw_buffer, %edi
popl %eax
.balign 4
0:
pushl %ecx
.balign 4
1:
shrl %ecx
rep; stosl
jnc 2f
stosw
.balign 4
2:
popl %ecx
addl %esi, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
ret
/* Desc: void v_rect24 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect24
_v_rect24:
pushl %esi
pushl %edi
movl 28(%esp), %eax
movl _vl_current_width, %esi
movl 16(%esp), %edi
movl 20(%esp), %ecx
imull %esi, %edi
movl 24(%esp), %edx
subl %ecx, %esi
addl 12(%esp), %edi
leal (%esi, %esi, 2), %esi
pushl %ebx
leal (%edi, %edi, 2), %edi
movl %eax, %ebx
addl _vl_current_draw_buffer, %edi
shrl $16, %ebx
.balign 4
0:
pushl %ecx
.balign 4
1:
movw %ax, (%edi)
movb %bl, 2(%edi)
addl $3, %edi
decl %ecx
jnz 1b
popl %ecx
addl %esi, %edi
decl %edx
jnz 0b
popl %ebx
popl %edi
popl %esi
ret
/* Desc: void v_rect32 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect32
_v_rect32:
pushl %esi
pushl %edi
movl _vl_current_width, %esi
movl 16(%esp), %edi
movl 20(%esp), %ecx
imull %esi, %edi
movl 24(%esp), %edx
subl %ecx, %esi
addl 12(%esp), %edi
shll $2, %esi
shll $2, %edi
movl 28(%esp), %eax
addl _vl_current_draw_buffer, %edi
.balign 4
0:
pushl %ecx
.balign 4
1:
movl %eax, (%edi)
addl $4, %edi
decl %ecx
jnz 1b
popl %ecx
addl %esi, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
ret
/* Desc: void v_putpixel8 (unsigned int offset, int color);
*
* In : offset within buffer, color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_putpixel8
_v_putpixel8:
movl 8(%esp), %ecx
movl 4(%esp), %edx
movl _vl_current_draw_buffer, %eax
movb %cl, (%eax,%edx)
ret
/* Desc: void v_putpixel16 (unsigned int offset, int color);
*
* In : offset within buffer, color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_putpixel16
_v_putpixel16:
movl 8(%esp), %ecx
movl 4(%esp), %edx
movl _vl_current_draw_buffer, %eax
movw %cx, (%eax,%edx,2)
ret
/* Desc: void v_putpixel24 (unsigned int offset, int color);
*
* In : offset within buffer, color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_putpixel24
_v_putpixel24:
movl 4(%esp), %eax
movl 8(%esp), %edx
movl _vl_current_draw_buffer, %ecx
leal (%eax,%eax,2), %eax
movw %dx, (%ecx,%eax)
shrl $16, %edx
movb %dl, 2(%ecx,%eax)
ret
/* Desc: void v_putpixel32 (unsigned int offset, int color);
*
* In : offset within buffer, color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_putpixel32
_v_putpixel32:
movl 8(%esp), %ecx
movl 4(%esp), %edx
movl _vl_current_draw_buffer, %eax
movl %ecx, (%eax,%edx,4)
ret