6 extern unsigned int gr_var_color;
7 extern unsigned int gr_var_bwidth;
8 extern unsigned char * gr_var_bitmap;
10 void gr_linear_stosd( void * source, unsigned char color, unsigned int nbytes);
11 void gr_linear_line( int x0, int y0, int x1, int y1);
12 void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
14 // This code aligns edi so that the destination is aligned to a dword boundry before rep movsd
15 void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels );
16 #pragma aux gr_linear_movsd parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] = \
34 void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels );
35 #pragma aux gr_linear_rep_movsdm parm [esi] [edi] [ecx] modify exact [ecx esi edi eax] = \
47 void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value );
48 #pragma aux gr_linear_rep_movsdm_faded parm [esi] [edi] [ecx] [ebx] modify exact [ecx esi edi eax ebx] = \
56 "movb al, gr_fade_table[eax]" \
64 void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, int num_dest_pixels );
65 #pragma aux gr_linear_rep_movsd_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] = \
87 void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize );
88 #pragma aux modex_copy_column parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = \
97 void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize );
98 #pragma aux modex_copy_column_m parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = \
110 void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels );
111 #pragma aux modex_copy_scanline parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = \
118 " mov al, [esi+8] " \
119 " mov ah, [esi+12] " \
122 " mov ah, [esi+4] " \
127 " jne next4pixels " \
140 void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels );
141 #pragma aux modex_copy_scanline_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = \
148 " mov al, [esi+4] " \
149 " mov ah, [esi+6] " \
152 " mov ah, [esi+2] " \
157 " jne next4pixels " \
170 #elif defined __GNUC__
171 // This code aligns edi so that the destination is aligned to a dword boundry before rep movsd
172 inline void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels ) {
174 __asm__ __volatile__ (
176 " movl %%ecx, %%ebx;"
177 " movl %%edi, %%eax;"
185 " movl %%ebx, %%ecx;"
188 " movl %%ebx, %%ecx;"
191 : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2])
192 : "0" (src), "1" (dest), "2" (num_pixels)
196 static inline void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels ) {
198 __asm__ __volatile__ (
200 " movb (%%esi), %%al;"
204 " movb %%al,(%%edi);"
209 : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2])
210 : "0" (src), "1" (dest), "2" (num_pixels)
214 /* #pragma aux gr_linear_rep_movsdm_faded parm [esi] [edi] [ecx] [ebx] modify exact [ecx esi edi eax ebx] */
215 static inline void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value ) {
217 __asm__ __volatile__ (
218 " xorl %%eax, %%eax;"
221 " movb (%%esi), %%al;"
226 " movb gr_fade_table(%%eax), %%al;"
228 " movb _gr_fade_table(%%eax), %%al;"
230 " movb %%al, (%%edi);"
235 : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2]), "=b" (dummy[3])
236 : "0" (src), "1" (dest), "2" (num_pixels), "3" (fade_value)
240 inline void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, unsigned int num_dest_pixels ) {
241 /* #pragma aux gr_linear_rep_movsd_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] */
243 __asm__ __volatile__ (
246 "movb (%%esi), %%al;"
247 "movb %%al, (%%edi);"
253 "movb (%%esi), %%al;"
255 "movw %%ax, (%%edi);"
262 : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2])
263 : "0" (src), "1" (dest), "2" (num_dest_pixels)
267 static inline void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) {
268 /*#pragma aux modex_copy_column parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = */
269 __asm__ __volatile__ (
271 "movb (%%esi), %%al;"
273 "movb %%al, (%%edi);"
277 : : "S" (src), "D" (dest), "c" (num_pixels), "b" (src_rowsize), "d" (dest_rowsize)
278 : "%eax", "%ecx", "%esi", "%edi");
281 static inline void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) {
282 /* #pragma aux modex_copy_column_m parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = */
283 __asm__ __volatile__ (
285 "movb (%%esi), %%al;"
289 "movb %%al, (%%edi);"
294 : "=c" (num_pixels), "=S" (src), "=D" (dest) : "S" (src), "D" (dest), "c" (num_pixels), "b" (src_rowsize), "d" (dest_rowsize)
298 static inline void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels ) {
299 /* #pragma aux modex_copy_scanline parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] */
300 __asm__ __volatile__ (
301 " movl %%ecx, %%ebx;"
307 " movb 8(%%esi), %%al;"
308 " movb 12(%%esi), %%ah;"
310 " movb (%%esi), %%al;"
311 " movb 4(%%esi), %%ah;"
312 " movl %%eax, (%%edi);"
321 " movb (%%esi), %%al;"
323 " movb %%al, (%%edi);"
328 : "=c" (npixels), "=S" (src), "=D" (dest): "S" (src), "D" (dest), "c" (npixels)
329 : "%eax", "%ebx", "%edx");
332 static inline void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels ) {
333 /* #pragma aux modex_copy_scanline_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = */
334 __asm__ __volatile__ (
335 " movl %%ecx, %%ebx;"
341 " movb 4(%%esi), %%al;"
342 " movb 6(%%esi), %%ah;"
344 " movb (%%esi), %%al;"
345 " movb 2(%%esi), %%ah;"
346 " movl %%eax, (%%edi);"
355 " movb (%%esi),%%al;"
357 " movb %%al, (%%edi);"
362 : "=c" (npixels), "=S" (src), "=D" (dest): "S" (src), "D" (dest), "c" (npixels)
363 : "%eax", "%ebx", "%edx");
365 #elif defined _MSC_VER
367 extern unsigned int gr_var_color;
368 extern unsigned int gr_var_bwidth;
369 extern unsigned char * gr_var_bitmap;
371 void gr_linear_stosd( ubyte * source, unsigned char color, unsigned int nbytes);
372 void gr_linear_line( int x0, int y0, int x1, int y1);
373 void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
375 // This code aligns edi so that the destination is aligned to a dword boundry before rep movsd
376 __inline void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels )
381 mov ecx, [num_pixels]
401 __inline void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels )
407 mov ecx, [num_pixels]
420 __inline void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value )
425 mov ecx, [num_pixels]
426 movzx ebx, byte ptr [fade_value]
434 mov al, gr_fade_table[eax]
443 __inline void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, uint num_dest_pixels )
448 mov ecx, [num_dest_pixels]
471 #define NO_ASM 1 // We really do want no assembler...