DMesa now uses OSMesa as a back-end.

This commit is contained in:
Daniel Borca 2006-03-31 20:53:12 +00:00
parent 3a46dff27d
commit 3a3e63dc4f
18 changed files with 1660 additions and 2384 deletions

View file

@ -20,9 +20,9 @@
# 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.6 for Mesa
# DOS/DJGPP makefile for Mesa
#
# Copyright (C) 2002 - Daniel Borca
# Author: Daniel Borca
# Email : dborca@users.sourceforge.net
# Web : http://www.geocities.com/dborca
@ -31,9 +31,6 @@
# Available options:
#
# Environment variables:
# GLU=[mesa|sgi] specify GLU directory; can be `sgi' (requires GNU/C++)
# or `mesa'.
# default = mesa
# GLIDE path to Glide3 SDK; used with FX.
# default = $(TOP)/glide3
# FX=1 build for 3dfx Glide3. Note that this disables
@ -57,8 +54,6 @@
.PHONY : all libgl libglu libglut clean realclean
GLU ?= mesa
CFLAGS = -Wall -W -pedantic
CFLAGS += -O2 -ffast-math
@ -75,7 +70,7 @@ all: libgl libglu libglut
libgl: lib
$(MAKE) -f Makefile.DJ -C src/mesa
libglu: lib
$(MAKE) -f Makefile.DJ -C src/glu/$(GLU)
$(MAKE) -f Makefile.DJ -C src/glu/sgi
libglut: lib
$(MAKE) -f Makefile.DJ -C src/glut/dos

View file

@ -1,4 +1,4 @@
Mesa 6.3 DOS/DJGPP Port v1.7
Mesa 6.5 DOS/DJGPP Port v1.8
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -7,8 +7,7 @@ Description:
~~~~~~~~~~~~
Well, guess what... this is the DOS port of Mesa 6.3, for DJGPP fans... Whoa!
The driver has its origins in ddsample.c, written by Brian Paul and found by me
in Mesa 3.4.2.
The driver uses OSMesa to draw off screen, and then blits the buffer.
@ -32,9 +31,6 @@ Available options:
Environment variables:
CPU optimize for the given processor.
default = pentium
GLU=[mesa|sgi] specify GLU directory; can be `sgi' (requires GNU/C++)
or `mesa'.
default = mesa
GLIDE path to Glide3 SDK; used with FX.
default = $(TOP)/glide3
FX=1 build for 3dfx Glide3. Note that this disables
@ -56,11 +52,9 @@ Available options:
Tested on:
CPU: AMD Athlon XP 1800+
Mainboard: GA-7VTXE w/ 512 MB DDRAM
Video card: Voodoo5 6000 AGP w/ 128 MB SDRAM
DJGPP: djdev 2.04 + gcc v3.4.3 + make v3.80
OS: DOS and Win98SE
Video card: Radeon 9500
DJGPP: djdev 2.04 + gcc v4.1.0 + make v3.80
OS: DOS, Win98SE, WinXP (using Videoport driver)
@ -98,7 +92,7 @@ FAQ:
Q) DMesa is so SLOOOW! The Win32 OpenGL performs so much better...
A) Is that a question? If you have a 3dfx Voodoo (any model), you're
lucky (check http://sourceforge.net/projects/glide for the DJGPP port).
If you haven't, sorry; everything is done in software. Suggestions?
If you haven't, sorry; everything is done in software.
Q) I tried to set refresh rate w/ DMesa, but without success.
A) Refresh rate control works only for VESA 3.0 and the 3dfx driver (in
@ -107,7 +101,8 @@ FAQ:
Q) I made a simple application and it does nothing. It exits right away. Not
even a blank screen.
A) Pure software drivers (VESA/VGA/NUL) support only double-buffered modes.
A) Software drivers (VESA/VGA/NUL) must to be constructed as single-buffered
visuals. However, DMesaSwapBuffers must be called to get any output.
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 ;-).
@ -265,6 +260,11 @@ v1.7 (???-2005)
* no more GLX sources in DOS GLUT
* made GLUT timer callbacks less accurate but safer
v1.8 (apr-2006)
* killed lots of code, the driver is now a front-end to OSMesa
* fixed problem with WinNT (http://www.volny.cz/martin.sulak/)
- removed 3dfx Glide3 support (temporarily?)
Contact:

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.7 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Daniel Borca
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@ -35,7 +35,7 @@
#define DMESA_H_included
#define DMESA_MAJOR_VERSION 6
#define DMESA_MINOR_VERSION 3
#define DMESA_MINOR_VERSION 5
/* Sample Usage:
*
@ -138,7 +138,7 @@ void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue);
/*
* DMesa functions
*/
typedef void (*DMesaProc) (void);
typedef void (*DMesaProc) ();
DMesaProc DMesaGetProcAddress (const char *name);
/*
@ -149,8 +149,8 @@ DMesaProc DMesaGetProcAddress (const char *name);
#define DMESA_GET_VIDEO_MODES 0x0300
#define DMESA_GET_BUFFER_ADDR 0x0400
#define DMESA_DRIVER_SWDB_BIT 0x1 /* software double-buffered */
#define DMESA_DRIVER_LLWO_BIT 0x2 /* lower-left window origin */
#define DMESA_DRIVER_DBL_BIT 0x1 /* double-buffered */
#define DMESA_DRIVER_YUP_BIT 0x2 /* lower-left window origin */
int DMesaGetIntegerv (GLenum pname, GLint *params);
#ifdef __cplusplus

View file

@ -66,6 +66,10 @@ glutCreateWindow (const char *title)
int i;
int m8width = (_glut_default.width + 7) & ~7;
if (!(_glut_default.mode & GLUT_DOUBLE)) {
return 0;
}
/* We set the Visual once. This will be our desktop (graphic mode).
* We should do this in the `glutInit' code, but we don't have any idea
* about its geometry. Supposedly, when we are about to create one
@ -73,7 +77,7 @@ glutCreateWindow (const char *title)
*/
if (!visual) {
if ((visual=DMesaCreateVisual(_glut_default.x + m8width, _glut_default.y + _glut_default.height, _glut_visual.bpp, _glut_visual.refresh,
_glut_default.mode & GLUT_DOUBLE,
GLUT_SINGLE,
!(_glut_default.mode & GLUT_INDEX),
(_glut_default.mode & GLUT_ALPHA ) ? _glut_visual.alpha : 0,
(_glut_default.mode & GLUT_DEPTH ) ? _glut_visual.depth : 0,

View file

@ -103,8 +103,8 @@ DRIVER_SOURCES += \
$(GLIDE_DRIVER_SOURCES)
else
DRIVER_SOURCES += \
$(OSMESA_DRIVER_SOURCES) \
drivers/dos/video.c \
drivers/dos/virtual.S \
drivers/dos/vesa.c \
drivers/dos/blit.S \
drivers/dos/vga.c \
@ -112,8 +112,6 @@ DRIVER_SOURCES += \
drivers/dos/dpmi.c
endif
#DRIVER_SOURCES += $(OSMESA_DRIVER_SOURCES)
SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.3 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
@ -197,3 +197,844 @@ _vesa_l_dump_virtual_mmx:
emms
#endif
ret
#define CVT_32_TO_16(s, tmp) \
/* SRC = bbbbbbbbggggggggrrrrrrrr******** */\
movl %e##s##x, %tmp ;\
/* TMP = bbbbbbbbggggggggrrrrrrrr******** */\
shrb $2, %s##h ;\
/* SRC = bbbbbbbbgggggg00rrrrrrrr******** */\
andl $0xF80000, %tmp ;\
/* TMP = 0000000000000000000rrrrr00000000 */\
shrw $3, %s##x ;\
/* SRC = bbbbbgggggg00000rrrrrrrr******** */\
shrl $8, %tmp ;\
/* TMP = 00000000000rrrrr0000000000000000 */\
orl %tmp, %e##s##x ;\
/* SRC = bbbbbggggggrrrrrrrrrrrrr******** */
#define CVT_32_TO_15(s, tmp) \
/* SRC = bbbbbbbbggggggggrrrrrrrr******** */\
movl %e##s##x, %tmp ;\
/* TMP = bbbbbbbbggggggggrrrrrrrr******** */\
shrb $3, %s##h ;\
/* SRC = bbbbbbbbgggggg00rrrrrrrr******** */\
andl $0xF80000, %tmp ;\
/* TMP = 0000000000000000000rrrrr00000000 */\
shrw $3, %s##x ;\
/* SRC = bbbbbgggggg00000rrrrrrrr******** */\
shrl $9, %tmp ;\
/* TMP = 00000000000rrrrr0000000000000000 */\
orl %tmp, %e##s##x ;\
/* SRC = bbbbbggggggrrrrrrrrrrrrr******** */
#define CVT_16_TO_15(src, tmp) \
/* SRC = bbbbbggggggrrrrrBBBBBGGGGGGRRRRR */\
movl %src, %tmp ;\
/* TMP = bbbbbggggggrrrrrBBBBBGGGGGGRRRRR */\
andl $0x1F001F, %src ;\
/* SRC = bbbbb00000000000BBBBB00000000000 */\
andl $0xFFC0FFC0, %tmp ;\
/* TMP = 000000gggggrrrrr000000GGGGGRRRRR */\
shrl %tmp ;\
/* TMP = 00000gggggrrrrr000000GGGGGRRRRR0 */\
orl %tmp, %src ;\
/* SRC = bbbbbgggggrrrrr0BBBBBGGGGGRRRRR0 */\
/* transform BGRA to BGR */
.p2align 5,,31
.global _vesa_l_dump_32_to_24
_vesa_l_dump_32_to_24:
pushl %ebx
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, %ebx
.balign 4
0:
pushl %ecx
1:
movl (%esi), %eax
addl $4, %esi
movw %ax, %fs:(%edi)
shrl $16, %eax
movb %al, %fs:2(%edi)
addl $3, %edi
subl $3, %ecx
jnz 1b
popl %ecx
addl %ebx, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %ebx
ret
/* transform BGRA to B5G6R5 */
.p2align 5,,31
.global _vesa_l_dump_32_to_16
_vesa_l_dump_32_to_16:
pushl %ebp
pushl %ebx
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, %ebx
.balign 4
0:
pushl %ecx
1:
movl (%esi), %eax
addl $4, %esi
CVT_32_TO_16(a, ebp)
movw %ax, %fs:(%edi)
addl $2, %edi
subl $2, %ecx
jnz 1b
popl %ecx
addl %ebx, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
/* transform BGRA to B5G5R5 */
.p2align 5,,31
.global _vesa_l_dump_32_to_15
_vesa_l_dump_32_to_15:
pushl %ebp
pushl %ebx
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, %ebx
.balign 4
0:
pushl %ecx
1:
movl (%esi), %eax
addl $4, %esi
CVT_32_TO_15(a, ebp)
movw %ax, %fs:(%edi)
addl $2, %edi
subl $2, %ecx
jnz 1b
popl %ecx
addl %ebx, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
/* transform BGRA to fake8 */
.p2align 5,,31
.global _vesa_l_dump_32_to_8
_vesa_l_dump_32_to_8:
pushl %ebp
pushl %ebx
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, %ebx
.balign 4
0:
pushl %edx
pushl %ecx
pushl %ebx
1:
movl (%esi), %eax
addl $4, %esi
#if 1
xorl %ebx, %ebx
movl %eax, %edx
movb %ah, %bl
shrl $16, %edx
andl $0xFF, %edx
andl $0xFF, %eax
movb _array_b(%eax), %al
movb _array_r(%edx), %dl
movb _array_g(%ebx), %bl
imull $36, %eax
imull $6, %ebx
addl %edx, %eax
addl %ebx, %eax
#endif
movb %al, %fs:(%edi)
incl %edi
decl %ecx
jnz 1b
popl %ebx
popl %ecx
popl %edx
addl %ebx, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
/* transform BGR to BGRx */
.p2align 5,,31
.global _vesa_l_dump_24_to_32
_vesa_l_dump_24_to_32:
pushl %ebx
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, %ebx
.balign 4
0:
pushl %ecx
1:
movl (%esi), %eax
addl $3, %esi
movl %eax, %fs:(%edi)
addl $4, %edi
subl $4, %ecx
jnz 1b
popl %ecx
addl %ebx, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %ebx
ret
/* transform BGR to fake8 */
.p2align 5,,31
.global _vesa_l_dump_24_to_8
_vesa_l_dump_24_to_8:
pushl %ebp
pushl %ebx
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, %ebx
.balign 4
0:
pushl %edx
pushl %ecx
pushl %ebx
1:
movl (%esi), %eax
addl $3, %esi
#if 1
xorl %ebx, %ebx
movl %eax, %edx
movb %ah, %bl
shrl $16, %edx
andl $0xFF, %edx
andl $0xFF, %eax
movb _array_b(%eax), %al
movb _array_r(%edx), %dl
movb _array_g(%ebx), %bl
imull $36, %eax
imull $6, %ebx
addl %edx, %eax
addl %ebx, %eax
#endif
movb %al, %fs:(%edi)
incl %edi
decl %ecx
jnz 1b
popl %ebx
popl %ecx
popl %edx
addl %ebx, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
/* transform B5G6R5 to B5G5R5 */
.p2align 5,,31
.global _vesa_l_dump_16_to_15
_vesa_l_dump_16_to_15:
pushl %ebp
pushl %ebx
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, %ebx
.balign 4
0:
pushl %ecx
1:
movl (%esi), %eax
addl $4, %esi
CVT_16_TO_15(eax, ebp)
movl %eax, %fs:(%edi)
addl $4, %edi
subl $4, %ecx
jnz 1b
popl %ecx
addl %ebx, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
/* transform B5G6R5 to fake8 */
.p2align 5,,31
.global _vesa_l_dump_16_to_8
_vesa_l_dump_16_to_8:
pushl %ebp
pushl %ebx
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, %ebx
.balign 4
0:
pushl %ecx
pushl %ebx
1:
movl (%esi), %eax
addl $4, %esi
#if 1
movl %eax, %ebx
andl $0xFFFF, %eax
shrl $16, %ebx
movb _tab_16_8(%eax), %al
movb _tab_16_8(%ebx), %ah
#endif
movw %ax, %fs:(%edi)
addl $2, %edi
subl $2, %ecx
jnz 1b
popl %ebx
popl %ecx
addl %ebx, %edi
decl %edx
jnz 0b
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.p2align 5,,31
.global _vesa_b_dump_32_to_24
_vesa_b_dump_32_to_24:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %fs
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 $0x00FFFFFF, %ebx
.balign 4
0:
pushl %eax
pushl %ecx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
pushl %ebx
incl %edx
xorl %ebx, %ebx
call *_vesa_swbank
popl %ebx
subl %ebp, %edi
.balign 4
2:
movb (%esi), %al /* XXX too many accesses */
incl %esi
rorl $8, %ebx
jnc 2b
movb %al, %fs:(%edi)
incl %edi
decl %ecx
jnz 1b
popl %ecx
popl %eax
addl _vl_current_delta, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
.p2align 5,,31
.global _vesa_b_dump_32_to_16
_vesa_b_dump_32_to_16:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %fs
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
.balign 4
0:
pushl %eax
pushl %ecx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
incl %edx
xorl %ebx, %ebx
call *_vesa_swbank
subl %ebp, %edi
.balign 4
2:
movl (%esi), %eax
addl $4, %esi
CVT_32_TO_16(a, ebx)
movw %ax, %fs:(%edi)
addl $2, %edi
subl $2, %ecx
jnz 1b
popl %ecx
popl %eax
addl _vl_current_delta, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
.p2align 5,,31
.global _vesa_b_dump_32_to_15
_vesa_b_dump_32_to_15:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %fs
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
.balign 4
0:
pushl %eax
pushl %ecx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
incl %edx
xorl %ebx, %ebx
call *_vesa_swbank
subl %ebp, %edi
.balign 4
2:
movl (%esi), %eax
addl $4, %esi
CVT_32_TO_15(a, ebx)
movw %ax, %fs:(%edi)
addl $2, %edi
subl $2, %ecx
jnz 1b
popl %ecx
popl %eax
addl _vl_current_delta, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
.p2align 5,,31
.global _vesa_b_dump_32_to_8
_vesa_b_dump_32_to_8:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %fs
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
.balign 4
0:
pushl %eax
pushl %ecx
pushl %edx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
popl %edx
incl %edx
pushl %edx
xorl %ebx, %ebx
call *_vesa_swbank
subl %ebp, %edi
.balign 4
2:
movl (%esi), %eax
addl $4, %esi
#if 1
xorl %ebx, %ebx
movl %eax, %edx
movb %ah, %bl
shrl $16, %edx
andl $0xFF, %edx
andl $0xFF, %eax
movb _array_b(%eax), %al
movb _array_r(%edx), %dl
movb _array_g(%ebx), %bl
imull $36, %eax
imull $6, %ebx
addl %edx, %eax
addl %ebx, %eax
#endif
movb %al, %fs:(%edi)
incl %edi
decl %ecx
jnz 1b
popl %edx
popl %ecx
popl %eax
addl _vl_current_delta, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
.p2align 5,,31
.global _vesa_b_dump_24_to_32
_vesa_b_dump_24_to_32:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %fs
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
.balign 4
0:
pushl %eax
pushl %ecx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
pushl %ebx
incl %edx
xorl %ebx, %ebx
call *_vesa_swbank
popl %ebx
subl %ebp, %edi
.balign 4
2:
movl (%esi), %eax
addl $3, %esi
movl %eax, %fs:(%edi)
addl $4, %edi
subl $4, %ecx
jnz 1b
popl %ecx
popl %eax
addl %ebx, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
.p2align 5,,31
.global _vesa_b_dump_24_to_8
_vesa_b_dump_24_to_8:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %fs
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
.balign 4
0:
pushl %eax
pushl %ecx
pushl %edx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
popl %edx
incl %edx
pushl %edx
xorl %ebx, %ebx
call *_vesa_swbank
subl %ebp, %edi
.balign 4
2:
movl (%esi), %eax
addl $3, %esi
#if 1
xorl %ebx, %ebx
movl %eax, %edx
movb %ah, %bl
shrl $16, %edx
andl $0xFF, %edx
andl $0xFF, %eax
movb _array_b(%eax), %al
movb _array_r(%edx), %dl
movb _array_g(%ebx), %bl
imull $36, %eax
imull $6, %ebx
addl %edx, %eax
addl %ebx, %eax
#endif
movb %al, %fs:(%edi)
incl %edi
decl %ecx
jnz 1b
popl %edx
popl %ecx
popl %eax
addl _vl_current_delta, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
.p2align 5,,31
.global _vesa_b_dump_16_to_15
_vesa_b_dump_16_to_15:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %fs
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
.balign 4
0:
pushl %eax
pushl %ecx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
incl %edx
xorl %ebx, %ebx
call *_vesa_swbank
subl %ebp, %edi
.balign 4
2:
movw (%esi), %ax
addl $2, %esi
CVT_16_TO_15(eax, ebx)
movw %ax, %fs:(%edi)
addl $2, %edi
subl $2, %ecx
jnz 1b
popl %ecx
popl %eax
addl _vl_current_delta, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
ret
.p2align 5,,31
.global _vesa_b_dump_16_to_8
_vesa_b_dump_16_to_8:
pushl %ebx
pushl %esi
pushl %edi
pushl %ebp
movl _vl_video_selector, %fs
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
.balign 4
0:
pushl %eax
pushl %ecx
.balign 4
1:
cmpl %ebp, %edi
jb 2f
pushl %ebx
incl %edx
xorl %ebx, %ebx
call *_vesa_swbank
popl %ebx
subl %ebp, %edi
.balign 4
2:
movw (%esi), %ax
addl $2, %esi
#if 1
andl $0xFFFF, %eax
movb _tab_16_8(%eax), %al
#endif
movb %al, %fs:(%edi)
addl $1, %edi
subl $1, %ecx
jnz 1b
popl %ecx
popl %eax
addl %ebx, %edi
decl %eax
jnz 0b
popl %ebp
popl %edi
popl %esi
popl %ebx
ret

File diff suppressed because it is too large Load diff

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.5 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.6 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@ -54,6 +54,8 @@ typedef unsigned long word32;
#define _16_ *(word16 *)&
#define _32_ *(word32 *)&
typedef void (*BLTFUNC) (void);
/*
* video mode structure
@ -75,7 +77,7 @@ typedef struct vl_mode {
*/
typedef struct {
vl_mode *(*init) (void);
int (*entermode) (vl_mode *p, int refresh);
int (*entermode) (vl_mode *p, int refresh, int fbbits);
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);
@ -100,32 +102,4 @@ void _remove_selector (int *segment);
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

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.7 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@ -137,13 +137,13 @@ null_fini (void)
* Note: -
*/
static int
null_entermode (vl_mode *p, int refresh)
null_entermode (vl_mode *p, int refresh, int fbbits)
{
NUL.blit = null_blit_nop;
return 0;
(void)(p && refresh); /* silence compiler warning */
(void)(p && refresh && fbbits); /* silence compiler warning */
}

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.6 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.6 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@ -86,16 +86,16 @@ unsigned int vesa_gran_mask, vesa_gran_shift;
* VESA 3.0 CRTC timings structure
*/
typedef struct CRTCInfoBlock {
unsigned short HorizontalTotal;
unsigned short HorizontalSyncStart;
unsigned short HorizontalSyncEnd;
unsigned short VerticalTotal;
unsigned short VerticalSyncStart;
unsigned short VerticalSyncEnd;
unsigned char Flags;
unsigned long PixelClock; /* units of Hz */
unsigned short RefreshRate; /* units of 0.01 Hz */
unsigned char reserved[40];
unsigned short HorizontalTotal;
unsigned short HorizontalSyncStart;
unsigned short HorizontalSyncEnd;
unsigned short VerticalTotal;
unsigned short VerticalSyncStart;
unsigned short VerticalSyncEnd;
unsigned char Flags;
unsigned long PixelClock; /* units of Hz */
unsigned short RefreshRate; /* units of 0.01 Hz */
unsigned char reserved[40];
} __PACKED__ CRTCInfoBlock;
#define HNEG (1 << 2)
@ -113,116 +113,122 @@ typedef struct CRTCInfoBlock {
static vl_mode *
vesa_init (void)
{
__dpmi_regs r;
word16 *p;
vl_mode *q;
char vesa_info[512], tmp[512];
int maxsize = 0;
word32 linearfb = 0;
__dpmi_regs r;
word16 *p;
vl_mode *q;
char vesa_info[512], tmp[512];
int maxsize = 0;
word32 linearfb = 0;
if (vesa_ver) {
return modes;
}
if (vesa_ver) {
return modes;
}
_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;
}
_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;
}
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) {
q->xres = _16_ tmp[M_XRES];
q->yres = _16_ tmp[M_YRES];
q->scanlen = _16_ tmp[M_SCANLEN];
q->gran = (_16_ tmp[M_GRAN])<<10;
if (tmp[M_ATTR] & 0x80) {
vl_mode *q1 = q + 1;
*q1 = *q++;
linearfb = _32_ tmp[M_PHYS_PTR];
q->mode |= 0x4000;
}
if (maxsize < (q->scanlen * q->yres)) {
maxsize = q->scanlen * q->yres;
}
q++;
}
} while (TRUE);
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) {
q->xres = _16_ tmp[M_XRES];
q->yres = _16_ tmp[M_YRES];
q->scanlen = _16_ tmp[M_SCANLEN];
q->gran = (_16_ tmp[M_GRAN]) << 10;
if (tmp[M_ATTR] & 0x80) {
vl_mode *q1 = q + 1;
*q1 = *q++;
linearfb = _32_ tmp[M_PHYS_PTR];
q->mode |= 0x4000;
}
if (maxsize < (q->scanlen * q->yres)) {
maxsize = q->scanlen * q->yres;
}
q++;
}
} while (TRUE);
if (q == modes) {
return NULL;
}
if (linearfb) {
maxsize = (maxsize + 0xfffUL) & ~0xfffUL;
if (_create_selector(&linear_selector, linearfb, maxsize)) {
return NULL;
}
}
if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) {
_remove_selector(&linear_selector);
return NULL;
}
if (q == modes) {
return NULL;
}
if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) {
return NULL;
}
if (linearfb) {
maxsize = ((maxsize + 0xfffUL) & ~0xfffUL);
if (_create_selector(&linear_selector, linearfb, maxsize)) {
linear_selector = banked_selector;
}
}
for (q = modes; q->mode != 0xffff; q++) {
q->sel = (q->mode & 0x4000) ? linear_selector : banked_selector;
}
for (q = modes; q->mode != 0xffff; q++) {
q->sel = banked_selector;
if (q->mode & 0x4000) {
if (linear_selector != banked_selector) {
q->sel = linear_selector;
} else {
q->mode &= ~0x4000;
}
}
}
if (vesa_info[V_MAJOR] >= 2) {
r.x.ax = 0x4f0a;
r.x.bx = 0;
__dpmi_int(0x10, &r);
if (r.x.ax == 0x004f) {
vesa_pmcode = (word16 *)malloc(r.x.cx);
if (vesa_pmcode != NULL) {
movedata(__djgpp_dos_sel, (r.x.es << 4) + r.x.di, _my_ds(), (unsigned)vesa_pmcode, r.x.cx);
if (vesa_pmcode[3]) {
p = (word16 *)((long)vesa_pmcode + vesa_pmcode[3]);
while (*p++ != 0xffff) {
}
} else {
p = NULL;
}
if (p && (*p != 0xffff)) {
free(vesa_pmcode);
vesa_pmcode = NULL;
} else {
vesa_swbank = (void *)((long)vesa_pmcode + vesa_pmcode[0]);
}
}
}
}
if (vesa_info[V_MAJOR] >= 2) {
r.x.ax = 0x4f0a;
r.x.bx = 0;
__dpmi_int(0x10, &r);
if (r.x.ax == 0x004f) {
vesa_pmcode = (word16 *)malloc(r.x.cx);
if (vesa_pmcode != NULL) {
movedata(__djgpp_dos_sel, (r.x.es << 4) + r.x.di, _my_ds(), (unsigned)vesa_pmcode, r.x.cx);
if (vesa_pmcode[3]) {
p = (word16 *)((long)vesa_pmcode + vesa_pmcode[3]);
while (*p++ != 0xffff) {
}
} else {
p = NULL;
}
if (p && (*p != 0xffff)) {
free(vesa_pmcode);
vesa_pmcode = NULL;
} else {
vesa_swbank = (void *)((long)vesa_pmcode + vesa_pmcode[0]);
}
}
}
}
vesa_ver = _16_ vesa_info[V_MINOR];
return modes;
vesa_ver = _16_ vesa_info[V_MINOR];
return modes;
}
@ -236,14 +242,14 @@ vesa_init (void)
static void
vesa_fini (void)
{
if (vesa_ver) {
_remove_selector(&linear_selector);
_remove_selector(&banked_selector);
if (vesa_pmcode != NULL) {
free(vesa_pmcode);
vesa_pmcode = NULL;
}
}
if (vesa_ver) {
_remove_selector(&linear_selector);
_remove_selector(&banked_selector);
if (vesa_pmcode != NULL) {
free(vesa_pmcode);
vesa_pmcode = NULL;
}
}
}
@ -257,15 +263,15 @@ vesa_fini (void)
static unsigned long
_closest_pixclk (int mode_no, unsigned long vclk)
{
__dpmi_regs r;
__dpmi_regs r;
r.x.ax = 0x4F0B;
r.h.bl = 0;
r.d.ecx = vclk;
r.x.dx = mode_no;
__dpmi_int(0x10, &r);
r.x.ax = 0x4F0B;
r.h.bl = 0;
r.d.ecx = vclk;
r.x.dx = mode_no;
__dpmi_int(0x10, &r);
return (r.x.ax == 0x004f) ? r.d.ecx : 0;
return (r.x.ax == 0x004f) ? r.d.ecx : 0;
}
@ -279,77 +285,253 @@ _closest_pixclk (int mode_no, unsigned long vclk)
static void
_crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust, int yadjust)
{
int HTotal, VTotal;
int HDisp, VDisp;
int HSS, VSS;
int HSE, VSE;
int HSWidth, VSWidth;
int SS, SE;
int doublescan = FALSE;
int HTotal, VTotal;
int HDisp, VDisp;
int HSS, VSS;
int HSE, VSE;
int HSWidth, VSWidth;
int SS, SE;
int doublescan = FALSE;
if (yres < 400) {
doublescan = TRUE;
yres *= 2;
}
if (yres < 400) {
doublescan = TRUE;
yres *= 2;
}
HDisp = xres;
HTotal = (int)(HDisp * 1.27) & ~0x7;
HSWidth = (int)((HTotal - HDisp) / 5) & ~0x7;
HSS = HDisp + 16;
HSE = HSS + HSWidth;
VDisp = yres;
VTotal = VDisp * 1.07;
VSWidth = (VTotal / 100) + 1;
VSS = VDisp + ((int)(VTotal - VDisp) / 5) + 1;
VSE = VSS + VSWidth;
HDisp = xres;
HTotal = (int)(HDisp * 1.27) & ~0x7;
HSWidth = (int)((HTotal - HDisp) / 5) & ~0x7;
HSS = HDisp + 16;
HSE = HSS + HSWidth;
VDisp = yres;
VTotal = VDisp * 1.07;
VSWidth = (VTotal / 100) + 1;
VSS = VDisp + ((int)(VTotal - VDisp) / 5) + 1;
VSE = VSS + VSWidth;
SS = HSS + xadjust;
SE = HSE + xadjust;
SS = HSS + xadjust;
SE = HSE + xadjust;
if (xadjust < 0) {
if (SS < (HDisp + 8)) {
SS = HDisp + 8;
SE = SS + HSWidth;
}
} else {
if ((HTotal - 24) < SE) {
SE = HTotal - 24;
SS = SE - HSWidth;
}
}
if (xadjust < 0) {
if (SS < (HDisp + 8)) {
SS = HDisp + 8;
SE = SS + HSWidth;
}
} else {
if ((HTotal - 24) < SE) {
SE = HTotal - 24;
SS = SE - HSWidth;
}
}
HSS = SS;
HSE = SE;
HSS = SS;
HSE = SE;
SS = VSS + yadjust;
SE = VSE + yadjust;
SS = VSS + yadjust;
SE = VSE + yadjust;
if (yadjust < 0) {
if (SS < (VDisp + 3)) {
SS = VDisp + 3;
SE = SS + VSWidth;
}
} else {
if ((VTotal - 4) < SE) {
SE = VTotal - 4;
SS = SE - VSWidth;
}
}
if (yadjust < 0) {
if (SS < (VDisp + 3)) {
SS = VDisp + 3;
SE = SS + VSWidth;
}
} else {
if ((VTotal - 4) < SE) {
SE = VTotal - 4;
SS = SE - VSWidth;
}
}
VSS = SS;
VSE = SE;
VSS = SS;
VSE = SE;
crtc->HorizontalTotal = HTotal;
crtc->HorizontalSyncStart = HSS;
crtc->HorizontalSyncEnd = HSE;
crtc->VerticalTotal = VTotal;
crtc->VerticalSyncStart = VSS;
crtc->VerticalSyncEnd = VSE;
crtc->Flags = HNEG | VNEG;
crtc->HorizontalTotal = HTotal;
crtc->HorizontalSyncStart = HSS;
crtc->HorizontalSyncEnd = HSE;
crtc->VerticalTotal = VTotal;
crtc->VerticalSyncStart = VSS;
crtc->VerticalSyncEnd = VSE;
crtc->Flags = HNEG | VNEG;
if (doublescan) {
crtc->Flags |= DOUBLESCAN;
}
if (doublescan) {
crtc->Flags |= DOUBLESCAN;
}
}
/* Desc: Attempts to choose a suitable blitter.
*
* In : ptr to mode structure, software framebuffer bits
* Out : blitter funciton, or NULL
*
* Note: -
*/
static BLTFUNC
_choose_blitter (vl_mode *p, int fbbits)
{
BLTFUNC blitter;
if (p->mode & 0x4000) {
blitter = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
switch (p->bpp) {
case 8:
switch (fbbits) {
case 8:
break;
case 16:
blitter = vesa_l_dump_16_to_8;
break;
case 24:
blitter = vesa_l_dump_24_to_8;
break;
case 32:
blitter = vesa_l_dump_32_to_8;
break;
case 15:
default:
return NULL;
}
break;
case 15:
switch (fbbits) {
case 16:
blitter = vesa_l_dump_16_to_15;
break;
case 32:
blitter = vesa_l_dump_32_to_15;
break;
case 8:
case 15:
case 24:
default:
return NULL;
}
break;
case 16:
switch (fbbits) {
case 16:
break;
case 32:
blitter = vesa_l_dump_32_to_16;
break;
case 8:
case 15:
case 24:
default:
return NULL;
}
break;
case 24:
switch (fbbits) {
case 24:
break;
case 32:
blitter = vesa_l_dump_32_to_24;
break;
case 8:
case 15:
case 16:
default:
return NULL;
}
break;
case 32:
switch (fbbits) {
case 24:
blitter = vesa_l_dump_24_to_32;
break;
case 32:
break;
case 8:
case 15:
case 16:
default:
return NULL;
}
break;
}
} else {
blitter = vesa_b_dump_virtual;
switch (p->bpp) {
case 8:
switch (fbbits) {
case 8:
break;
case 16:
blitter = vesa_b_dump_16_to_8;
break;
case 24:
blitter = vesa_b_dump_24_to_8;
break;
case 32:
blitter = vesa_b_dump_32_to_8;
break;
case 15:
default:
return NULL;
}
break;
case 15:
switch (fbbits) {
case 16:
blitter = vesa_b_dump_16_to_15;
break;
case 32:
blitter = vesa_b_dump_32_to_15;
break;
case 8:
case 15:
case 24:
default:
return NULL;
}
break;
case 16:
switch (fbbits) {
case 16:
break;
case 32:
blitter = vesa_b_dump_32_to_16;
break;
case 8:
case 15:
case 24:
default:
return NULL;
}
break;
case 24:
switch (fbbits) {
case 24:
break;
case 32:
blitter = vesa_b_dump_32_to_24;
break;
case 8:
case 15:
case 16:
default:
return NULL;
}
break;
case 32:
switch (fbbits) {
case 24:
blitter = vesa_b_dump_24_to_32;
break;
case 32:
break;
case 8:
case 15:
case 16:
default:
return NULL;
}
break;
}
}
return blitter;
}
@ -361,74 +543,76 @@ _crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust, int yadjust)
* Note: -
*/
static int
vesa_entermode (vl_mode *p, int refresh)
vesa_entermode (vl_mode *p, int refresh, int fbbits)
{
__dpmi_regs r;
__dpmi_regs r;
if (p->mode & 0x4000) {
VESA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
} else {
VESA.blit = vesa_b_dump_virtual;
{ int n; for (vesa_gran_shift=0, n=p->gran; n; vesa_gran_shift++, n>>=1) ; }
vesa_gran_mask = (1 << (--vesa_gran_shift)) - 1;
if ((unsigned)p->gran != (vesa_gran_mask+1)) {
return !0;
}
}
if (!(p->mode & 0x4000)) {
{ int n; for (vesa_gran_shift = 0, n = p->gran; n; vesa_gran_shift++, n >>= 1); }
vesa_gran_mask = (1 << (--vesa_gran_shift)) - 1;
if ((unsigned)p->gran != (vesa_gran_mask + 1)) {
return !0;
}
}
if (oldmode == -1) {
r.x.ax = 0x4f03;
__dpmi_int(0x10, &r);
oldmode = r.x.bx;
}
VESA.blit = _choose_blitter(p, fbbits);
if (VESA.blit == NULL) {
return !0;
}
r.x.ax = 0x4f02;
r.x.bx = p->mode;
if (oldmode == -1) {
r.x.ax = 0x4f03;
__dpmi_int(0x10, &r);
oldmode = r.x.bx;
}
if (refresh && ((vesa_ver>>8) >= 3)) {
/* VESA 3.0 stuff for controlling the refresh rate */
CRTCInfoBlock crtc;
unsigned long vclk;
double f0;
r.x.ax = 0x4f02;
r.x.bx = p->mode;
_crtc_timing(&crtc, p->xres, p->yres, 0, 0);
if (refresh && ((vesa_ver >> 8) >= 3)) {
/* VESA 3.0 stuff for controlling the refresh rate */
CRTCInfoBlock crtc;
unsigned long vclk;
double f0;
vclk = (double)crtc.HorizontalTotal * crtc.VerticalTotal * refresh;
vclk = _closest_pixclk(p->mode, vclk);
_crtc_timing(&crtc, p->xres, p->yres, 0, 0);
if (vclk != 0) {
f0 = (double)vclk / (crtc.HorizontalTotal * crtc.VerticalTotal);
/*_current_refresh_rate = (int)(f0 + 0.5);*/
vclk = (double)crtc.HorizontalTotal * crtc.VerticalTotal * refresh;
vclk = _closest_pixclk(p->mode, vclk);
crtc.PixelClock = vclk;
crtc.RefreshRate = refresh * 100;
if (vclk != 0) {
f0 = (double)vclk / (crtc.HorizontalTotal * crtc.VerticalTotal);
/*_current_refresh_rate = (int)(f0 + 0.5);*/
movedata(_my_ds(), (unsigned)&crtc, _stubinfo->ds_selector, 0, sizeof(crtc));
crtc.PixelClock = vclk;
crtc.RefreshRate = refresh * 100;
r.x.di = 0;
r.x.es = _stubinfo->ds_segment;
r.x.bx |= 0x0800;
}
}
movedata(_my_ds(), (unsigned)&crtc, _stubinfo->ds_selector, 0, sizeof(crtc));
__dpmi_int(0x10, &r);
if (r.x.ax != 0x004f) {
return !0;
}
r.x.di = 0;
r.x.es = _stubinfo->ds_segment;
r.x.bx |= 0x0800;
}
}
if (p->bpp == 8) {
r.x.ax = 0x4f08;
r.x.bx = 0x0800;
__dpmi_int(0x10, &r);
if (r.x.ax == 0x004f) {
r.x.ax = 0x4f08;
r.h.bl = 0x01;
__dpmi_int(0x10, &r);
vesa_color_precision = r.h.bh;
}
}
__dpmi_int(0x10, &r);
if (r.x.ax != 0x004f) {
return !0;
}
return 0;
if (p->bpp == 8) {
r.x.ax = 0x4f08;
r.x.bx = 0x0800;
__dpmi_int(0x10, &r);
if (r.x.ax == 0x004f) {
r.x.ax = 0x4f08;
r.h.bl = 0x01;
__dpmi_int(0x10, &r);
vesa_color_precision = r.h.bh;
}
}
return 0;
}
@ -442,14 +626,18 @@ vesa_entermode (vl_mode *p, int refresh)
static void
vesa_restore (void)
{
__dpmi_regs r;
__dpmi_regs r;
if (oldmode != -1) {
r.x.ax = 0x4f02;
r.x.bx = oldmode;
__dpmi_int(0x10, &r);
oldmode = -1;
}
if (oldmode != -1) {
if (oldmode < 0x100) {
__asm("int $0x10"::"a"(oldmode));
} else {
r.x.ax = 0x4f02;
r.x.bx = oldmode;
__dpmi_int(0x10, &r);
}
oldmode = -1;
}
}
@ -464,17 +652,17 @@ static void
vesa_setCI_i (int index, int red, int green, int blue)
{
#if 0
__asm("\n\
__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);
outportb(0x03C8, index);
outportb(0x03C9, red);
outportb(0x03C9, green);
outportb(0x03C9, blue);
#endif
}
@ -489,9 +677,9 @@ vesa_setCI_i (int index, int red, int green, int blue)
static void
vesa_setCI_f (int index, float red, float green, float blue)
{
float max = (1 << vesa_color_precision) - 1;
float max = (1 << vesa_color_precision) - 1;
vesa_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
vesa_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
}
@ -505,14 +693,14 @@ vesa_setCI_f (int index, float red, float green, float blue)
static int
vesa_get (int pname, int *params)
{
switch (pname) {
case VL_GET_CI_PREC:
params[0] = vesa_color_precision;
break;
default:
return -1;
}
return 0;
switch (pname) {
case VL_GET_CI_PREC:
params[0] = vesa_color_precision;
break;
default:
return -1;
}
return 0;
}
@ -520,12 +708,12 @@ vesa_get (int pname, int *params)
* the driver
*/
vl_driver VESA = {
vesa_init,
vesa_entermode,
NULL,
vesa_setCI_f,
vesa_setCI_i,
vesa_get,
vesa_restore,
vesa_fini
vesa_init,
vesa_entermode,
NULL,
vesa_setCI_f,
vesa_setCI_i,
vesa_get,
vesa_restore,
vesa_fini
};

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.3 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
@ -42,6 +42,24 @@ extern void vesa_b_dump_virtual (void);
extern void vesa_l_dump_virtual (void);
extern void vesa_l_dump_virtual_mmx (void);
extern void vesa_l_dump_32_to_24 (void);
extern void vesa_l_dump_32_to_16 (void);
extern void vesa_l_dump_32_to_15 (void);
extern void vesa_l_dump_32_to_8 (void);
extern void vesa_l_dump_24_to_32 (void);
extern void vesa_l_dump_24_to_8 (void);
extern void vesa_l_dump_16_to_15 (void);
extern void vesa_l_dump_16_to_8 (void);
extern void vesa_b_dump_32_to_24 (void);
extern void vesa_b_dump_32_to_16 (void);
extern void vesa_b_dump_32_to_15 (void);
extern void vesa_b_dump_32_to_8 (void);
extern void vesa_b_dump_24_to_32 (void);
extern void vesa_b_dump_24_to_8 (void);
extern void vesa_b_dump_16_to_15 (void);
extern void vesa_b_dump_16_to_8 (void);
extern vl_driver VESA;
#endif

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.7 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@ -123,6 +123,41 @@ vga_fini (void)
}
/* Desc: Attempts to choose a suitable blitter.
*
* In : ptr to mode structure, software framebuffer bits
* Out : blitter funciton, or NULL
*
* Note: -
*/
static BLTFUNC
_choose_blitter (vl_mode *p, int fbbits)
{
BLTFUNC blitter;
switch (fbbits) {
case 8:
blitter = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
break;
case 16:
blitter = vesa_l_dump_16_to_8;
break;
case 24:
blitter = vesa_l_dump_24_to_8;
break;
case 32:
blitter = vesa_l_dump_32_to_8;
break;
default:
return NULL;
}
return blitter;
(void)p;
}
/* Desc: Attempts to enter specified video mode.
*
* In : ptr to mode structure, refresh rate
@ -131,27 +166,31 @@ vga_fini (void)
* Note: -
*/
static int
vga_entermode (vl_mode *p, int refresh)
vga_entermode (vl_mode *p, int refresh, int fbbits)
{
if (!(p->mode & 0x4000)) {
return -1;
}
VGA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
if (!(p->mode & 0x4000)) {
return -1;
}
if (oldmode == -1) {
__asm("\n\
VGA.blit = _choose_blitter(p, fbbits);
if (VGA.blit == NULL) {
return !0;
}
if (oldmode == -1) {
__asm("\n\
movb $0x0f, %%ah \n\
int $0x10 \n\
andl $0xff, %%eax \n\
movl %%eax, %0 \n\
":"=g"(oldmode)::"%eax", "%ebx");
}
":"=g"(oldmode)::"%eax", "%ebx");
}
__asm("int $0x10"::"a"(p->mode&0xff));
__asm("int $0x10"::"a"(p->mode&0xff));
return 0;
return 0;
(void)refresh; /* silence compiler warning */
(void)refresh; /* silence compiler warning */
}

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.3 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.6 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*
@ -53,17 +53,25 @@ int vl_current_stride, vl_current_width, vl_current_height, vl_current_bytes;
int vl_current_offset, vl_current_delta;
#if HUGE_LOOKUP
/* These lookup tables are used to extract RGB values in [0,255]
* from 15/16-bit pixel values.
*/
static unsigned char pix15r[0x8000];
static unsigned char pix15g[0x8000];
static unsigned char pix15b[0x8000];
static unsigned char pix16r[0x10000];
static unsigned char pix16g[0x10000];
static unsigned char pix16b[0x10000];
#else
void (*vl_flip) (void);
/* FakeColor data */
#define R_CNT 6
#define G_CNT 6
#define B_CNT 6
#define R_BIAS 7
#define G_BIAS 7
#define B_BIAS 7
static word32 VGAPalette[256];
word8 array_r[256];
word8 array_g[256];
word8 array_b[256];
word8 tab_16_8[0x10000];
/* lookup table for scaling 5 bit colors up to 8 bits */
static int _rgb_scale_5[32] = {
0, 8, 16, 25, 33, 41, 49, 58,
@ -71,7 +79,6 @@ static int _rgb_scale_5[32] = {
132, 140, 148, 156, 165, 173, 181, 189,
197, 206, 214, 222, 230, 239, 247, 255
};
#endif
/* lookup table for scaling 6 bit colors up to 8 bits */
static int _rgb_scale_6[64] = {
@ -85,92 +92,6 @@ static int _rgb_scale_6[64] = {
227, 231, 235, 239, 243, 247, 251, 255
};
/* FakeColor data */
#define R_CNT 6
#define G_CNT 6
#define B_CNT 6
#define R_BIAS 7
#define G_BIAS 7
#define B_BIAS 7
static word32 VGAPalette[256];
static word8 array_r[256];
static word8 array_g[256];
static word8 array_b[256];
int (*vl_mixfix) (fixed r, fixed g, fixed b);
int (*vl_mixrgb) (const unsigned char rgb[]);
int (*vl_mixrgba) (const unsigned char rgba[]);
void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]);
int (*vl_getpixel) (unsigned int offset);
void (*vl_clear) (int color);
void (*vl_rect) (int x, int y, int width, int height, int color);
void (*vl_flip) (void);
void (*vl_putpixel) (unsigned int offset, int color);
/* Desc: color composition (w/o ALPHA)
*
* In : R, G, B
* Out : color
*
* Note: -
*/
static int
vl_mixfix8fake (fixed r, fixed g, fixed b)
{
return array_b[b>>FIXED_SHIFT]*G_CNT*R_CNT
+ array_g[g>>FIXED_SHIFT]*R_CNT
+ array_r[r>>FIXED_SHIFT];
}
#define vl_mixfix8 vl_mixfix8fake
static int
vl_mixfix15 (fixed r, fixed g, fixed b)
{
return ((r>>(3+FIXED_SHIFT))<<10)
|((g>>(3+FIXED_SHIFT))<<5)
| (b>>(3+FIXED_SHIFT));
}
static int
vl_mixfix16 (fixed r, fixed g, fixed b)
{
return ((r>>(3+FIXED_SHIFT))<<11)
|((g>>(2+FIXED_SHIFT))<<5)
| (b>>(3+FIXED_SHIFT));
}
#define vl_mixfix24 vl_mixfix32
static int
vl_mixfix32 (fixed r, fixed g, fixed b)
{
return ((r>>FIXED_SHIFT)<<16)
|((g>>FIXED_SHIFT)<<8)
| (b>>FIXED_SHIFT);
}
/* Desc: color composition (w/ ALPHA)
*
* In : array of integers (R, G, B, A)
* Out : color
*
* Note: -
*/
#define vl_mixrgba8 vl_mixrgb8fake
#define vl_mixrgba15 vl_mixrgb15
#define vl_mixrgba16 vl_mixrgb16
#define vl_mixrgba24 vl_mixrgb24
static int
vl_mixrgba32 (const unsigned char rgba[])
{
/* Hack alert:
* currently, DMesa uses Mesa's alpha buffer;
* so we don't really care about alpha value here...
*/
return /*(rgba[3]<<24) | */(rgba[0]<<16) | (rgba[1]<<8) | (rgba[2]);
}
/* Desc: color composition (w/o ALPHA)
*
@ -180,29 +101,12 @@ vl_mixrgba32 (const unsigned char rgba[])
* Note: -
*/
static int
vl_mixrgb8fake (const unsigned char rgb[])
v_mixrgb8fake (const unsigned char rgb[])
{
return array_b[rgb[2]]*G_CNT*R_CNT
+ array_g[rgb[1]]*R_CNT
+ array_r[rgb[0]];
}
#define vl_mixrgb8 vl_mixrgb8fake
static int
vl_mixrgb15 (const unsigned char rgb[])
{
return ((rgb[0]>>3)<<10) | ((rgb[1]>>3)<<5) | (rgb[2]>>3);
}
static int
vl_mixrgb16 (const unsigned char rgb[])
{
return ((rgb[0]>>3)<<11) | ((rgb[1]>>2)<<5) | (rgb[2]>>3);
}
#define vl_mixrgb24 vl_mixrgb32
static int
vl_mixrgb32 (const unsigned char rgb[])
{
return (rgb[0]<<16) | (rgb[1]<<8) | (rgb[2]);
}
/* Desc: color decomposition
@ -213,102 +117,43 @@ vl_mixrgb32 (const unsigned char rgb[])
* Note: uses current read buffer
*/
static void
v_getrgba8fake6 (unsigned int offset, unsigned char rgba[4])
v_getrgb8fake6 (unsigned int offset, unsigned char rgb[])
{
word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]];
rgba[0] = _rgb_scale_6[(c >> 16) & 0x3F];
rgba[1] = _rgb_scale_6[(c >> 8) & 0x3F];
rgba[2] = _rgb_scale_6[ c & 0x3F];
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
rgb[0] = _rgb_scale_6[(c >> 16) & 0x3F];
rgb[1] = _rgb_scale_6[(c >> 8) & 0x3F];
rgb[2] = _rgb_scale_6[ c & 0x3F];
}
static void
v_getrgba8fake8 (unsigned int offset, unsigned char rgba[4])
v_getrgb8fake8 (unsigned int offset, unsigned char rgb[])
{
word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]];
rgba[0] = c >> 16;
rgba[1] = c >> 8;
rgba[2] = c;
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
}
#define v_getrgba8 v_getrgba8fake6
static void
v_getrgba15 (unsigned int offset, unsigned char rgba[4])
{
word32 c = ((word16 *)vl_current_read_buffer)[offset];
#if HUGE_LOOKUP
c &= 0x7fff;
rgba[0] = pix15r[c];
rgba[1] = pix15g[c];
rgba[2] = pix15b[c];
#else
rgba[0] = _rgb_scale_5[(c >> 10) & 0x1F];
rgba[1] = _rgb_scale_5[(c >> 5) & 0x1F];
rgba[2] = _rgb_scale_5[ c & 0x1F];
#endif
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
}
static void
v_getrgba16 (unsigned int offset, unsigned char rgba[4])
{
word32 c = ((word16 *)vl_current_read_buffer)[offset];
#if HUGE_LOOKUP
rgba[0] = pix16r[c];
rgba[1] = pix16g[c];
rgba[2] = pix16b[c];
#else
rgba[0] = _rgb_scale_5[(c >> 11) & 0x1F];
rgba[1] = _rgb_scale_6[(c >> 5) & 0x3F];
rgba[2] = _rgb_scale_5[ c & 0x1F];
#endif
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
}
static void
v_getrgba24 (unsigned int offset, unsigned char rgba[4])
{
word32 c = *(word32 *)((long)vl_current_read_buffer+offset*3);
rgba[0] = c >> 16;
rgba[1] = c >> 8;
rgba[2] = c;
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
}
static void
v_getrgba32 (unsigned int offset, unsigned char rgba[4])
{
word32 c = ((word32 *)vl_current_read_buffer)[offset];
rgba[0] = c >> 16;
rgba[1] = c >> 8;
rgba[2] = c;
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
rgb[0] = c >> 16;
rgb[1] = c >> 8;
rgb[2] = c;
}
/* Desc: pixel retrieval
/* Desc: create R5G6B5 to FakeColor table lookup
*
* In : pixel offset
* Out : pixel value
* In : -
* Out : -
*
* Note: uses current read buffer
* Note: -
*/
static int
v_getpixel8 (unsigned int offset)
static void
init_tab_16_8 (void)
{
return ((word8 *)vl_current_read_buffer)[offset];
}
#define v_getpixel15 v_getpixel16
static int
v_getpixel16 (unsigned int offset)
{
return ((word16 *)vl_current_read_buffer)[offset];
}
static int
v_getpixel24 (unsigned int offset)
{
return *(word32 *)((long)vl_current_read_buffer+offset*3);
}
static int
v_getpixel32 (unsigned int offset)
{
return ((word32 *)vl_current_read_buffer)[offset];
int i;
for (i = 0; i < 0x10000; i++) {
unsigned char rgb[3];
rgb[0] = _rgb_scale_5[(i >> 11) & 0x1F];
rgb[1] = _rgb_scale_6[(i >> 5) & 0x3F];
rgb[2] = _rgb_scale_5[ i & 0x1F];
tab_16_8[i] = v_mixrgb8fake(rgb);
}
(void)v_getrgb8fake6;
(void)v_getrgb8fake8;
}
@ -379,54 +224,6 @@ fake_buildpalette (int bits)
}
#if HUGE_LOOKUP
/* Desc: initialize lookup arrays
*
* In : -
* Out : -
*
* Note: -
*/
void
v_init_pixeltables (void)
{
unsigned int pixel;
for (pixel = 0; pixel <= 0xffff; pixel++) {
unsigned int r, g, b;
if (pixel <= 0x7fff) {
/* 15bit */
r = (pixel & 0x7c00) >> 8;
g = (pixel & 0x03E0) >> 3;
b = (pixel & 0x001F) << 2;
r = (unsigned int)(((double)r * 255. / 0x7c) + 0.5);
g = (unsigned int)(((double)g * 255. / 0x7c) + 0.5);
b = (unsigned int)(((double)b * 255. / 0x7c) + 0.5);
pix15r[pixel] = r;
pix15g[pixel] = g;
pix15b[pixel] = b;
}
/* 16bit */
r = (pixel & 0xF800) >> 8;
g = (pixel & 0x07E0) >> 3;
b = (pixel & 0x001F) << 3;
r = (unsigned int)(((double)r * 255. / 0xF8) + 0.5);
g = (unsigned int)(((double)g * 255. / 0xFC) + 0.5);
b = (unsigned int)(((double)b * 255. / 0xF8) + 0.5);
pix16r[pixel] = r;
pix16g[pixel] = g;
pix16b[pixel] = b;
}
}
#endif
/* Desc: initialize hardware
*
* In : -
@ -471,7 +268,7 @@ v_init_hw (void)
int
vl_sync_buffer (void **buffer, int x, int y, int width, int height)
{
if ((width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) {
if ((/*XXX*/width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) {
return -1;
} else {
void *newbuf = *buffer;
@ -553,38 +350,21 @@ vl_setup_mode (vl_mode *p)
return -1;
}
#define INITPTR(bpp) \
vl_putpixel = v_putpixel##bpp; \
vl_getrgba = v_getrgba##bpp; \
vl_getpixel = v_getpixel##bpp; \
vl_rect = v_rect##bpp; \
vl_mixfix = vl_mixfix##bpp; \
vl_mixrgb = vl_mixrgb##bpp; \
vl_mixrgba = vl_mixrgba##bpp; \
vl_clear = _can_mmx() ? v_clear##bpp##_mmx : v_clear##bpp
switch (p->bpp) {
case 8:
INITPTR(8);
break;
case 15:
INITPTR(15);
break;
case 16:
INITPTR(16);
break;
case 24:
INITPTR(24);
break;
case 32:
INITPTR(32);
break;
default:
return -1;
}
#undef INITPTR
video_mode = p;
video_bypp = (p->bpp+7)/8;
video_scanlen = p->scanlen;
@ -618,7 +398,7 @@ vl_video_exit (void)
* Note: -
*/
int
vl_video_init (int width, int height, int bpp, int rgb, int refresh)
vl_video_init (int width, int height, int bpp, int rgb, int refresh, int fbbits)
{
int fake;
vl_mode *p, *q;
@ -630,11 +410,6 @@ vl_video_init (int width, int height, int bpp, int rgb, int refresh)
} else if (bpp == 8) {
fake = 1;
}
#if HUGE_LOOKUP
else if (bpp < 24) {
v_init_pixeltables();
}
#endif
/* initialize hardware */
if ((q = v_init_hw()) == NULL) {
@ -651,18 +426,16 @@ vl_video_init (int width, int height, int bpp, int rgb, int refresh)
}
}
/* setup and enter mode */
if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
vl_flip = drv->blit;
if (fake) {
drv->get(VL_GET_CI_PREC, (int *)(&min));
fake_buildpalette(min);
if (min == 8) {
vl_getrgba = v_getrgba8fake8;
}
}
return bpp;
}
/* setup and enter mode */
if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh, fbbits) == 0)) {
vl_flip = drv->blit;
if (fake) {
drv->get(VL_GET_CI_PREC, (int *)(&min));
fake_buildpalette(min);
init_tab_16_8();
}
return bpp;
}
/* abort */
return 0;

View file

@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.5 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@ -43,16 +43,7 @@ typedef int fixed;
#define VL_GET_SCREEN_SIZE 0x0202
#define VL_GET_VIDEO_MODES 0x0300
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);
@ -60,6 +51,6 @@ 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);
int vl_video_init (int width, int height, int bpp, int rgb, int refresh, int fbbits);
#endif

View file

@ -1,489 +0,0 @@
/*
* 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