2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
15 * $Source: /cvs/cvsroot/d2x/2d/2dsline.c,v $
18 * $Date: 2001-10-18 22:45:58 $
20 * FIXME: add description
22 * $Log: not supported by cvs2svn $
42 int Gr_scanline_darkening_level = GR_FADE_LEVELS;
46 void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table );
47 # pragma aux gr_linear_darken parm [edi] [eax] [ecx] [edx] modify exact [eax ebx ecx edx edi] = \
50 "gld_loop: mov bl, [edi] " \
51 " mov al, [ebx+edx] " \
57 # elif defined __GNUC__
58 static inline void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table ) {
60 __asm__ __volatile__ (
63 "0: movb (%%edi), %%bl;"
64 " movb (%%ebx, %%edx), %%al;"
65 " movb %%al, (%%edi);"
69 : "=D" (dummy[0]), "=a" (dummy[1]), "=c" (dummy[2]), "=d" (dummy[3])
70 : "0" (dest), "1" (darkening_level), "2" (count), "3" (fade_table)
73 # elif defined _MSC_VER
74 __inline void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table )
78 mov eax,[darkening_level]
93 // Unknown compiler. So we use C rather than inline assembler.
94 # define USE_C_GR_LINEAR_DARKEN 1
97 #else // No Assembler. So we use C.
98 # define USE_C_GR_LINEAR_DARKEN 1
99 void gr_linear_stosd( ubyte * dest, unsigned char color, unsigned int nbytes) {
100 memset(dest,color,nbytes);
104 #ifdef USE_C_GR_LINEAR_DARKEN
105 void gr_linear_darken(ubyte * dest, int darkening_level, int count, ubyte * fade_table) {
108 for (i=0;i<count;i++)
109 *dest=fade_table[(*dest++)+(darkening_level*256)];
113 void gr_uscanline( int x1, int x2, int y )
115 if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) {
121 gr_linear_stosd( DATA + ROWSIZE*y + x1, (unsigned char)COLOR, x2-x1+1);
125 gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
128 gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
138 gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table);
142 gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
145 gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
152 void gr_scanline( int x1, int x2, int y )
154 if ((y<0)||(y>MAXY)) return;
156 if (x2 < x1 ) x2 ^= x1 ^= x2;
158 if (x1 > MAXX) return;
159 if (x2 < MINX) return;
161 if (x1 < MINX) x1 = MINX;
162 if (x2 > MAXX) x2 = MAXX;
164 if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) {
170 gr_linear_stosd( DATA + ROWSIZE*y + x1, (unsigned char)COLOR, x2-x1+1);
174 gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
177 gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
187 gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table);
191 gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
194 gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );