diff -r d252d2dd3fe6 src/CMakeLists.txt
--- a/src/CMakeLists.txt	Sun Nov 15 19:01:04 2015 -0500
+++ b/src/CMakeLists.txt	Mon Nov 16 22:54:36 2015 -0500
@@ -274,6 +274,7 @@
 	wl_atmos.cpp
 	wl_cloudsky.cpp
 	wl_debug.cpp
+	wl_dir3dspr.cpp
 	wl_draw.cpp
 	wl_floorceiling.cpp
 	wl_game.cpp
diff -r d252d2dd3fe6 src/r_sprites.cpp
--- a/src/r_sprites.cpp	Sun Nov 15 19:01:04 2015 -0500
+++ b/src/r_sprites.cpp	Mon Nov 16 22:54:36 2015 -0500
@@ -439,7 +439,8 @@
 	}
 }
 
-void Scale3DSpriter(AActor *actor, int x1, int x2, const Frame *frame, fixed nx1, fixed nx2)
+#if 1
+void Scale3DSpriter(AActor *actor, int x1, int x2, const Frame *frame, fixed ny1, fixed ny2, fixed nx1, fixed nx2)
 {
 	if(actor->sprite == SPR_NONE || loadedSprites[actor->sprite].numFrames == 0)
 		return;
@@ -473,12 +474,9 @@
 	if(scale == 0 || -(viewheight/2 - viewshift - topoffset) >= scale)
 		return;
 
-	double dxScale = (height/256.0)*(FixedDiv(actor->scaleX, yaspect)/65536.);
 	double dyScale = (height/256.0)*(actor->scaleY/65536.);
 	int upperedge = static_cast<int>((viewheight/2 - viewshift - topoffset)+scale - tex->GetScaledTopOffsetDouble()*dyScale);
 	
-	fixed xStep = (tex->GetWidth()<<FRACBITS)/(x2-x1); // [XA] TODO xscale
-	//fixed xStep = static_cast<fixed>(tex->xScale/dxScale);
 	fixed yStep = static_cast<fixed>(tex->yScale/dyScale);
 	unsigned int startY = -MIN(upperedge, 0);
 	fixed endY = MIN<fixed>(tex->GetHeight()<<FRACBITS, yStep*(viewheight-upperedge));
@@ -500,12 +498,35 @@
 	fixed x, y;
 	unsigned screenSize = screenHeight * screenWidth;
 
-	for(i = x1, x = 0; i < x2; x += xStep, ++i)
+	printf("%f, %f, %f, %f\n", FIXED2FLOAT(ny1), FIXED2FLOAT(ny2), FIXED2FLOAT(nx1), FIXED2FLOAT(nx1));
+	fixed dxx=(ny2-ny1)<<8,dzz=(nx2-nx1)<<8;
+	fixed dxa = 0, dza = 0;
+	dxx>>=TEXTURESHIFT,dzz>>=TEXTURESHIFT;
+	dxa+=dxx,dza+=dzz;
+	int nexti = (int)((ny1+(dxa>>8))*::scale/(nx1+(dza>>8))+centerx);
+	src = tex->GetColumn(flip ? texWidth - 1 : 0, NULL);
+
+	for(i = x1, x = 0; i < x2; ++i)
 	{
+		while(i >= nexti)
+		{
+			++x;
+			src = tex->GetColumn(flip ? texWidth - x - 1 : x, NULL);
+
+			dxa += dxx;
+			dza += dzz;
+			nexti = (int)((ny1+(dxa>>8))*::scale/(nx1+(dza>>8))+centerx);
+		}
+
+		// linear interpolation oh no
+		height = (unsigned)(height1 + ((int)height2 - (int)height1) * ((double)(i+1 - x1) / (x2 - x1)));
+
+		// recalculation double oh no
+		scale = height>>3;
+		topoffset = (scale*(viewz-(32<<FRACBITS))/(32<<FRACBITS));
+
 		if(i < 0 || i > screenWidth || wallheight[i] > (signed)height || scale == 0 || -(viewheight/2 - viewshift - topoffset) >= scale)
 			continue;
-
-		src = tex->GetColumn(flip ? texWidth - (x>>FRACBITS) - 1 : (x>>FRACBITS), NULL);
 		
 		dest = vbuf + i + (upperedge > 0 ? vbufPitch*upperedge : 0);
 		for(y = startY*yStep;y < endY;y += yStep)
@@ -515,104 +536,335 @@
 			dest += vbufPitch;
 		}
 
-		// linear interpolation oh no
-		height = (unsigned)(height1 + ((int)height2 - (int)height1) * ((double)(i+1 - x1) / (x2 - x1)));
-
-		// recalculation double oh no
-		scale = height>>3;
-		topoffset = (scale*(viewz-(32<<FRACBITS))/(32<<FRACBITS));
-
-		//dxScale = (height/256.0)*(FixedDiv(actor->scaleX, yaspect)/65536.);
 		dyScale = (height/256.0)*(actor->scaleY/65536.);
 		upperedge = static_cast<int>((viewheight/2 - viewshift - topoffset)+scale - tex->GetScaledTopOffsetDouble()*dyScale);
 		
-		//xStep = static_cast<fixed>(tex->xScale/dxScale);
 		yStep = static_cast<fixed>(tex->yScale/dyScale);
 		startY = -MIN(upperedge, 0);
 		endY = MIN<fixed>(tex->GetHeight()<<FRACBITS, yStep*(viewheight-upperedge));
 	}
-}
-
-void Scale3DSprite(AActor *actor, const Frame *frame, unsigned height)
-{	
-	fixed nx1,nx2,ny1,ny2;
-	int viewx1,viewx2;
-	fixed diradd;
-	fixed playx = viewx;
-	fixed playy = viewy;
-	
-#define SIZEADD 1024
-
-	// [XA] For now, treat 0- and 180-degree angles as vertical sprites, all else as horizontal.
-	//      TODO support any angle
-	if(actor->angle == 0 || actor->angle == ANGLE_180) // vertical dir 3d sprite
-	{
-		fixed gy1,gy2,gx,gyt1,gyt2,gxt;
-
-		// translate point to view centered coordinates
-		gy1 = actor->y-playy-0x8000L-SIZEADD;
-		gy2 = gy1+0x10000L+2*SIZEADD;
-		gx = actor->x-playx;
-		
-		// calculate newx
-		gxt = FixedMul(gx,viewcos);
-		gyt1 = FixedMul(gy1,viewsin);
-		gyt2 = FixedMul(gy2,viewsin);
-		nx1 = gxt-gyt1;
-		nx2 = gxt-gyt2;
-		
-		// calculate newy
-		gxt = FixedMul(gx,viewsin);
-		gyt1 = FixedMul(gy1,viewcos);
-		gyt2 = FixedMul(gy2,viewcos);
-		ny1 = gyt1+gxt;
-		ny2 = gyt2+gxt;
-	}
-	else // horizontal dir 3d sprite
-	{
-		fixed gx1,gx2,gy,gxt1,gxt2,gyt;
-
-		// translate point to view centered coordinates
-		gx1 = actor->x-playx-0x8000L-SIZEADD;
-		gx2 = gx1+0x10000L+2*SIZEADD;
-		gy = actor->y-playy;
-		
-		// calculate newx
-		gxt1 = FixedMul(gx1,viewcos);
-		gxt2 = FixedMul(gx2,viewcos);
-		gyt = FixedMul(gy,viewsin);
-		nx1 = gxt1-gyt;
-		nx2 = gxt2-gyt;
-		
-		// calculate newy
-		gxt1 = FixedMul(gx1,viewsin);
-		gxt2 = FixedMul(gx2,viewsin);
-		gyt = FixedMul(gy,viewcos);
-		ny1 = gyt+gxt1;
-		ny2 = gyt+gxt2;
-	}
-	
-	if(nx1 < 0 || nx2 < 0) return; // TODO: Clip on viewplane
-	
-	// calculate perspective ratio
-	if(nx1>=0 && nx1<=1792) nx1=1792;
-	if(nx1<0 && nx1>=-1792) nx1=-1792;
-	if(nx2>=0 && nx2<=1792) nx2=1792;
-	if(nx2<0 && nx2>=-1792) nx2=-1792;
-	
-	viewx1=(int)(centerx+ny1*scale/nx1);
-	viewx2=(int)(centerx+ny2*scale/nx2);
-	
-	if(viewx2 < viewx1)
-	{
-		Scale3DSpriter(actor, viewx2, viewx1, frame, nx2, nx1);
-	}
-	else
-	{
-		Scale3DSpriter(actor, viewx1, viewx2, frame, nx1, nx2);
-	}
 }
 
+#if 1
+void Scale3DSprite(AActor *actor, const Frame *frame, unsigned height)
+{	
+	fixed nx1,nx2,ny1,ny2;
+	int viewx1,viewx2;
+	fixed diradd;
+	fixed playx = viewx;
+	fixed playy = viewy;
+
+
+	// [XA] For now, treat 0- and 180-degree angles as vertical sprites, all else as horizontal.
+	//      TODO support any angle
+	if(actor->angle == 0 || actor->angle == ANGLE_180) // vertical dir 3d sprite
+	{
+		fixed gy1,gy2,gx,gyt1,gyt2,gxt;
+
+		// translate point to view centered coordinates
+		gy1 = actor->y-playy-0x8000;
+		gy2 = gy1+0x10000L+2;
+		gx = actor->x-playx;
+		
+		// calculate newx
+		gxt = FixedMul(gx,viewcos);
+		gyt1 = FixedMul(gy1,viewsin);
+		gyt2 = FixedMul(gy2,viewsin);
+		nx1 = gxt-gyt1;
+		nx2 = gxt-gyt2;
+		
+		// calculate newy
+		gxt = FixedMul(gx,viewsin);
+		gyt1 = FixedMul(gy1,viewcos);
+		gyt2 = FixedMul(gy2,viewcos);
+		ny1 = gyt1+gxt;
+		ny2 = gyt2+gxt;
+	}
+	else // horizontal dir 3d sprite
+	{
+		fixed gx1,gx2,gy,gxt1,gxt2,gyt;
+
+		// translate point to view centered coordinates
+		gx1 = actor->x-playx-0x8000L;
+		gx2 = gx1+0x10000L+2;
+		gy = actor->y-playy;
+		
+		// calculate newx
+		gxt1 = FixedMul(gx1,viewcos);
+		gxt2 = FixedMul(gx2,viewcos);
+		gyt = FixedMul(gy,viewsin);
+		nx1 = gxt1-gyt;
+		nx2 = gxt2-gyt;
+		
+		// calculate newy
+		gxt1 = FixedMul(gx1,viewsin);
+		gxt2 = FixedMul(gx2,viewsin);
+		gyt = FixedMul(gy,viewcos);
+		ny1 = gyt+gxt1;
+		ny2 = gyt+gxt2;
+	}
+	
+	if(nx1 < 0 || nx2 < 0) return; // TODO: Clip on viewplane
+	
+	// calculate perspective ratio
+	if(nx1>=0 && nx1<=1792) nx1=1792;
+	if(nx1<0 && nx1>=-1792) nx1=-1792;
+	if(nx2>=0 && nx2<=1792) nx2=1792;
+	if(nx2<0 && nx2>=-1792) nx2=-1792;
+	
+	viewx1=(int)(centerx+ny1*scale/nx1);
+	viewx2=(int)(centerx+ny2*scale/nx2);
+	
+	if(viewx2 < viewx1)
+	{
+		Scale3DSpriter(actor, viewx2, viewx1, frame, ny2, ny1, nx2, nx1);
+	}
+	else
+	{
+		Scale3DSpriter(actor, viewx1, viewx2, frame, ny1, ny2, nx1, nx2);
+	}
+}
+#endif
+#endif
+#if 1
+void Scale3DShaperSDL(int x1, int x2, FTexture *shape, uint32_t flags, fixed ny1, fixed ny2,
+				fixed nx1, fixed nx2, byte *vbuf, unsigned vbufPitch)
+{
+	printf("%s(%d, %d, %p, %d, %f, %f, %f, %f, %p, %d)\n", __FUNCTION__, x1, x2, shape, flags, FIXED2FLOAT(ny1), FIXED2FLOAT(ny2), FIXED2FLOAT(nx1), FIXED2FLOAT(nx2), vbuf, vbufPitch);
+	unsigned scale1,starty,endy;
+	word *cmdptr;
+	byte *line;
+	byte *vmem;
+	int dx,len,i,newstart,ycnt,pixheight,screndy,upperedge,scrstarty;
+	unsigned j;
+	fixed height,dheight,height1,height2;
+	int xpos[TEXTURESIZE+1];
+	int slinex;
+	fixed dxx=(ny2-ny1)<<8,dzz=(nx2-nx1)<<8;
+	fixed dxa=0,dza=0;
+	byte col;
+
+	len=shape->GetWidth();
+	if(!len) return;
+
+	ny1+=dxx>>9;
+	nx1+=dzz>>9;
+
+	dxa=-(dxx>>1),dza=-(dzz>>1);
+	dxx>>=TEXTURESHIFT,dzz>>=TEXTURESHIFT;
+	dxa+=dxx,dza+=dzz;
+
+	xpos[0]=(int)((ny1+(dxa>>8))*scale/(nx1+(dza>>8))+centerx);
+	height1 = heightnumerator/((nx1+(dza>>8))>>8);
+	height=(((fixed)height1)<<12)+2048;
+
+	printf("{%d,", xpos[0]);
+	for(i=1;i<=len;i++)
+	{
+		dxa+=dxx,dza+=dzz;
+		xpos[i]=(int)((ny1+(dxa>>8))*scale/(nx1+(dza>>8))+centerx);
+		printf("%d,", xpos[i]);
+		if(xpos[i-1]>viewwidth) break;
+	}
+	printf("}\n");
+	len=i-1;
+	dx = xpos[len] - xpos[0];
+	if(!dx) return;
+
+	height2 = heightnumerator/((nx1+(dza>>8))>>8);
+	dheight=(((fixed)height2-(fixed)height1)<<12)/(fixed)dx;
+
+	i=0;
+	if(x2>viewwidth) x2=viewwidth;
+
+	for(i=0;i<len;i++)
+	{
+		for(slinex=xpos[i];slinex<xpos[i+1] && slinex<x2;slinex++)
+		{
+			height+=dheight;
+			if(slinex<0) continue;
+
+			scale1=(unsigned)(height>>15);
+
+			if(wallheight[slinex]<(height>>12) && scale1 /*&& scale1<=maxscale*/)
+			{
+#define SPRITESCALEFACTOR 2
+				pixheight=scale1*SPRITESCALEFACTOR;
+				upperedge=viewheight/2-scale1;
+
+				line=(byte*)shape->GetColumn(i, NULL);
+
+				if((endy = 128) != 0)
+				{
+					endy >>= 1;
+					newstart = 0;
+					starty = 0 >> 1;
+					j=starty;
+					ycnt=j*pixheight;
+					screndy=(ycnt>>6)+upperedge;
+					if(screndy<0) vmem=vbuf+slinex;
+					else vmem=vbuf+screndy*vbufPitch+slinex;
+					for(;j<endy;j++)
+					{
+						scrstarty=screndy;
+						ycnt+=pixheight;
+						screndy=(ycnt>>6)+upperedge;
+						if(scrstarty!=screndy && screndy>0)
+						{
+							col=line[j];
+							if(scrstarty<0) scrstarty=0;
+							if(screndy>viewheight) screndy=viewheight,j=endy;
+
+							while(scrstarty<screndy)
+							{
+								if(col)
+									*vmem=col;
+								vmem+=vbufPitch;
+								scrstarty++;
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
+#if 0
+void Scale3DSprite(AActor *ob, const Frame *frame, unsigned height)
+{
+	fixed nx1,nx2,ny1,ny2;
+	int viewx1,viewx2;
+	fixed diradd = 0x8000;
+	fixed playx = viewx;
+	fixed playy = viewy;
+
+	//
+	// the following values for "diradd" aren't optimized yet
+	// if you have problems with sprites being visible through wall edges
+	// where they shouldn't, you can try to adjust these values and SIZEADD
+	//
+
+#define SIZEADD 0
+
+#if 0
+	switch(ob->flags & FL_DIR_POS_MASK)
+	{
+		case FL_DIR_POS_FW: diradd=0x7ff0+0x8000; break;
+		case FL_DIR_POS_BW: diradd=-0x7ff0+0x8000; break;
+		case FL_DIR_POS_MID: diradd=0x8000; break;
+		default:
+			Quit("Unknown directional 3d sprite position (shapenum = %i)", ob->shapenum);
+	}
+#endif
+
+	if(ob->angle == 0 || ob->angle == ANGLE_180)     // vertical dir 3d sprite
+	{
+		fixed gy1,gy2,gx,gyt1,gyt2,gxt;
+		//
+		// translate point to view centered coordinates
+		//
+		gy1 = (((long)ob->tiley) << TILESHIFT)+0x8000-playy-0x8000L-SIZEADD;
+		gy2 = gy1+0x10000L+2*SIZEADD;
+		gx = (((long)ob->tilex) << TILESHIFT)+diradd-playx;
+
+		//
+		// calculate newx
+		//
+		gxt = FixedMul(gx,viewcos);
+		gyt1 = FixedMul(gy1,viewsin);
+		gyt2 = FixedMul(gy2,viewsin);
+		nx1 = gxt-gyt1;
+		nx2 = gxt-gyt2;
+
+		//
+		// calculate newy
+		//
+		gxt = FixedMul(gx,viewsin);
+		gyt1 = FixedMul(gy1,viewcos);
+		gyt2 = FixedMul(gy2,viewcos);
+		ny1 = gyt1+gxt;
+		ny2 = gyt2+gxt;
+	}
+	else                                    // horizontal dir 3d sprite
+	{
+		fixed gx1,gx2,gy,gxt1,gxt2,gyt;
+		//
+		// translate point to view centered coordinates
+		//
+		gx1 = (((long)ob->tilex) << TILESHIFT)+0x8000-playx-0x8000L-SIZEADD;
+		gx2 = gx1+0x10000L+2*SIZEADD;
+		gy = (((long)ob->tiley) << TILESHIFT)+diradd-playy;
+
+		//
+		// calculate newx
+		//
+		gxt1 = FixedMul(gx1,viewcos);
+		gxt2 = FixedMul(gx2,viewcos);
+		gyt = FixedMul(gy,viewsin);
+		nx1 = gxt1-gyt;
+		nx2 = gxt2-gyt;
+
+		//
+		// calculate newy
+		//
+		gxt1 = FixedMul(gx1,viewsin);
+		gxt2 = FixedMul(gx2,viewsin);
+		gyt = FixedMul(gy,viewcos);
+		ny1 = gyt+gxt1;
+		ny2 = gyt+gxt2;
+	}
+
+	if(nx1 < 0 || nx2 < 0) return;      // TODO: Clip on viewplane
+
+	//
+	// calculate perspective ratio
+	//
+	if(nx1>=0 && nx1<=1792) nx1=1792;
+	if(nx1<0 && nx1>=-1792) nx1=-1792;
+	if(nx2>=0 && nx2<=1792) nx2=1792;
+	if(nx2<0 && nx2>=-1792) nx2=-1792;
+
+	viewx1=(int)(centerx+ny1*scale/nx1);
+	viewx2=(int)(centerx+ny2*scale/nx2);
+
+	bool flip = false;
+	const Sprite &spr = spriteFrames[loadedSprites[ob->sprite].frames+frame->frame];
+	FTexture *tex;
+	if(spr.rotations == 0)
+		tex = TexMan[spr.texture[0]];
+	else
+	{
+		int rot = (CalcRotate(ob)+4)%8;
+		tex = TexMan[spr.texture[rot]];
+		flip = (spr.mirror>>rot)&1;
+	}
+	if(tex == NULL)
+		return;
+
+#if 0
+	if(viewx2 < viewx1)
+	{
+		Scale3DShaperSDL(viewx2,viewx1,tex,0,ny2,ny1,nx2,nx1,vbuf,vbufPitch);
+	}
+	else
+	{
+		Scale3DShaperSDL(viewx1,viewx2,tex,0,ny1,ny2,nx1,nx2,vbuf,vbufPitch);
+	}
+#else
+	if(viewx2 < viewx1)
+	{
+		Scale3DSpriter(ob, viewx2, viewx1, frame, ny2, ny1, nx2, nx1);
+	}
+	else
+	{
+		Scale3DSpriter(ob, viewx1, viewx2, frame, ny1, ny2, nx1, nx2);
+	}
+#endif
+}
+#endif
+#endif
+
 void R_DrawPlayerSprite(AActor *actor, const Frame *frame, fixed offsetX, fixed offsetY)
 {
 	if(frame->spriteInf == SPR_NONE || loadedSprites[frame->spriteInf].numFrames == 0)
diff -r d252d2dd3fe6 src/wl_dir3dspr.cpp
--- a/src/wl_dir3dspr.cpp	Sun Nov 15 19:01:04 2015 -0500
+++ b/src/wl_dir3dspr.cpp	Mon Nov 16 22:54:36 2015 -0500
@@ -1,18 +1,21 @@
 #include "version.h"
 
-#ifdef USE_DIR3DSPR
+#if 0
+#include "actor.h"
 #include "wl_def.h"
+#include "wl_draw.h"
 #include "wl_shade.h"
+#include "wl_main.h"
 #include "c_cvars.h"
 
 // Define directional 3d sprites in wl_act1.cpp (there are two examples)
 // Make sure you have according entries in ScanInfoPlane in wl_game.cpp.
 
 
-void Scale3DShaper(int x1, int x2, int shapenum, uint32_t flags, fixed ny1, fixed ny2,
+void Scale3DShaper(int x1, int x2, FTexture *shape, uint32_t flags, fixed ny1, fixed ny2,
 				fixed nx1, fixed nx2, byte *vbuf, unsigned vbufPitch)
 {
-	t_compshape *shape;
+	printf("%s(%d, %d, %p, %d, %f, %f, %f, %f, %p, %d)\n", __FUNCTION__, x1, x2, shape, flags, FIXED2FLOAT(ny1), FIXED2FLOAT(ny2), FIXED2FLOAT(nx1), FIXED2FLOAT(nx2), vbuf, vbufPitch);
 	unsigned scale1,starty,endy;
 	word *cmdptr;
 	byte *line;
@@ -26,9 +29,7 @@
 	fixed dxa=0,dza=0;
 	byte col;
 
-	shape = (t_compshape *) PM_GetSprite(shapenum);
-
-	len=shape->rightpix-shape->leftpix+1;
+	len=shape->GetWidth();
 	if(!len) return;
 
 	ny1+=dxx>>9;
@@ -36,7 +37,7 @@
 
 	dxa=-(dxx>>1),dza=-(dzz>>1);
 	dxx>>=TEXTURESHIFT,dzz>>=TEXTURESHIFT;
-	dxa+=shape->leftpix*dxx,dza+=shape->leftpix*dzz;
+	dxa+=dxx,dza+=dzz;
 
 	xpos[0]=(int)((ny1+(dxa>>8))*scale/(nx1+(dza>>8))+centerx);
 	height1 = heightnumerator/((nx1+(dza>>8))>>8);
@@ -55,8 +56,6 @@
 	height2 = heightnumerator/((nx1+(dza>>8))>>8);
 	dheight=(((fixed)height2-(fixed)height1)<<12)/(fixed)dx;
 
-	cmdptr = (word *) shape->dataofs;
-
 	i=0;
 	if(x2>viewwidth) x2=viewwidth;
 
@@ -71,22 +70,17 @@
 
 			if(wallheight[slinex]<(height>>12) && scale1 /*&& scale1<=maxscale*/)
 			{
-				BYTE *curshades;
-				if(flags & FL_BRIGHT)
-					curshades = NormalLights.Maps;
-				else
-					curshades = &NormalLights.Maps[256*GetShade(scale1<<3)];
-
+#define SPRITESCALEFACTOR 2
 				pixheight=scale1*SPRITESCALEFACTOR;
 				upperedge=viewheight/2-scale1;
 
-				line=(byte *)shape + cmdptr[i];
+				line=(byte*)shape->GetColumn(i, NULL);
 
-				while((endy = READWORD(line)) != 0)
+				if((endy = 128) != 0)
 				{
 					endy >>= 1;
-					newstart = READWORD(line);
-					starty = READWORD(line) >> 1;
+					newstart = 0;
+					starty = 0 >> 1;
 					j=starty;
 					ycnt=j*pixheight;
 					screndy=(ycnt>>6)+upperedge;
@@ -99,16 +93,14 @@
 						screndy=(ycnt>>6)+upperedge;
 						if(scrstarty!=screndy && screndy>0)
 						{
-							if(r_depthfog)
-								col=curshades[((byte *)shape)[newstart+j]];
-							else
-								col=((byte *)shape)[newstart+j];
+							col=line[j];
 							if(scrstarty<0) scrstarty=0;
 							if(screndy>viewheight) screndy=viewheight,j=endy;
 
 							while(scrstarty<screndy)
 							{
-								*vmem=col;
+								if(col)
+									*vmem=col;
 								vmem+=vbufPitch;
 								scrstarty++;
 							}
@@ -120,109 +112,4 @@
 	}
 }
 
-void Scale3DShape(byte *vbuf, unsigned vbufPitch, statobj_t *ob)
-{
-	fixed nx1,nx2,ny1,ny2;
-	int viewx1,viewx2;
-	fixed diradd;
-	fixed playx = viewx;
-	fixed playy = viewy;
-
-	//
-	// the following values for "diradd" aren't optimized yet
-	// if you have problems with sprites being visible through wall edges
-	// where they shouldn't, you can try to adjust these values and SIZEADD
-	//
-
-#define SIZEADD 1024
-
-	switch(ob->flags & FL_DIR_POS_MASK)
-	{
-		case FL_DIR_POS_FW: diradd=0x7ff0+0x8000; break;
-		case FL_DIR_POS_BW: diradd=-0x7ff0+0x8000; break;
-		case FL_DIR_POS_MID: diradd=0x8000; break;
-		default:
-			Quit("Unknown directional 3d sprite position (shapenum = %i)", ob->shapenum);
-	}
-
-	if(ob->flags & FL_DIR_VERT_FLAG)     // vertical dir 3d sprite
-	{
-		fixed gy1,gy2,gx,gyt1,gyt2,gxt;
-		//
-		// translate point to view centered coordinates
-		//
-		gy1 = (((long)ob->tiley) << TILESHIFT)+0x8000-playy-0x8000L-SIZEADD;
-		gy2 = gy1+0x10000L+2*SIZEADD;
-		gx = (((long)ob->tilex) << TILESHIFT)+diradd-playx;
-
-		//
-		// calculate newx
-		//
-		gxt = FixedMul(gx,viewcos);
-		gyt1 = FixedMul(gy1,viewsin);
-		gyt2 = FixedMul(gy2,viewsin);
-		nx1 = gxt-gyt1;
-		nx2 = gxt-gyt2;
-
-		//
-		// calculate newy
-		//
-		gxt = FixedMul(gx,viewsin);
-		gyt1 = FixedMul(gy1,viewcos);
-		gyt2 = FixedMul(gy2,viewcos);
-		ny1 = gyt1+gxt;
-		ny2 = gyt2+gxt;
-	}
-	else                                    // horizontal dir 3d sprite
-	{
-		fixed gx1,gx2,gy,gxt1,gxt2,gyt;
-		//
-		// translate point to view centered coordinates
-		//
-		gx1 = (((long)ob->tilex) << TILESHIFT)+0x8000-playx-0x8000L-SIZEADD;
-		gx2 = gx1+0x10000L+2*SIZEADD;
-		gy = (((long)ob->tiley) << TILESHIFT)+diradd-playy;
-
-		//
-		// calculate newx
-		//
-		gxt1 = FixedMul(gx1,viewcos);
-		gxt2 = FixedMul(gx2,viewcos);
-		gyt = FixedMul(gy,viewsin);
-		nx1 = gxt1-gyt;
-		nx2 = gxt2-gyt;
-
-		//
-		// calculate newy
-		//
-		gxt1 = FixedMul(gx1,viewsin);
-		gxt2 = FixedMul(gx2,viewsin);
-		gyt = FixedMul(gy,viewcos);
-		ny1 = gyt+gxt1;
-		ny2 = gyt+gxt2;
-	}
-
-	if(nx1 < 0 || nx2 < 0) return;      // TODO: Clip on viewplane
-
-	//
-	// calculate perspective ratio
-	//
-	if(nx1>=0 && nx1<=1792) nx1=1792;
-	if(nx1<0 && nx1>=-1792) nx1=-1792;
-	if(nx2>=0 && nx2<=1792) nx2=1792;
-	if(nx2<0 && nx2>=-1792) nx2=-1792;
-
-	viewx1=(int)(centerx+ny1*scale/nx1);
-	viewx2=(int)(centerx+ny2*scale/nx2);
-
-	if(viewx2 < viewx1)
-	{
-		Scale3DShaper(viewx2,viewx1,ob->shapenum,ob->flags,ny2,ny1,nx2,nx1,vbuf,vbufPitch);
-	}
-	else
-	{
-		Scale3DShaper(viewx1,viewx2,ob->shapenum,ob->flags,ny1,ny2,nx1,nx2,vbuf,vbufPitch);
-	}
-}
-
 #endif
