2 * Mesa 3-D graphics library
5 * Copyright (C) 1999 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * DOS/DJGPP device driver for Mesa
28 * Author: Daniel Borca
29 * Email : dborca@users.sourceforge.net
30 * Web : http://www.geocities.com/dborca
41 static vl_mode modes
[] = {
46 /* .mode = */ 0x13 | 0x4000,
62 static word16 vga_ver
;
63 static int linear_selector
;
64 static int oldmode
= -1;
66 #define vga_color_precision 6
69 /* Desc: Attempts to detect VGA, check video modes and create selectors.
86 movw $0x1a00, %%ax \n\
94 0:":"=g"(rv
)::"%eax", "%ebx");
99 if (_create_selector(&linear_selector
, 0xa0000, 0x10000)) {
103 modes
[0].sel
= linear_selector
;
110 /* Desc: Frees all resources allocated by VGA init code.
121 _remove_selector(&linear_selector
);
126 /* Desc: Attempts to choose a suitable blitter.
128 * In : ptr to mode structure, software framebuffer bits
129 * Out : blitter funciton, or NULL
134 _choose_blitter (vl_mode
*p
, int fbbits
)
140 blitter
= _can_mmx() ? vesa_l_dump_virtual_mmx
: vesa_l_dump_virtual
;
143 blitter
= vesa_l_dump_16_to_8
;
146 blitter
= vesa_l_dump_24_to_8
;
149 blitter
= vesa_l_dump_32_to_8
;
161 /* Desc: Attempts to enter specified video mode.
163 * In : ptr to mode structure, refresh rate
169 vga_entermode (vl_mode
*p
, int refresh
, int fbbits
)
171 if (!(p
->mode
& 0x4000)) {
175 VGA
.blit
= _choose_blitter(p
, fbbits
);
176 if (VGA
.blit
== NULL
) {
184 andl $0xff, %%eax \n\
186 ":"=g"(oldmode
)::"%eax", "%ebx");
189 __asm("int $0x10"::"a"(p
->mode
&0xff));
193 (void)refresh
; /* silence compiler warning */
197 /* Desc: Restores to the mode prior to first call to vga_entermode.
208 __asm("int $0x10"::"a"(oldmode
));
214 /* Desc: set one palette entry
216 * In : color index, R, G, B
219 * Note: uses integer values
222 vga_setCI_i (int index
, int red
, int green
, int blue
)
226 movw $0x1010, %%ax \n\
230 "::"b"(index
), "m"(red
), "m"(green
), "c"(blue
):"%eax", "%edx");
232 outportb(0x03C8, index
);
233 outportb(0x03C9, red
);
234 outportb(0x03C9, green
);
235 outportb(0x03C9, blue
);
240 /* Desc: set one palette entry
242 * In : color index, R, G, B
245 * Note: uses normalized values
248 vga_setCI_f (int index
, float red
, float green
, float blue
)
250 float max
= (1 << vga_color_precision
) - 1;
252 vga_setCI_i(index
, (int)(red
* max
), (int)(green
* max
), (int)(blue
* max
));
256 /* Desc: state retrieval
258 * In : parameter name, ptr to storage
259 * Out : 0 if request successfully processed
264 vga_get (int pname
, int *params
)
268 params
[0] = vga_color_precision
;