// Use only C-functions!!!!!
// tpoly1.c
for( ; ylen--; y++)
{
	RGBA *_screen;
	RGBA *w_texture = (RGBA *) texture;
	RGBA p;
	WORD ofs;

#if defined(ZBUFFER)
	int *_zbuffer;
#endif
	if( x1 < x2)
	{
		x = (x1 >> 16), xf = (x2 >> 16);
		tx = (tx1 >> 16), txf = (tx2 >> 16);
		ty = (ty1 >> 16), tyf = (ty2 >> 16);
#if defined(ZBUFFER)
		z = z1, zf = z2;
#endif
#if defined(GOURADE)
		l = l1, lf = l2;
#endif
	}
	else
	{
		x = (x2 >> 16), xf = (x1 >> 16);
		tx = (tx2 >> 16), txf = (tx1 >> 16);
		ty = (ty2 >> 16), tyf = (ty1 >> 16);
#if defined(ZBUFFER)
		z = z2, zf = z1;
#endif
#if defined(GOURADE)
		l = l2, lf = l1;
#endif
	}

	xlen = (x2 >> 16) - (x1 >> 16);
	if( xlen)
	{
		txadd = (tx2 - tx1) / xlen;
		tyadd = (ty2 - ty1) / xlen;
#if defined(ZBUFFER)
		zadd = (z2 - z1) / xlen;
#endif
#if defined(GOURADE)
		ladd = (l2 - l1) / xlen;
#endif
	}
	else
	{
		txadd = 0;
		tyadd = 0;
#if defined(ZBUFFER)
		zadd = 0;
#endif
#if defined(GOURADE)
		ladd = 0;
#endif
	}
	xlen = abs(xlen);


	//  Xclip...
	if( x < buff->minx)
	{
		tx += txadd * (buff->minx - x);
		ty += tyadd * (buff->minx - x);
#if defined(ZBUFFER)
		z += zadd * (buff->minx - x);
#endif
#if defined(GOURADE)
		l += ladd * (buff->minx - x);
#endif
		xlen -= buff->minx - x, x = buff->minx;
	}
	if( (x + xlen) > buff->maxx)
		xlen -= (x + xlen) - buff->maxx;

	// Kompensation f”r avrundning...
	tx += (txadd * yc) >> 16;
	ty += (tyadd * yc) >> 16;
#if defined(ZBUFFER)
	z += (zadd * yc) >> 16;
#endif
#if defined(GOURADE)
	l += (ladd * yc) >> 16;
#endif


	if( xlen > 0)
	{
		_screen = screen + x;
#if defined(ZBUFFER)
		_zbuffer = zbuffer + x;
#endif
//------------------------------------
// Do one scanline...
//------------------------------------
		for( ; xlen--; x++)
		{
#if defined(ZBUFFER)
      if( z < *_zbuffer)
			{
				*_zbuffer = z;
#endif
#if defined(GOURADE)
				//p = w_texture [(tx>>16) &~0x00ff + (ty>>8) & ~0xff00];
				//*_screen = p; //lighttab[p + ((l >> 8) & ~0xff)];
#else
				ofs = (tx>>16 & 0xff);
				ofs |= (ty>>8 & 0xff00);
				p = w_texture[ofs]; //;w_texture [((tx>>16) &~0x00ff) | ((ty>>8) & ~0xff00)];
				*_screen = p; // w_texture [(tx>>16) &~0x00ff + (ty>>8) & ~0xff00];
#endif

#if defined(ZBUFFER)
			}
			z += zadd;
			_zbuffer++;
#endif

#if defined(GOURADE)
			l += ladd;
#endif
			_screen+=1;
			tx += txadd;
			ty += tyadd;
		}
		if( x < xf)
		{
#if defined(ZBUFFER)
			if( zf > *_zbuffer)
			{
				*_zbuffer = zf;
#endif
#if defined(GOURADE)
				p = w_texture [(tx>>16) &~0x00ff + (ty>>8) & ~0xff00];
				*_screen = p; //lighttab[p + ((l >> 8) & ~0xff)];
#else
				*_screen = w_texture [(tx>>16) &~0x00ff + (ty>>8) & ~0xff00];
#endif
#if defined(ZBUFFER)
			}
#endif
		}
	}
	x1 += x1add, x2 += x2add;
	tx1 += tx1add, tx2 += tx2add;
	ty1 += ty1add;
	ty2 += ty2add;
#if defined(ZBUFFER)
	z1 += z1add, z2 += z2add;
	zbuffer += buff->width;
#endif
#if defined(GOURADE)
	l1 += l1add, l2 += l2add;
#endif
	screen += buff->width;
}
