1 /* $Id: 2dsline.c,v 1.5 2002-07-17 21:10:38 bradleyb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
31 int Gr_scanline_darkening_level = GR_FADE_LEVELS;
35 void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table );
36 # pragma aux gr_linear_darken parm [edi] [eax] [ecx] [edx] modify exact [eax ebx ecx edx edi] = \
39 "gld_loop: mov bl, [edi] " \
40 " mov al, [ebx+edx] " \
46 # elif defined __GNUC__
47 static inline void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table ) {
49 __asm__ __volatile__ (
52 "0: movb (%%edi), %%bl;"
53 " movb (%%ebx, %%edx), %%al;"
54 " movb %%al, (%%edi);"
58 : "=D" (dummy[0]), "=a" (dummy[1]), "=c" (dummy[2]), "=d" (dummy[3])
59 : "0" (dest), "1" (darkening_level), "2" (count), "3" (fade_table)
62 # elif defined _MSC_VER
63 __inline void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table )
67 mov eax,[darkening_level]
82 // Unknown compiler. So we use C rather than inline assembler.
83 # define USE_C_GR_LINEAR_DARKEN 1
86 #else // No Assembler. So we use C.
87 # define USE_C_GR_LINEAR_DARKEN 1
88 void gr_linear_stosd( ubyte * dest, unsigned char color, unsigned int nbytes) {
89 memset(dest,color,nbytes);
93 #ifdef USE_C_GR_LINEAR_DARKEN
94 void gr_linear_darken(ubyte * dest, int darkening_level, int count, ubyte * fade_table) {
98 *dest=fade_table[(*dest++)+(darkening_level*256)];
102 void gr_uscanline( int x1, int x2, int y )
104 if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) {
110 gr_linear_stosd( DATA + ROWSIZE*y + x1, (unsigned char)COLOR, x2-x1+1);
114 gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
117 gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
127 gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table);
131 gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
134 gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
141 void gr_scanline( int x1, int x2, int y )
143 if ((y<0)||(y>MAXY)) return;
145 if (x2 < x1 ) x2 ^= x1 ^= x2;
147 if (x1 > MAXX) return;
148 if (x2 < MINX) return;
150 if (x1 < MINX) x1 = MINX;
151 if (x2 > MAXX) x2 = MAXX;
153 if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) {
159 gr_linear_stosd( DATA + ROWSIZE*y + x1, (unsigned char)COLOR, x2-x1+1);
163 gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
166 gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
176 gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table);
180 gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
183 gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );