summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dos/virtual.S
blob: 3633161c982a87780fae971f80acb705cfd939c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
 * Mesa 3-D graphics library
 * Version:  4.0
 * 
 * Copyright (C) 1999  Brian Paul   All Rights Reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/*
 * DOS/DJGPP device driver v1.1 for Mesa 4.0
 *
 *  Copyright (C) 2002 - Borca Daniel
 *  Email : dborca@yahoo.com
 *  Web   : http://www.geocities.com/dborca
 */


		.file	"virtual.S"

/*
 * extern word32 vl_hw_granularity;
 * extern int vl_video_selector;
 * extern int vl_current_offset, vl_current_delta;
 */

		.text

/*
 * void v_clear16 (void *buffer, int bytes, int color);
 */
		.balign	4
		.global	_v_clear16
_v_clear16:
		movl	12(%esp), %eax
		pushw	%ax
		pushw	%ax
		popl	%eax
		jmp	_v_clear_common

/*
 * void v_clear32 (void *buffer, int bytes, int color);
 */
		.balign	4
		.global	_v_clear32
_v_clear32:
		movl	12(%esp), %eax
		.balign	4
_v_clear_common:
		movl	8(%esp), %ecx
		movl	4(%esp), %edx
		shrl	$2, %ecx
	0:
		.balign	4
		movl	%eax, (%edx)
		addl	$4, %edx
		decl	%ecx
		jnz	0b
		ret

/*
 * void v_clear24 (void *buffer, int bytes, int color);
 */
		.balign	4
		.global	_v_clear24
_v_clear24:
		movl	8(%esp), %edx
		movl	$0xaaaaaaab, %eax
		mull	%edx
		movl	12(%esp), %eax
		movl	%edx, %ecx
		movl	4(%esp), %edx
		pushl	%ebx
		shrl	%ecx
		movb	18(%esp), %bl
		.balign	4
	0:
		movw	%ax, (%edx)
		movb	%bl, 2(%edx)
		addl	$3, %edx
		decl	%ecx
		jnz	0b
		popl	%ebx
		ret

/*
 * void b_dump_virtual (void *buffer, int stride, int height);
 */
		.balign	4
		.global	_b_dump_virtual
_b_dump_virtual:
		pushl	%ebx
		pushl	%esi
		pushl	%edi
		pushl	%ebp
		movl	_vl_video_selector, %fs
		movl	4*4+4+0(%esp), %esi
		movl	_vl_hw_granularity, %ebp
		xorl	%edx, %edx
		movl	_vl_current_offset, %eax
		divl	%ebp
		movl	%edx, %edi
		pushl	%eax
		movl	%eax, %edx
		xorl	%ebx, %ebx
		movw	$0x4f05, %ax
		int	$0x10
		movl	_vl_current_delta, %ebx
		movl	5*4+4+4(%esp), %ecx
		movl	5*4+4+8(%esp), %edx
		shrl	$2, %ecx
		.balign	4
	0:
		pushl	%ecx
		.balign	4
	1:
		cmpl	%ebp, %edi
		jb	2f
		pushl	%ebx
		pushl	%edx
		incl	12(%esp)
		movw	$0x4f05, %ax
		movl	12(%esp), %edx
		xorl	%ebx, %ebx
		int	$0x10
		popl	%edx
		popl	%ebx
		subl	%ebp, %edi
	2:
		movl	(%esi), %eax
		addl	$4, %esi
		movl	%eax, %fs:(%edi)
		addl	$4, %edi
		decl	%ecx
		jnz	1b
		popl	%ecx
		addl	%ebx, %edi
		decl	%edx
		jnz	0b
		popl	%eax
		popl	%ebp
		popl	%edi
		popl	%esi
		popl	%ebx
		ret

/*
 * void l_dump_virtual (void *buffer, int stride, int height);
 */
		.balign	4
		.global	_l_dump_virtual
_l_dump_virtual:
		pushl	%ebx
		pushl	%esi
		pushl	%edi
		movl	_vl_video_selector, %fs
		movl	3*4+4+0(%esp), %esi
		movl	_vl_current_offset, %edi
		movl	3*4+4+4(%esp), %ecx
		movl	3*4+4+8(%esp), %edx
		movl	_vl_current_delta, %ebx
		shrl	$2, %ecx
		.balign	4
	0:
		pushl	%ecx
		.balign	4
	1:
		movl	(%esi), %eax
		addl	$4, %esi
		movl	%eax, %fs:(%edi)
		addl	$4, %edi
		decl	%ecx
		jnz	1b
		popl	%ecx
		addl	%ebx, %edi
		decl	%edx
		jnz	0b
		popl	%edi
		popl	%esi
		popl	%ebx
		ret

/*
 * void v_putpixel16 (void *buffer, int offset, int color);
 */
		.balign	4
		.global	_v_putpixel16
_v_putpixel16:
		movl	8(%esp), %edx
		shll	%edx
		movl	12(%esp), %eax
		addl	4(%esp), %edx
		movw	%ax, (%edx)
		ret

/*
 * void v_putpixel24 (void *buffer, int offset, int color);
 */
		.balign	4
		.global	_v_putpixel24
_v_putpixel24:
		movl	8(%esp), %edx
		leal	(%edx, %edx, 2), %edx
		movl	12(%esp), %eax
		addl	4(%esp), %edx
		movw	%ax, (%edx)
		shrl	$16, %eax
		movb	%al, 2(%edx)
		ret

/*
 * void v_putpixel32 (void *buffer, int offset, int color);
 */
		.balign	4
		.global	_v_putpixel32
_v_putpixel32:
		movl	8(%esp), %edx
		shll	$2, %edx
		movl	12(%esp), %eax
		addl	4(%esp), %edx
		movl	%eax, (%edx)
		ret