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@yahoo.com
30 * Web : http://www.geocities.com/dborca
37 * extern unsigned int vesa_gran_mask, vesa_gran_shift;
38 * extern int vl_video_selector;
40 * extern void *vl_current_draw_buffer;
41 * extern int vl_current_stride, vl_current_height;
42 * extern int vl_current_offset, vl_current_delta;
47 /* Desc: VESA bank switching routine (BIOS)
49 * In : EBX=0, EDX = bank number
62 _vesa_swbank: .long _vesa_swbankBIOS
64 /* Desc: void vesa_b_dump_virtual (void);
69 * Note: uses current draw buffer
72 .global _vesa_b_dump_virtual
80 movl _vl_video_selector, %es
81 movl _vl_current_draw_buffer, %esi
82 movl _vl_current_offset, %edi
83 movl _vesa_gran_shift, %ecx
84 movl _vesa_gran_mask, %ebp
91 movl _vl_current_stride, %ecx
92 movl _vl_current_height, %eax
93 movl _vl_current_delta, %ebx
126 /* Desc: void vesa_l_dump_virtual (void);
131 * Note: uses current draw buffer
134 .global _vesa_l_dump_virtual
135 _vesa_l_dump_virtual:
140 movl _vl_video_selector, %es
141 movl _vl_current_draw_buffer, %esi
142 movl _vl_current_offset, %edi
143 movl _vl_current_stride, %ecx
144 movl _vl_current_height, %edx
145 movl _vl_current_delta, %eax
160 /* Desc: void vesa_l_dump_virtual_mmx (void);
165 * Note: uses current draw buffer
168 .global _vesa_l_dump_virtual_mmx
169 _vesa_l_dump_virtual_mmx:
173 movl _vl_video_selector, %fs
174 movl _vl_current_draw_buffer, %esi
175 movl _vl_current_offset, %edi
176 movl _vl_current_stride, %ecx
177 movl _vl_current_height, %edx
178 movl _vl_current_delta, %eax
187 movq %mm0, %fs:(%edi)
203 #define CVT_32_TO_16(s, tmp) \
204 /* SRC = bbbbbbbbggggggggrrrrrrrr******** */\
205 movl %e##s##x, %tmp ;\
206 /* TMP = bbbbbbbbggggggggrrrrrrrr******** */\
208 /* SRC = bbbbbbbbgggggg00rrrrrrrr******** */\
209 andl $0xF80000, %tmp ;\
210 /* TMP = 0000000000000000000rrrrr00000000 */\
212 /* SRC = bbbbbgggggg00000rrrrrrrr******** */\
214 /* TMP = 00000000000rrrrr0000000000000000 */\
215 orl %tmp, %e##s##x ;\
216 /* SRC = bbbbbggggggrrrrrrrrrrrrr******** */
218 #define CVT_32_TO_15(s, tmp) \
219 /* SRC = bbbbbbbbggggggggrrrrrrrr******** */\
220 movl %e##s##x, %tmp ;\
221 /* TMP = bbbbbbbbggggggggrrrrrrrr******** */\
223 /* SRC = bbbbbbbbgggggg00rrrrrrrr******** */\
224 andl $0xF80000, %tmp ;\
225 /* TMP = 0000000000000000000rrrrr00000000 */\
227 /* SRC = bbbbbgggggg00000rrrrrrrr******** */\
229 /* TMP = 00000000000rrrrr0000000000000000 */\
230 orl %tmp, %e##s##x ;\
231 /* SRC = bbbbbggggggrrrrrrrrrrrrr******** */
233 #define CVT_16_TO_15(src, tmp) \
234 /* SRC = bbbbbggggggrrrrrBBBBBGGGGGGRRRRR */\
236 /* TMP = bbbbbggggggrrrrrBBBBBGGGGGGRRRRR */\
237 andl $0x1F001F, %src ;\
238 /* SRC = bbbbb00000000000BBBBB00000000000 */\
239 andl $0xFFC0FFC0, %tmp ;\
240 /* TMP = 000000gggggrrrrr000000GGGGGRRRRR */\
242 /* TMP = 00000gggggrrrrr000000GGGGGRRRRR0 */\
244 /* SRC = bbbbbgggggrrrrr0BBBBBGGGGGRRRRR0 */\
248 /* transform BGRA to BGR */
250 .global _vesa_l_dump_32_to_24
251 _vesa_l_dump_32_to_24:
255 movl _vl_video_selector, %fs
256 movl _vl_current_draw_buffer, %esi
257 movl _vl_current_offset, %edi
258 movl _vl_current_stride, %ecx
259 movl _vl_current_height, %edx
260 movl _vl_current_delta, %ebx
269 movb %al, %fs:2(%edi)
282 /* transform BGRA to B5G6R5 */
284 .global _vesa_l_dump_32_to_16
285 _vesa_l_dump_32_to_16:
290 movl _vl_video_selector, %fs
291 movl _vl_current_draw_buffer, %esi
292 movl _vl_current_offset, %edi
293 movl _vl_current_stride, %ecx
294 movl _vl_current_height, %edx
295 movl _vl_current_delta, %ebx
317 /* transform BGRA to B5G5R5 */
319 .global _vesa_l_dump_32_to_15
320 _vesa_l_dump_32_to_15:
325 movl _vl_video_selector, %fs
326 movl _vl_current_draw_buffer, %esi
327 movl _vl_current_offset, %edi
328 movl _vl_current_stride, %ecx
329 movl _vl_current_height, %edx
330 movl _vl_current_delta, %ebx
352 /* transform BGRA to fake8 */
354 .global _vesa_l_dump_32_to_8
355 _vesa_l_dump_32_to_8:
360 movl _vl_video_selector, %fs
361 movl _vl_current_draw_buffer, %esi
362 movl _vl_current_offset, %edi
363 movl _vl_current_stride, %ecx
364 movl _vl_current_height, %edx
365 movl _vl_current_delta, %ebx
382 movb _array_b(%eax), %al
383 movb _array_r(%edx), %dl
384 movb _array_g(%ebx), %bl
407 /* transform BGR to BGRx */
409 .global _vesa_l_dump_24_to_32
410 _vesa_l_dump_24_to_32:
414 movl _vl_video_selector, %fs
415 movl _vl_current_draw_buffer, %esi
416 movl _vl_current_offset, %edi
417 movl _vl_current_stride, %ecx
418 movl _vl_current_height, %edx
419 movl _vl_current_delta, %ebx
426 movl %eax, %fs:(%edi)
439 /* transform BGR to fake8 */
441 .global _vesa_l_dump_24_to_8
442 _vesa_l_dump_24_to_8:
447 movl _vl_video_selector, %fs
448 movl _vl_current_draw_buffer, %esi
449 movl _vl_current_offset, %edi
450 movl _vl_current_stride, %ecx
451 movl _vl_current_height, %edx
452 movl _vl_current_delta, %ebx
469 movb _array_b(%eax), %al
470 movb _array_r(%edx), %dl
471 movb _array_g(%ebx), %bl
494 /* transform B5G6R5 to B5G5R5 */
496 .global _vesa_l_dump_16_to_15
497 _vesa_l_dump_16_to_15:
502 movl _vl_video_selector, %fs
503 movl _vl_current_draw_buffer, %esi
504 movl _vl_current_offset, %edi
505 movl _vl_current_stride, %ecx
506 movl _vl_current_height, %edx
507 movl _vl_current_delta, %ebx
514 CVT_16_TO_15(eax, ebp)
515 movl %eax, %fs:(%edi)
529 /* transform B5G6R5 to fake8 */
531 .global _vesa_l_dump_16_to_8
532 _vesa_l_dump_16_to_8:
537 movl _vl_video_selector, %fs
538 movl _vl_current_draw_buffer, %esi
539 movl _vl_current_offset, %edi
540 movl _vl_current_stride, %ecx
541 movl _vl_current_height, %edx
542 movl _vl_current_delta, %ebx
554 movb _tab_16_8(%eax), %al
555 movb _tab_16_8(%ebx), %ah
575 .global _vesa_b_dump_32_to_24
576 _vesa_b_dump_32_to_24:
581 movl _vl_video_selector, %fs
582 movl _vl_current_draw_buffer, %esi
583 movl _vl_current_offset, %edi
584 movl _vesa_gran_shift, %ecx
585 movl _vesa_gran_mask, %ebp
592 movl _vl_current_stride, %ecx
593 movl _vl_current_height, %eax
594 movl $0x00FFFFFF, %ebx
611 movb (%esi), %al /* XXX too many accesses */
621 addl _vl_current_delta, %edi
631 .global _vesa_b_dump_32_to_16
632 _vesa_b_dump_32_to_16:
637 movl _vl_video_selector, %fs
638 movl _vl_current_draw_buffer, %esi
639 movl _vl_current_offset, %edi
640 movl _vesa_gran_shift, %ecx
641 movl _vesa_gran_mask, %ebp
648 movl _vl_current_stride, %ecx
649 movl _vl_current_height, %eax
673 addl _vl_current_delta, %edi
683 .global _vesa_b_dump_32_to_15
684 _vesa_b_dump_32_to_15:
689 movl _vl_video_selector, %fs
690 movl _vl_current_draw_buffer, %esi
691 movl _vl_current_offset, %edi
692 movl _vesa_gran_shift, %ecx
693 movl _vesa_gran_mask, %ebp
700 movl _vl_current_stride, %ecx
701 movl _vl_current_height, %eax
725 addl _vl_current_delta, %edi
735 .global _vesa_b_dump_32_to_8
736 _vesa_b_dump_32_to_8:
741 movl _vl_video_selector, %fs
742 movl _vl_current_draw_buffer, %esi
743 movl _vl_current_offset, %edi
744 movl _vesa_gran_shift, %ecx
745 movl _vesa_gran_mask, %ebp
752 movl _vl_current_stride, %ecx
753 movl _vl_current_height, %eax
781 movb _array_b(%eax), %al
782 movb _array_r(%edx), %dl
783 movb _array_g(%ebx), %bl
797 addl _vl_current_delta, %edi
807 .global _vesa_b_dump_24_to_32
808 _vesa_b_dump_24_to_32:
813 movl _vl_video_selector, %fs
814 movl _vl_current_draw_buffer, %esi
815 movl _vl_current_offset, %edi
816 movl _vesa_gran_shift, %ecx
817 movl _vesa_gran_mask, %ebp
824 movl _vl_current_stride, %ecx
825 movl _vl_current_height, %eax
826 movl _vl_current_delta, %ebx
845 movl %eax, %fs:(%edi)
861 .global _vesa_b_dump_24_to_8
862 _vesa_b_dump_24_to_8:
867 movl _vl_video_selector, %fs
868 movl _vl_current_draw_buffer, %esi
869 movl _vl_current_offset, %edi
870 movl _vesa_gran_shift, %ecx
871 movl _vesa_gran_mask, %ebp
878 movl _vl_current_stride, %ecx
879 movl _vl_current_height, %eax
907 movb _array_b(%eax), %al
908 movb _array_r(%edx), %dl
909 movb _array_g(%ebx), %bl
923 addl _vl_current_delta, %edi
933 .global _vesa_b_dump_16_to_15
934 _vesa_b_dump_16_to_15:
939 movl _vl_video_selector, %fs
940 movl _vl_current_draw_buffer, %esi
941 movl _vl_current_offset, %edi
942 movl _vesa_gran_shift, %ecx
943 movl _vesa_gran_mask, %ebp
950 movl _vl_current_stride, %ecx
951 movl _vl_current_height, %eax
968 CVT_16_TO_15(eax, ebx)
975 addl _vl_current_delta, %edi
985 .global _vesa_b_dump_16_to_8
986 _vesa_b_dump_16_to_8:
991 movl _vl_video_selector, %fs
992 movl _vl_current_draw_buffer, %esi
993 movl _vl_current_offset, %edi
994 movl _vesa_gran_shift, %ecx
995 movl _vesa_gran_mask, %ebp
1002 movl _vl_current_stride, %ecx
1003 movl _vl_current_height, %eax
1004 movl _vl_current_delta, %ebx
1025 movb _tab_16_8(%eax), %al
1027 movb %al, %fs:(%edi)