1 /* $Id: linear.h,v 1.4 2002-07-17 21:55:19 bradleyb Exp $ */
7 extern unsigned int gr_var_color;
8 extern unsigned int gr_var_bwidth;
9 extern unsigned char * gr_var_bitmap;
11 void gr_linear_stosd( void * source, unsigned char color, unsigned int nbytes);
12 void gr_linear_line( int x0, int y0, int x1, int y1);
13 void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
15 // This code aligns edi so that the destination is aligned to a dword boundry before rep movsd
16 void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels );
17 #pragma aux gr_linear_movsd parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] = \
35 void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels );
36 #pragma aux gr_linear_rep_movsdm parm [esi] [edi] [ecx] modify exact [ecx esi edi eax] = \
48 void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value );
49 #pragma aux gr_linear_rep_movsdm_faded parm [esi] [edi] [ecx] [ebx] modify exact [ecx esi edi eax ebx] = \
57 "movb al, gr_fade_table[eax]" \
65 void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, int num_dest_pixels );
66 #pragma aux gr_linear_rep_movsd_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] = \
88 void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize );
89 #pragma aux modex_copy_column parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = \
98 void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize );
99 #pragma aux modex_copy_column_m parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = \
111 void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels );
112 #pragma aux modex_copy_scanline parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = \
119 " mov al, [esi+8] " \
120 " mov ah, [esi+12] " \
123 " mov ah, [esi+4] " \
128 " jne next4pixels " \
141 void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels );
142 #pragma aux modex_copy_scanline_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = \
149 " mov al, [esi+4] " \
150 " mov ah, [esi+6] " \
153 " mov ah, [esi+2] " \
158 " jne next4pixels " \
171 #elif defined __GNUC__
172 // This code aligns edi so that the destination is aligned to a dword boundry before rep movsd
173 inline void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels ) {
175 __asm__ __volatile__ (
177 " movl %%ecx, %%ebx;"
178 " movl %%edi, %%eax;"
186 " movl %%ebx, %%ecx;"
189 " movl %%ebx, %%ecx;"
192 : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2])
193 : "0" (src), "1" (dest), "2" (num_pixels)
197 static inline void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels ) {
199 __asm__ __volatile__ (
201 " movb (%%esi), %%al;"
205 " movb %%al,(%%edi);"
210 : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2])
211 : "0" (src), "1" (dest), "2" (num_pixels)
215 /* #pragma aux gr_linear_rep_movsdm_faded parm [esi] [edi] [ecx] [ebx] modify exact [ecx esi edi eax ebx] */
216 static inline void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value ) {
218 __asm__ __volatile__ (
219 " xorl %%eax, %%eax;"
222 " movb (%%esi), %%al;"
227 " movb gr_fade_table(%%eax), %%al;"
229 " movb _gr_fade_table(%%eax), %%al;"
231 " movb %%al, (%%edi);"
236 : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2]), "=b" (dummy[3])
237 : "0" (src), "1" (dest), "2" (num_pixels), "3" (fade_value)
241 inline void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, unsigned int num_dest_pixels ) {
242 /* #pragma aux gr_linear_rep_movsd_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] */
244 __asm__ __volatile__ (
247 "movb (%%esi), %%al;"
248 "movb %%al, (%%edi);"
254 "movb (%%esi), %%al;"
256 "movw %%ax, (%%edi);"
263 : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2])
264 : "0" (src), "1" (dest), "2" (num_dest_pixels)
268 static inline void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) {
269 /*#pragma aux modex_copy_column parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = */
270 __asm__ __volatile__ (
272 "movb (%%esi), %%al;"
274 "movb %%al, (%%edi);"
278 : : "S" (src), "D" (dest), "c" (num_pixels), "b" (src_rowsize), "d" (dest_rowsize)
279 : "%eax", "%ecx", "%esi", "%edi");
282 static inline void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) {
283 /* #pragma aux modex_copy_column_m parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = */
285 __asm__ __volatile__ (
287 "movb (%%esi), %%al;"
291 "movb %%al, (%%edi);"
296 : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2])
297 : "1" (src), "2" (dest), "0" (num_pixels), "b" (src_rowsize), "d" (dest_rowsize)
301 static inline void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels ) {
302 /* #pragma aux modex_copy_scanline parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] */
304 __asm__ __volatile__ (
305 " movl %%ecx, %%ebx;"
311 " movb 8(%%esi), %%al;"
312 " movb 12(%%esi), %%ah;"
314 " movb (%%esi), %%al;"
315 " movb 4(%%esi), %%ah;"
316 " movl %%eax, (%%edi);"
325 " movb (%%esi), %%al;"
327 " movb %%al, (%%edi);"
332 : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2])
333 : "1" (src), "2" (dest), "0" (npixels)
334 : "%eax", "%ebx", "%edx" );
337 static inline void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels ) {
338 /* #pragma aux modex_copy_scanline_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = */
340 __asm__ __volatile__ (
341 " movl %%ecx, %%ebx;"
347 " movb 4(%%esi), %%al;"
348 " movb 6(%%esi), %%ah;"
350 " movb (%%esi), %%al;"
351 " movb 2(%%esi), %%ah;"
352 " movl %%eax, (%%edi);"
361 " movb (%%esi),%%al;"
363 " movb %%al, (%%edi);"
368 : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2])
369 : "1" (src), "2" (dest), "0" (npixels)
370 : "%eax", "%ebx", "%edx" );
372 #elif defined _MSC_VER
374 extern unsigned int gr_var_color;
375 extern unsigned int gr_var_bwidth;
376 extern unsigned char * gr_var_bitmap;
378 void gr_linear_stosd( ubyte * source, unsigned char color, unsigned int nbytes);
379 void gr_linear_line( int x0, int y0, int x1, int y1);
380 void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
382 // This code aligns edi so that the destination is aligned to a dword boundry before rep movsd
383 __inline void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels )
388 mov ecx, [num_pixels]
408 __inline void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels )
414 mov ecx, [num_pixels]
427 __inline void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value )
432 mov ecx, [num_pixels]
433 movzx ebx, byte ptr [fade_value]
441 mov al, gr_fade_table[eax]
450 __inline void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, uint num_dest_pixels )
455 mov ecx, [num_dest_pixels]
478 #define NO_ASM 1 // We really do want no assembler...