updates from Daniel Borca
[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.1 for Mesa 4.0
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 word32 vl_hw_granularity;
38 * extern int vl_video_selector;
39 * extern int vl_current_offset, vl_current_delta;
40 */
41
42 .text
43
44 /*
45 * void v_clear16 (void *buffer, int bytes, int color);
46 */
47 .balign 4
48 .global _v_clear16
49 _v_clear16:
50 movl 12(%esp), %eax
51 pushw %ax
52 pushw %ax
53 popl %eax
54 jmp _v_clear_common
55
56 /*
57 * void v_clear32 (void *buffer, int bytes, int color);
58 */
59 .balign 4
60 .global _v_clear32
61 _v_clear32:
62 movl 12(%esp), %eax
63 .balign 4
64 _v_clear_common:
65 movl 8(%esp), %ecx
66 movl 4(%esp), %edx
67 shrl $2, %ecx
68 0:
69 .balign 4
70 movl %eax, (%edx)
71 addl $4, %edx
72 decl %ecx
73 jnz 0b
74 ret
75
76 /*
77 * void v_clear24 (void *buffer, int bytes, int color);
78 */
79 .balign 4
80 .global _v_clear24
81 _v_clear24:
82 movl 8(%esp), %edx
83 movl $0xaaaaaaab, %eax
84 mull %edx
85 movl 12(%esp), %eax
86 movl %edx, %ecx
87 movl 4(%esp), %edx
88 pushl %ebx
89 shrl %ecx
90 movb 18(%esp), %bl
91 .balign 4
92 0:
93 movw %ax, (%edx)
94 movb %bl, 2(%edx)
95 addl $3, %edx
96 decl %ecx
97 jnz 0b
98 popl %ebx
99 ret
100
101 /*
102 * void b_dump_virtual (void *buffer, int stride, int height);
103 */
104 .balign 4
105 .global _b_dump_virtual
106 _b_dump_virtual:
107 pushl %ebx
108 pushl %esi
109 pushl %edi
110 pushl %ebp
111 movl _vl_video_selector, %fs
112 movl 4*4+4+0(%esp), %esi
113 movl _vl_hw_granularity, %ebp
114 xorl %edx, %edx
115 movl _vl_current_offset, %eax
116 divl %ebp
117 movl %edx, %edi
118 pushl %eax
119 movl %eax, %edx
120 xorl %ebx, %ebx
121 movw $0x4f05, %ax
122 int $0x10
123 movl _vl_current_delta, %ebx
124 movl 5*4+4+4(%esp), %ecx
125 movl 5*4+4+8(%esp), %edx
126 shrl $2, %ecx
127 .balign 4
128 0:
129 pushl %ecx
130 .balign 4
131 1:
132 cmpl %ebp, %edi
133 jb 2f
134 pushl %ebx
135 pushl %edx
136 incl 12(%esp)
137 movw $0x4f05, %ax
138 movl 12(%esp), %edx
139 xorl %ebx, %ebx
140 int $0x10
141 popl %edx
142 popl %ebx
143 subl %ebp, %edi
144 2:
145 movl (%esi), %eax
146 addl $4, %esi
147 movl %eax, %fs:(%edi)
148 addl $4, %edi
149 decl %ecx
150 jnz 1b
151 popl %ecx
152 addl %ebx, %edi
153 decl %edx
154 jnz 0b
155 popl %eax
156 popl %ebp
157 popl %edi
158 popl %esi
159 popl %ebx
160 ret
161
162 /*
163 * void l_dump_virtual (void *buffer, int stride, int height);
164 */
165 .balign 4
166 .global _l_dump_virtual
167 _l_dump_virtual:
168 pushl %ebx
169 pushl %esi
170 pushl %edi
171 movl _vl_video_selector, %fs
172 movl 3*4+4+0(%esp), %esi
173 movl _vl_current_offset, %edi
174 movl 3*4+4+4(%esp), %ecx
175 movl 3*4+4+8(%esp), %edx
176 movl _vl_current_delta, %ebx
177 shrl $2, %ecx
178 .balign 4
179 0:
180 pushl %ecx
181 .balign 4
182 1:
183 movl (%esi), %eax
184 addl $4, %esi
185 movl %eax, %fs:(%edi)
186 addl $4, %edi
187 decl %ecx
188 jnz 1b
189 popl %ecx
190 addl %ebx, %edi
191 decl %edx
192 jnz 0b
193 popl %edi
194 popl %esi
195 popl %ebx
196 ret
197
198 /*
199 * void v_putpixel16 (void *buffer, int offset, int color);
200 */
201 .balign 4
202 .global _v_putpixel16
203 _v_putpixel16:
204 movl 8(%esp), %edx
205 shll %edx
206 movl 12(%esp), %eax
207 addl 4(%esp), %edx
208 movw %ax, (%edx)
209 ret
210
211 /*
212 * void v_putpixel24 (void *buffer, int offset, int color);
213 */
214 .balign 4
215 .global _v_putpixel24
216 _v_putpixel24:
217 movl 8(%esp), %edx
218 leal (%edx, %edx, 2), %edx
219 movl 12(%esp), %eax
220 addl 4(%esp), %edx
221 movw %ax, (%edx)
222 shrl $16, %eax
223 movb %al, 2(%edx)
224 ret
225
226 /*
227 * void v_putpixel32 (void *buffer, int offset, int color);
228 */
229 .balign 4
230 .global _v_putpixel32
231 _v_putpixel32:
232 movl 8(%esp), %edx
233 shll $2, %edx
234 movl 12(%esp), %eax
235 addl 4(%esp), %edx
236 movl %eax, (%edx)
237 ret