Adjust mga drivers to remove redundant h file for sarea and IOCTLs
[mesa.git] / src / mesa / drivers / dos / virtual.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 "virtual.S"
35
36 /*
37 * extern void *vl_current_draw_buffer;
38 * extern int vl_current_width, vl_current_bytes;
39 */
40
41 .text
42
43 /* Desc: void v_clear8 (int color);
44 *
45 * In : color
46 * Out : -
47 *
48 * Note: uses current draw buffer
49 */
50 .p2align 5,,31
51 .global _v_clear8
52 _v_clear8:
53 movl 4(%esp), %eax
54 movb %al, %ah
55 pushw %ax
56 pushw %ax
57 popl %eax
58 jmp _v_clear_common
59
60 /* Desc: void v_clear16 (int color);
61 *
62 * In : color
63 * Out : -
64 *
65 * Note: uses current draw buffer
66 */
67 .p2align 5,,31
68 .global _v_clear16
69 _v_clear16:
70 movl 4(%esp), %eax
71 pushw %ax
72 pushw %ax
73 popl %eax
74 jmp _v_clear_common
75
76 /* Desc: void v_clear32 (int color);
77 *
78 * In : color
79 * Out : -
80 *
81 * Note: uses current draw buffer
82 */
83 .p2align 5,,31
84 .global _v_clear32
85 _v_clear32:
86 movl 4(%esp), %eax
87 .balign 4
88 _v_clear_common:
89 movl _vl_current_bytes, %ecx
90 movl _vl_current_draw_buffer, %edx
91 shrl $2, %ecx
92 .balign 4
93 0:
94 movl %eax, (%edx)
95 addl $4, %edx
96 decl %ecx
97 jnz 0b
98 ret
99
100 /* Desc: void v_clear8_mmx (int color);
101 *
102 * In : color
103 * Out : -
104 *
105 * Note: uses current draw buffer
106 */
107 .p2align 5,,31
108 .global _v_clear8_mmx
109 _v_clear8_mmx:
110 #ifdef USE_MMX_ASM
111 movd 4(%esp), %mm0
112 punpcklbw %mm0, %mm0
113 punpcklwd %mm0, %mm0
114 jmp _v_clear_common_mmx
115 #endif
116
117 /* Desc: void v_clear16_mmx (int color);
118 *
119 * In : color
120 * Out : -
121 *
122 * Note: uses current draw buffer
123 */
124 .p2align 5,,31
125 .global _v_clear16_mmx
126 _v_clear16_mmx:
127 #ifdef USE_MMX_ASM
128 movd 4(%esp), %mm0
129 punpcklwd %mm0, %mm0
130 jmp _v_clear_common_mmx
131 #endif
132
133 /* Desc: void v_clear32_mmx (int color);
134 *
135 * In : color
136 * Out : -
137 *
138 * Note: uses current draw buffer
139 */
140 .p2align 5,,31
141 .global _v_clear32_mmx
142 _v_clear32_mmx:
143 #ifdef USE_MMX_ASM
144 movd 4(%esp), %mm0
145 .balign 4
146 _v_clear_common_mmx:
147 punpckldq %mm0, %mm0
148 movl _vl_current_bytes, %ecx
149 movl _vl_current_draw_buffer, %edx
150 shrl $3, %ecx
151 .balign 4
152 0:
153 movq %mm0, (%edx)
154 addl $8, %edx
155 decl %ecx
156 jnz 0b
157 emms
158 #endif
159 ret
160
161 /* Desc: void v_clear24 (int color);
162 *
163 * In : color
164 * Out : -
165 *
166 * Note: uses current draw buffer
167 */
168 .p2align 5,,31
169 .global _v_clear24
170 _v_clear24:
171 movl $0xaaaaaaab, %eax
172 mull _vl_current_bytes
173 movl 4(%esp), %eax
174 movl %edx, %ecx
175 pushl %ebx
176 movl _vl_current_draw_buffer, %edx
177 shrl %ecx
178 movb 10(%esp), %bl
179 .balign 4
180 0:
181 movw %ax, (%edx)
182 movb %bl, 2(%edx)
183 addl $3, %edx
184 decl %ecx
185 jnz 0b
186 popl %ebx
187 ret
188
189 /* Desc: void v_clear24_mmx (int color);
190 *
191 * In : color
192 * Out : -
193 *
194 * Note: uses current draw buffer
195 */
196 .p2align 5,,31
197 .global _v_clear24_mmx
198 _v_clear24_mmx:
199 #ifdef USE_MMX_ASM
200 movl 4(%esp), %eax
201 movl %eax, %edx
202 movl %eax, %ecx
203 shll $16, %edx
204 rorl $8, %ecx
205 movw %cx, %dx
206 rorl $16, %ecx
207 movb %dh, %cl
208 shll $8, %eax
209 movb %ch, %al
210 rorl $8, %eax
211
212 pushl %edx
213 pushl %eax
214 movq (%esp), %mm0
215 pushl %ecx
216 movq (%esp), %mm1
217 pushl %edx
218 movq (%esp), %mm2
219
220 movl $0xaaaaaaab, %eax
221 mull _vl_current_bytes
222 movl %edx, %ecx
223 movl _vl_current_draw_buffer, %edx
224 shrl $4, %ecx
225 .balign 4
226 0:
227 movq %mm0, (%edx)
228 movq %mm1, 8(%edx)
229 movq %mm2, 16(%edx)
230 addl $24, %edx
231 decl %ecx
232 jnz 0b
233 emms
234 addl $16, %esp
235 #endif
236 ret
237
238 /* Desc: void v_rect8 (int color);
239 *
240 * In : color
241 * Out : -
242 *
243 * Note: uses current draw buffer
244 */
245 .p2align 5,,31
246 .global _v_rect8
247 _v_rect8:
248 cld
249 pushl %esi
250 pushl %edi
251 movl 28(%esp), %eax
252 movl _vl_current_width, %esi
253 movl 16(%esp), %edi
254 movb %al, %ah
255 movl 20(%esp), %ecx
256 imull %esi, %edi
257 movl 24(%esp), %edx
258 subl %ecx, %esi
259 addl 12(%esp), %edi
260 pushw %ax
261 pushw %ax
262 pushl %ds
263 popl %es
264 addl _vl_current_draw_buffer, %edi
265 popl %eax
266 pushl %ebx
267 movl %ecx, %ebx
268 andl $3, %ebx
269 .balign 4
270 0:
271 pushl %ecx
272 .balign 4
273 1:
274 shrl $2, %ecx
275 rep; stosl
276 testl %ebx, %ebx
277 jz 2f
278 movl %ebx, %ecx
279 rep; stosb
280 .balign 4
281 2:
282 popl %ecx
283 addl %esi, %edi
284 decl %edx
285 jnz 0b
286 popl %ebx
287 popl %edi
288 popl %esi
289 ret
290
291 /* Desc: void v_rect16 (int color);
292 *
293 * In : color
294 * Out : -
295 *
296 * Note: uses current draw buffer
297 */
298 .p2align 5,,31
299 .global _v_rect16
300 _v_rect16:
301 cld
302 pushl %esi
303 pushl %edi
304 movl 28(%esp), %eax
305 movl _vl_current_width, %esi
306 movl 16(%esp), %edi
307 movl 20(%esp), %ecx
308 imull %esi, %edi
309 movl 24(%esp), %edx
310 subl %ecx, %esi
311 addl 12(%esp), %edi
312 pushw %ax
313 shll %esi
314 pushw %ax
315 shll %edi
316 pushl %ds
317 popl %es
318 addl _vl_current_draw_buffer, %edi
319 popl %eax
320 .balign 4
321 0:
322 pushl %ecx
323 .balign 4
324 1:
325 shrl %ecx
326 rep; stosl
327 jnc 2f
328 stosw
329 .balign 4
330 2:
331 popl %ecx
332 addl %esi, %edi
333 decl %edx
334 jnz 0b
335 popl %edi
336 popl %esi
337 ret
338
339 /* Desc: void v_rect24 (int color);
340 *
341 * In : color
342 * Out : -
343 *
344 * Note: uses current draw buffer
345 */
346 .p2align 5,,31
347 .global _v_rect24
348 _v_rect24:
349 pushl %esi
350 pushl %edi
351 movl 28(%esp), %eax
352 movl _vl_current_width, %esi
353 movl 16(%esp), %edi
354 movl 20(%esp), %ecx
355 imull %esi, %edi
356 movl 24(%esp), %edx
357 subl %ecx, %esi
358 addl 12(%esp), %edi
359 leal (%esi, %esi, 2), %esi
360 pushl %ebx
361 leal (%edi, %edi, 2), %edi
362 movl %eax, %ebx
363 addl _vl_current_draw_buffer, %edi
364 shrl $16, %ebx
365 .balign 4
366 0:
367 pushl %ecx
368 .balign 4
369 1:
370 movw %ax, (%edi)
371 movb %bl, 2(%edi)
372 addl $3, %edi
373 decl %ecx
374 jnz 1b
375 popl %ecx
376 addl %esi, %edi
377 decl %edx
378 jnz 0b
379 popl %ebx
380 popl %edi
381 popl %esi
382 ret
383
384 /* Desc: void v_rect32 (int color);
385 *
386 * In : color
387 * Out : -
388 *
389 * Note: uses current draw buffer
390 */
391 .p2align 5,,31
392 .global _v_rect32
393 _v_rect32:
394 pushl %esi
395 pushl %edi
396 movl _vl_current_width, %esi
397 movl 16(%esp), %edi
398 movl 20(%esp), %ecx
399 imull %esi, %edi
400 movl 24(%esp), %edx
401 subl %ecx, %esi
402 addl 12(%esp), %edi
403 shll $2, %esi
404 shll $2, %edi
405 movl 28(%esp), %eax
406 addl _vl_current_draw_buffer, %edi
407 .balign 4
408 0:
409 pushl %ecx
410 .balign 4
411 1:
412 movl %eax, (%edi)
413 addl $4, %edi
414 decl %ecx
415 jnz 1b
416 popl %ecx
417 addl %esi, %edi
418 decl %edx
419 jnz 0b
420 popl %edi
421 popl %esi
422 ret
423
424 /* Desc: void v_putpixel8 (unsigned int offset, int color);
425 *
426 * In : offset within buffer, color
427 * Out : -
428 *
429 * Note: uses current draw buffer
430 */
431 .p2align 5,,31
432 .global _v_putpixel8
433 _v_putpixel8:
434 movl 8(%esp), %ecx
435 movl 4(%esp), %edx
436 movl _vl_current_draw_buffer, %eax
437 movb %cl, (%eax,%edx)
438 ret
439
440 /* Desc: void v_putpixel16 (unsigned int offset, int color);
441 *
442 * In : offset within buffer, color
443 * Out : -
444 *
445 * Note: uses current draw buffer
446 */
447 .p2align 5,,31
448 .global _v_putpixel16
449 _v_putpixel16:
450 movl 8(%esp), %ecx
451 movl 4(%esp), %edx
452 movl _vl_current_draw_buffer, %eax
453 movw %cx, (%eax,%edx,2)
454 ret
455
456 /* Desc: void v_putpixel24 (unsigned int offset, int color);
457 *
458 * In : offset within buffer, color
459 * Out : -
460 *
461 * Note: uses current draw buffer
462 */
463 .p2align 5,,31
464 .global _v_putpixel24
465 _v_putpixel24:
466 movl 4(%esp), %eax
467 movl 8(%esp), %edx
468 movl _vl_current_draw_buffer, %ecx
469 leal (%eax,%eax,2), %eax
470 movw %dx, (%ecx,%eax)
471 shrl $16, %edx
472 movb %dl, 2(%ecx,%eax)
473 ret
474
475 /* Desc: void v_putpixel32 (unsigned int offset, int color);
476 *
477 * In : offset within buffer, color
478 * Out : -
479 *
480 * Note: uses current draw buffer
481 */
482 .p2align 5,,31
483 .global _v_putpixel32
484 _v_putpixel32:
485 movl 8(%esp), %ecx
486 movl 4(%esp), %edx
487 movl _vl_current_draw_buffer, %eax
488 movl %ecx, (%eax,%edx,4)
489 ret