DOS updates for new tree (Daniel Borca)
[mesa.git] / src / mesa / drivers / dos / blit.S
1 /*
2 * Mesa 3-D graphics library
3 * Version: 4.0
4 *
5 * Copyright (C) 1999 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
25 /*
26 * DOS/DJGPP device driver v1.3 for Mesa
27 *
28 * Copyright (C) 2002 - Borca Daniel
29 * Email : dborca@yahoo.com
30 * Web : http://www.geocities.com/dborca
31 */
32
33
34 .file "blit.S"
35
36 /*
37 * extern unsigned int vesa_gran_mask, vesa_gran_shift;
38 * extern int vl_video_selector;
39
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;
43 */
44
45 .text
46
47 /* Desc: VESA bank switching routine (BIOS)
48 *
49 * In : EBX=0, EDX = bank number
50 * Out : -
51 *
52 * Note: thrashes EAX
53 */
54 .p2align 5,,31
55 _vesa_swbankBIOS:
56 movw $0x4f05, %ax
57 int $0x10
58 ret
59
60 .p2align 2,,3
61 .global _vesa_swbank
62 _vesa_swbank: .long _vesa_swbankBIOS
63
64 /* Desc: void vesa_b_dump_virtual (void);
65 *
66 * In : -
67 * Out : -
68 *
69 * Note: uses current draw buffer
70 */
71 .p2align 5,,31
72 .global _vesa_b_dump_virtual
73 _vesa_b_dump_virtual:
74 cld
75 pushl %es
76 pushl %ebx
77 pushl %esi
78 pushl %edi
79 pushl %ebp
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
85 movl %edi, %edx
86 xorl %ebx, %ebx
87 andl %ebp, %edi
88 shrl %cl, %edx
89 incl %ebp
90 call *_vesa_swbank
91 movl _vl_current_stride, %ecx
92 movl _vl_current_height, %eax
93 movl _vl_current_delta, %ebx
94 shrl $2, %ecx
95 .balign 4
96 0:
97 pushl %ecx
98 .balign 4
99 1:
100 cmpl %ebp, %edi
101 jb 2f
102 pushl %eax
103 pushl %ebx
104 incl %edx
105 xorl %ebx, %ebx
106 call *_vesa_swbank
107 popl %ebx
108 popl %eax
109 subl %ebp, %edi
110 .balign 4
111 2:
112 movsl
113 decl %ecx
114 jnz 1b
115 popl %ecx
116 addl %ebx, %edi
117 decl %eax
118 jnz 0b
119 popl %ebp
120 popl %edi
121 popl %esi
122 popl %ebx
123 popl %es
124 ret
125
126 /* Desc: void vesa_l_dump_virtual (void);
127 *
128 * In : -
129 * Out : -
130 *
131 * Note: uses current draw buffer
132 */
133 .p2align 5,,31
134 .global _vesa_l_dump_virtual
135 _vesa_l_dump_virtual:
136 cld
137 pushl %es
138 pushl %esi
139 pushl %edi
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
146 shrl $2, %ecx
147 .balign 4
148 0:
149 pushl %ecx
150 rep; movsl
151 popl %ecx
152 addl %eax, %edi
153 decl %edx
154 jnz 0b
155 popl %edi
156 popl %esi
157 popl %es
158 ret
159
160 /* Desc: void vesa_l_dump_virtual_mmx (void);
161 *
162 * In : -
163 * Out : -
164 *
165 * Note: uses current draw buffer
166 */
167 .p2align 5,,31
168 .global _vesa_l_dump_virtual_mmx
169 _vesa_l_dump_virtual_mmx:
170 #ifdef USE_MMX_ASM
171 pushl %esi
172 pushl %edi
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
179 shrl $3, %ecx
180 .balign 4
181 0:
182 pushl %ecx
183 .balign 4
184 1:
185 movq (%esi), %mm0
186 addl $8, %esi
187 movq %mm0, %fs:(%edi)
188 addl $8, %edi
189 decl %ecx
190 jnz 1b
191 popl %ecx
192 addl %eax, %edi
193 decl %edx
194 jnz 0b
195 popl %edi
196 popl %esi
197 emms
198 #endif
199 ret