shithub: qk1

Download patch

ref: b4c6a7ee10270801b4e26063ad3a1919e0d0f104
parent: ab06b0ebe671252f7fc1b517d2c2d3f1f00ee5bc
author: qwx <>
date: Sat Apr 21 05:46:40 EDT 2018

vid: clean up and simplify

- remove unused shit
- shitcan viewsizes < 100, useless on plan9
- flipfb: don't care about vrect lists, useless; don't redraw the entire
  screen every time unless screen.c says so or palette changed

--- a/d_iface.h
+++ b/d_iface.h
@@ -108,7 +108,6 @@
 											//  driver)
 extern float	r_aliasuvscale;		// scale-up factor for screen u and v
 									//  on Alias vertices passed to driver
-extern int		r_pixbytes;
 extern qboolean	r_dowarp;
 
 extern affinetridesc_t	r_affinetridesc;
@@ -115,19 +114,10 @@
 extern spritedesc_t		r_spritedesc;
 extern zpointdesc_t		r_zpointdesc;
 extern polydesc_t		r_polydesc;
-
-extern int		d_con_indirect;	// if 0, Quake will draw console directly
-								//  to vid.buffer; if 1, Quake will
-								//  draw console via D_DrawRect. Must be
-								//  defined by driver
-
 extern vec3_t	r_pright, r_pup, r_ppn;
 
 
 void D_Aff8Patch (void *pcolormap);
-void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height);
-void D_DisableBackBufferAccess (void);
-void D_EndDirectRect (int x, int y, int width, int height);
 void D_PolysetDraw (void);
 void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts);
 void D_DrawParticle (particle_t *pparticle);
@@ -135,7 +125,6 @@
 void D_DrawSprite (void);
 void D_DrawSurfaces (void);
 void D_DrawZPoint (void);
-void D_EnableBackBufferAccess (void);
 void D_EndParticles (void);
 void D_Init (void);
 void D_ViewChanged (void);
--- a/d_init.c
+++ b/d_init.c
@@ -39,7 +39,6 @@
 	r_drawpolys = false;
 	r_worldpolysbacktofront = false;
 	r_recursiveaffinetriangles = true;
-	r_pixbytes = 1;
 	r_aliasuvscale = 1.0;
 }
 
--- a/draw.c
+++ b/draw.c
@@ -110,7 +110,6 @@
 {
 	byte			*dest;
 	byte			*source;
-	unsigned short	*pusdest;
 	int				drawline;	
 	int				row, col;
 
@@ -138,63 +137,19 @@
 	}
 	else
 		drawline = 8;
-
-
-	if (r_pixbytes == 1)
-	{
-		dest = vid.conbuffer + y*vid.conrowbytes + x;
-	
-		while (drawline--)
-		{
-			if (source[0])
-				dest[0] = source[0];
-			if (source[1])
-				dest[1] = source[1];
-			if (source[2])
-				dest[2] = source[2];
-			if (source[3])
-				dest[3] = source[3];
-			if (source[4])
-				dest[4] = source[4];
-			if (source[5])
-				dest[5] = source[5];
-			if (source[6])
-				dest[6] = source[6];
-			if (source[7])
-				dest[7] = source[7];
-			source += 128;
-			dest += vid.conrowbytes;
-		}
+	dest = vid.conbuffer + y*vid.conrowbytes + x;
+	while(drawline--){
+		if(source[0]) dest[0] = source[0];
+		if(source[1]) dest[1] = source[1];
+		if(source[2]) dest[2] = source[2];
+		if(source[3]) dest[3] = source[3];
+		if(source[4]) dest[4] = source[4];
+		if(source[5]) dest[5] = source[5];
+		if(source[6]) dest[6] = source[6];
+		if(source[7]) dest[7] = source[7];
+		source += 128;
+		dest += vid.conrowbytes;
 	}
-	else
-	{
-	// FIXME: pre-expand to native format?
-		pusdest = (unsigned short *)
-				((byte *)vid.conbuffer + y*vid.conrowbytes + (x<<1));
-
-		while (drawline--)
-		{
-			if (source[0])
-				pusdest[0] = d_8to16table[source[0]];
-			if (source[1])
-				pusdest[1] = d_8to16table[source[1]];
-			if (source[2])
-				pusdest[2] = d_8to16table[source[2]];
-			if (source[3])
-				pusdest[3] = d_8to16table[source[3]];
-			if (source[4])
-				pusdest[4] = d_8to16table[source[4]];
-			if (source[5])
-				pusdest[5] = d_8to16table[source[5]];
-			if (source[6])
-				pusdest[6] = d_8to16table[source[6]];
-			if (source[7])
-				pusdest[7] = d_8to16table[source[7]];
-
-			source += 128;
-			pusdest += (vid.conrowbytes >> 1);
-		}
-	}
 }
 
 /*
@@ -263,8 +218,7 @@
 void Draw_Pic (int x, int y, qpic_t *pic)
 {
 	byte			*dest, *source;
-	unsigned short	*pusdest;
-	int				v, u;
+	int v;
 
 	if ((x < 0) ||
 		(x + pic->width > vid.width) ||
@@ -273,36 +227,13 @@
 	{
 		fatal ("Draw_Pic: bad coordinates");
 	}
-
 	source = pic->data;
-
-	if (r_pixbytes == 1)
-	{
-		dest = vid.buffer + y * vid.rowbytes + x;
-
-		for (v=0 ; v<pic->height ; v++)
-		{
-			memcpy(dest, source, pic->width);
-			dest += vid.rowbytes;
-			source += pic->width;
-		}
+	dest = vid.buffer + y * vid.rowbytes + x;
+	for(v=0; v<pic->height; v++){
+		memcpy(dest, source, pic->width);
+		dest += vid.rowbytes;
+		source += pic->width;
 	}
-	else
-	{
-	// FIXME: pretranslate at load time?
-		pusdest = (unsigned short *)vid.buffer + y * (vid.rowbytes >> 1) + x;
-
-		for (v=0 ; v<pic->height ; v++)
-		{
-			for (u=0 ; u<pic->width ; u++)
-			{
-				pusdest[u] = d_8to16table[source[u]];
-			}
-
-			pusdest += vid.rowbytes >> 1;
-			source += pic->width;
-		}
-	}
 }
 
 
@@ -314,7 +245,6 @@
 void Draw_TransPic (int x, int y, qpic_t *pic)
 {
 	byte	*dest, *source, tbyte;
-	unsigned short	*pusdest;
 	int				v, u;
 
 	if (x < 0 || (unsigned)(x + pic->width) > vid.width || y < 0 ||
@@ -322,71 +252,37 @@
 	{
 		fatal ("Draw_TransPic: bad coordinates");
 	}
-		
 	source = pic->data;
-
-	if (r_pixbytes == 1)
-	{
-		dest = vid.buffer + y * vid.rowbytes + x;
-
-		if (pic->width & 7)
-		{	// general
-			for (v=0 ; v<pic->height ; v++)
-			{
-				for (u=0 ; u<pic->width ; u++)
-					if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
-						dest[u] = tbyte;
-	
-				dest += vid.rowbytes;
-				source += pic->width;
-			}
+	dest = vid.buffer + y * vid.rowbytes + x;
+	if(pic->width & 7){	// general
+		for(v=0; v<pic->height; v++){
+			for(u=0; u<pic->width; u++)
+				if((tbyte = source[u]) != TRANSPARENT_COLOR)
+					dest[u] = tbyte;
+			dest += vid.rowbytes;
+			source += pic->width;
 		}
-		else
-		{	// unwound
-			for (v=0 ; v<pic->height ; v++)
-			{
-				for (u=0 ; u<pic->width ; u+=8)
-				{
-					if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
-						dest[u] = tbyte;
-					if ( (tbyte=source[u+1]) != TRANSPARENT_COLOR)
-						dest[u+1] = tbyte;
-					if ( (tbyte=source[u+2]) != TRANSPARENT_COLOR)
-						dest[u+2] = tbyte;
-					if ( (tbyte=source[u+3]) != TRANSPARENT_COLOR)
-						dest[u+3] = tbyte;
-					if ( (tbyte=source[u+4]) != TRANSPARENT_COLOR)
-						dest[u+4] = tbyte;
-					if ( (tbyte=source[u+5]) != TRANSPARENT_COLOR)
-						dest[u+5] = tbyte;
-					if ( (tbyte=source[u+6]) != TRANSPARENT_COLOR)
-						dest[u+6] = tbyte;
-					if ( (tbyte=source[u+7]) != TRANSPARENT_COLOR)
-						dest[u+7] = tbyte;
-				}
-				dest += vid.rowbytes;
-				source += pic->width;
+	}else{	// unwound
+		for(v=0; v<pic->height; v++){
+			for(u=0; u<pic->width; u+=8){
+				if((tbyte = source[u]) != TRANSPARENT_COLOR)
+					dest[u] = tbyte;
+				if((tbyte = source[u+1]) != TRANSPARENT_COLOR)
+					dest[u+1] = tbyte;
+				if((tbyte = source[u+2]) != TRANSPARENT_COLOR)
+					dest[u+2] = tbyte;
+				if((tbyte = source[u+3]) != TRANSPARENT_COLOR)
+					dest[u+3] = tbyte;
+				if((tbyte = source[u+4]) != TRANSPARENT_COLOR)
+					dest[u+4] = tbyte;
+				if((tbyte = source[u+5]) != TRANSPARENT_COLOR)
+					dest[u+5] = tbyte;
+				if((tbyte = source[u+6]) != TRANSPARENT_COLOR)
+					dest[u+6] = tbyte;
+				if((tbyte = source[u+7]) != TRANSPARENT_COLOR)
+					dest[u+7] = tbyte;
 			}
-		}
-	}
-	else
-	{
-	// FIXME: pretranslate at load time?
-		pusdest = (unsigned short *)vid.buffer + y * (vid.rowbytes >> 1) + x;
-
-		for (v=0 ; v<pic->height ; v++)
-		{
-			for (u=0 ; u<pic->width ; u++)
-			{
-				tbyte = source[u];
-
-				if (tbyte != TRANSPARENT_COLOR)
-				{
-					pusdest[u] = d_8to16table[tbyte];
-				}
-			}
-
-			pusdest += vid.rowbytes >> 1;
+			dest += vid.rowbytes;
 			source += pic->width;
 		}
 	}
@@ -401,7 +297,6 @@
 void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation)
 {
 	byte	*dest, *source, tbyte;
-	unsigned short	*pusdest;
 	int				v, u;
 
 	if (x < 0 || (unsigned)(x + pic->width) > vid.width || y < 0 ||
@@ -408,72 +303,38 @@
 		 (unsigned)(y + pic->height) > vid.height)
 	{
 		fatal ("Draw_TransPic: bad coordinates");
-	}
-		
+	}	
 	source = pic->data;
-
-	if (r_pixbytes == 1)
-	{
-		dest = vid.buffer + y * vid.rowbytes + x;
-
-		if (pic->width & 7)
-		{	// general
-			for (v=0 ; v<pic->height ; v++)
-			{
-				for (u=0 ; u<pic->width ; u++)
-					if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
-						dest[u] = translation[tbyte];
-
-				dest += vid.rowbytes;
-				source += pic->width;
-			}
+	dest = vid.buffer + y * vid.rowbytes + x;
+	if (pic->width & 7){	// general
+		for(v=0; v<pic->height; v++){
+			for(u=0; u<pic->width; u++)
+				if((tbyte = source[u]) != TRANSPARENT_COLOR)
+					dest[u] = translation[tbyte];
+			dest += vid.rowbytes;
+			source += pic->width;
 		}
-		else
-		{	// unwound
-			for (v=0 ; v<pic->height ; v++)
-			{
-				for (u=0 ; u<pic->width ; u+=8)
-				{
-					if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
-						dest[u] = translation[tbyte];
-					if ( (tbyte=source[u+1]) != TRANSPARENT_COLOR)
-						dest[u+1] = translation[tbyte];
-					if ( (tbyte=source[u+2]) != TRANSPARENT_COLOR)
-						dest[u+2] = translation[tbyte];
-					if ( (tbyte=source[u+3]) != TRANSPARENT_COLOR)
-						dest[u+3] = translation[tbyte];
-					if ( (tbyte=source[u+4]) != TRANSPARENT_COLOR)
-						dest[u+4] = translation[tbyte];
-					if ( (tbyte=source[u+5]) != TRANSPARENT_COLOR)
-						dest[u+5] = translation[tbyte];
-					if ( (tbyte=source[u+6]) != TRANSPARENT_COLOR)
-						dest[u+6] = translation[tbyte];
-					if ( (tbyte=source[u+7]) != TRANSPARENT_COLOR)
-						dest[u+7] = translation[tbyte];
-				}
-				dest += vid.rowbytes;
-				source += pic->width;
+	}else{	// unwound
+		for(v=0; v<pic->height; v++){
+			for(u=0; u<pic->width; u+=8){
+				if((tbyte = source[u]) != TRANSPARENT_COLOR)
+					dest[u] = translation[tbyte];
+				if((tbyte = source[u+1]) != TRANSPARENT_COLOR)
+					dest[u+1] = translation[tbyte];
+				if((tbyte = source[u+2]) != TRANSPARENT_COLOR)
+					dest[u+2] = translation[tbyte];
+				if((tbyte = source[u+3]) != TRANSPARENT_COLOR)
+					dest[u+3] = translation[tbyte];
+				if((tbyte = source[u+4]) != TRANSPARENT_COLOR)
+					dest[u+4] = translation[tbyte];
+				if((tbyte = source[u+5]) != TRANSPARENT_COLOR)
+					dest[u+5] = translation[tbyte];
+				if((tbyte = source[u+6]) != TRANSPARENT_COLOR)
+					dest[u+6] = translation[tbyte];
+				if((tbyte = source[u+7]) != TRANSPARENT_COLOR)
+					dest[u+7] = translation[tbyte];
 			}
-		}
-	}
-	else
-	{
-	// FIXME: pretranslate at load time?
-		pusdest = (unsigned short *)vid.buffer + y * (vid.rowbytes >> 1) + x;
-
-		for (v=0 ; v<pic->height ; v++)
-		{
-			for (u=0 ; u<pic->width ; u++)
-			{
-				tbyte = source[u];
-
-				if (tbyte != TRANSPARENT_COLOR)
-				{
-					pusdest[u] = d_8to16table[tbyte];
-				}
-			}
-
-			pusdest += vid.rowbytes >> 1;
+			dest += vid.rowbytes;
 			source += pic->width;
 		}
 	}
@@ -514,7 +375,6 @@
 {
 	int				x, y, v;
 	byte			*src, *dest;
-	unsigned short	*pusdest;
 	int				f, fstep;
 	qpic_t			*conback;
 	char			ver[100];
@@ -527,58 +387,20 @@
 
 	for (x=0 ; x<strlen(ver) ; x++)
 		Draw_CharToConback (ver[x], dest+(x<<3));
-	
-// draw the pic
-	if (r_pixbytes == 1)
-	{
-		dest = vid.conbuffer;
-
-		for (y=0 ; y<lines ; y++, dest += vid.conrowbytes)
-		{
-			v = (vid.conheight - lines + y)*200/vid.conheight;
-			src = conback->data + v*320;
-			if (vid.conwidth == 320)
-				memcpy (dest, src, vid.conwidth);
-			else
-			{
-				f = 0;
-				fstep = 320*0x10000/vid.conwidth;
-				for (x=0 ; x<vid.conwidth ; x+=4)
-				{
-					dest[x] = src[f>>16];
-					f += fstep;
-					dest[x+1] = src[f>>16];
-					f += fstep;
-					dest[x+2] = src[f>>16];
-					f += fstep;
-					dest[x+3] = src[f>>16];
-					f += fstep;
-				}
-			}
-		}
-	}
-	else
-	{
-		pusdest = (unsigned short *)vid.conbuffer;
-
-		for (y=0 ; y<lines ; y++, pusdest += (vid.conrowbytes >> 1))
-		{
-		// FIXME: pre-expand to native format?
-		// FIXME: does the endian switching go away in production?
-			v = (vid.conheight - lines + y)*200/vid.conheight;
-			src = conback->data + v*320;
+	dest = vid.conbuffer;
+	for(y=0; y<lines; y++, dest+=vid.conrowbytes){
+		v = (vid.conheight - lines + y) * 200 / vid.conheight;
+		src = conback->data + v * 320;
+		if(vid.conwidth == 320)
+			memcpy(dest, src, vid.conwidth);
+		else{
 			f = 0;
-			fstep = 320*0x10000/vid.conwidth;
-			for (x=0 ; x<vid.conwidth ; x+=4)
-			{
-				pusdest[x] = d_8to16table[src[f>>16]];
-				f += fstep;
-				pusdest[x+1] = d_8to16table[src[f>>16]];
-				f += fstep;
-				pusdest[x+2] = d_8to16table[src[f>>16]];
-				f += fstep;
-				pusdest[x+3] = d_8to16table[src[f>>16]];
-				f += fstep;
+			fstep = 320 * 0x10000 / vid.conwidth;
+			for(x=0; x<vid.conwidth; x+=4){
+				dest[x] = src[f>>16]; f += fstep;
+				dest[x+1] = src[f>>16]; f += fstep;
+				dest[x+2] = src[f>>16]; f += fstep;
+				dest[x+3] = src[f>>16]; f += fstep;
 			}
 		}
 	}
@@ -633,66 +455,7 @@
 	}
 }
 
-
 /*
-==============
-R_DrawRect16
-==============
-*/
-void R_DrawRect16 (vrect_t *prect, int rowbytes, byte *psrc,
-	int transparent)
-{
-	byte			t;
-	int				i, j, srcdelta, destdelta;
-	unsigned short	*pdest;
-
-// FIXME: would it be better to pre-expand native-format versions?
-
-	pdest = (unsigned short *)vid.buffer +
-			(prect->y * (vid.rowbytes >> 1)) + prect->x;
-
-	srcdelta = rowbytes - prect->width;
-	destdelta = (vid.rowbytes >> 1) - prect->width;
-
-	if (transparent)
-	{
-		for (i=0 ; i<prect->height ; i++)
-		{
-			for (j=0 ; j<prect->width ; j++)
-			{
-				t = *psrc;
-				if (t != TRANSPARENT_COLOR)
-				{
-					*pdest = d_8to16table[t];
-				}
-
-				psrc++;
-				pdest++;
-			}
-
-			psrc += srcdelta;
-			pdest += destdelta;
-		}
-	}
-	else
-	{
-		for (i=0 ; i<prect->height ; i++)
-		{
-			for (j=0 ; j<prect->width ; j++)
-			{
-				*pdest = d_8to16table[*psrc];
-				psrc++;
-				pdest++;
-			}
-
-			psrc += srcdelta;
-			pdest += destdelta;
-		}
-	}
-}
-
-
-/*
 =============
 Draw_TileClear
 
@@ -743,16 +506,7 @@
 
 			psrc = r_rectdesc.ptexbytes +
 					(tileoffsety * r_rectdesc.rowbytes) + tileoffsetx;
-
-			if (r_pixbytes == 1)
-			{
-				R_DrawRect8 (&vr, r_rectdesc.rowbytes, psrc, 0);
-			}
-			else
-			{
-				R_DrawRect16 (&vr, r_rectdesc.rowbytes, psrc, 0);
-			}
-
+			R_DrawRect8(&vr, r_rectdesc.rowbytes, psrc, 0);
 			vr.x += vr.width;
 			width -= vr.width;
 			tileoffsetx = 0;	// only the left tile can be left-clipped
@@ -775,28 +529,13 @@
 void Draw_Fill (int x, int y, int w, int h, int c)
 {
 	byte			*dest;
-	unsigned short	*pusdest;
-	unsigned		uc;
 	int				u, v;
 
-	if (r_pixbytes == 1)
-	{
-		dest = vid.buffer + y*vid.rowbytes + x;
-		for (v=0 ; v<h ; v++, dest += vid.rowbytes)
-			for (u=0 ; u<w ; u++)
-				dest[u] = c;
-	}
-	else
-	{
-		uc = d_8to16table[c];
-
-		pusdest = (unsigned short *)vid.buffer + y * (vid.rowbytes >> 1) + x;
-		for (v=0 ; v<h ; v++, pusdest += (vid.rowbytes >> 1))
-			for (u=0 ; u<w ; u++)
-				pusdest[u] = uc;
-	}
+	dest = vid.buffer + y*vid.rowbytes + x;
+	for(v=0; v<h; v++, dest+=vid.rowbytes)
+		for(u=0; u<w; u++)
+			dest[u] = c;
 }
-//=============================================================================
 
 /*
 ================
@@ -823,35 +562,3 @@
 		}
 	}
 }
-
-//=============================================================================
-
-/*
-================
-Draw_BeginDisc
-
-Draws the little blue disc in the corner of the screen.
-Call before beginning any disc IO.
-================
-*/
-void Draw_BeginDisc (void)
-{
-
-	D_BeginDirectRect (vid.width - 24, 0, draw_disc->data, 24, 24);
-}
-
-
-/*
-================
-Draw_EndDisc
-
-Erases the disc icon.
-Call after completing any disc IO
-================
-*/
-void Draw_EndDisc (void)
-{
-
-	D_EndDirectRect (vid.width - 24, 0, 24, 24);
-}
-
--- a/fns.h
+++ b/fns.h
@@ -1,3 +1,6 @@
+void	setpal(uchar*);
+void	flipfb(int);
+void	initfb(void);
 void	conscmd(void);
 void	Sys_SendKeyEvents(void);
 void	stepcd(void);
--- a/fs.c
+++ b/fs.c
@@ -346,10 +346,8 @@
 	if(buf == nil)
 		fatal("loadlmp %s %d: memory allocation failed: %r", f, m + 1);
 	buf[m] = 0;
-	Draw_BeginDisc();
 	eread(bf, buf, m);
 	closelmp(bf);
-	Draw_EndDisc();
 	if(n != nil)
 		*n = m;
 	return buf;
--- a/host.c
+++ b/host.c
@@ -630,7 +630,7 @@
 		if(host_colormap == nil)
 			fatal("Host_Init: %r");
 
-		VID_Init (host_basepal);
+		initfb();
 
 		Draw_Init ();
 		SCR_Init ();
@@ -681,10 +681,5 @@
 	shutcd();
 	shutsnd();
 	IN_Shutdown ();
-
-	if (cls.state != ca_dedicated)
-	{
-		VID_Shutdown();
-	}
 }
 
--- a/menu.c
+++ b/menu.c
@@ -7,12 +7,8 @@
 char savs[Nsav][Nsavcm];
 int savcanld[Nsav];
 
-/* FIXME: useless and redefined in vid.c? */
-void (*vid_menudrawfn)(void);
-void (*vid_menukeyfn)(int key);
+enum {m_none, m_main, m_singleplayer, m_load, m_save, m_multiplayer, m_setup, m_net, m_options, m_keys, m_help, m_quit, m_serialconfig, m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist} m_state;
 
-enum {m_none, m_main, m_singleplayer, m_load, m_save, m_multiplayer, m_setup, m_net, m_options, m_video, m_keys, m_help, m_quit, m_serialconfig, m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist} m_state;
-
 void M_Menu_Main_f (void);
 	void M_Menu_SinglePlayer_f (void);
 		void M_Menu_Load_f (void);
@@ -22,7 +18,6 @@
 		void M_Menu_Net_f (void);
 	void M_Menu_Options_f (void);
 		void M_Menu_Keys_f (void);
-		void M_Menu_Video_f (void);
 	void M_Menu_Help_f (void);
 	void M_Menu_Quit_f (void);
 void M_Menu_SerialConfig_f (void);
@@ -41,7 +36,6 @@
 		void M_Net_Draw (void);
 	void M_Options_Draw (void);
 		void M_Keys_Draw (void);
-		void M_Video_Draw (void);
 	void M_Help_Draw (void);
 	void M_Quit_Draw (void);
 void M_SerialConfig_Draw (void);
@@ -60,7 +54,6 @@
 		void M_Net_Key (int key);
 	void M_Options_Key (int key);
 		void M_Keys_Key (int key);
-		void M_Video_Key (int key);
 	void M_Help_Key (int key);
 	void M_Quit_Key (int key);
 void M_SerialConfig_Key (int key);
@@ -989,8 +982,8 @@
 	{
 	case 3:	// screen size
 		scr_viewsize.value += dir * 10;
-		if (scr_viewsize.value < 30)
-			scr_viewsize.value = 30;
+		if (scr_viewsize.value < 100)
+			scr_viewsize.value = 100;
 		if (scr_viewsize.value > 120)
 			scr_viewsize.value = 120;
 		setcvarv ("viewsize", scr_viewsize.value);
@@ -1099,7 +1092,7 @@
 	M_Print (16, 48, "     Reset to defaults");
 
 	M_Print (16, 56, "           Screen size");
-	r = (scr_viewsize.value - 30) / (120 - 30);
+	r = (scr_viewsize.value - 100) / (120 - 100);
 	M_DrawSlider (220, 56, r);
 
 	M_Print (16, 64, "            Brightness");
@@ -1130,9 +1123,6 @@
 	M_Print (16, 120, "            Lookstrafe");
 	M_DrawCheckbox (220, 120, lookstrafe.value);
 
-	if (vid_menudrawfn)
-		M_Print (16, 128, "         Video Options");
-
 // cursor
 	M_DrawCharacter (200, 32 + options_cursor*8, 12+((int)(realtime*4)&1));
 }
@@ -1160,9 +1150,6 @@
 		case 2:
 			Cbuf_AddText ("exec default.cfg\n");
 			break;
-		case 12:
-			M_Menu_Video_f ();
-			break;
 		default:
 			M_AdjustSliders (1);
 			break;
@@ -1192,8 +1179,7 @@
 		break;
 	}
 
-	if (options_cursor == 12 && vid_menudrawfn == NULL)
-	{
+	if(options_cursor == 12){
 		if (k == K_UPARROW)
 			options_cursor = 11;
 		else
@@ -1390,28 +1376,6 @@
 }
 
 //=============================================================================
-/* VIDEO MENU */
-
-void M_Menu_Video_f (void)
-{
-	key_dest = key_menu;
-	m_state = m_video;
-	m_entersound = true;
-}
-
-
-void M_Video_Draw (void)
-{
-	(*vid_menudrawfn) ();
-}
-
-
-void M_Video_Key (int key)
-{
-	(*vid_menukeyfn) (key);
-}
-
-//=============================================================================
 /* HELP MENU */
 
 int		help_page;
@@ -2867,7 +2831,6 @@
 	Cmd_AddCommand ("menu_setup", M_Menu_Setup_f);
 	Cmd_AddCommand ("menu_options", M_Menu_Options_f);
 	Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
-	Cmd_AddCommand ("menu_video", M_Menu_Video_f);
 	Cmd_AddCommand ("help", M_Menu_Help_f);
 	Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
 }
@@ -2935,10 +2898,6 @@
 		M_Keys_Draw ();
 		break;
 
-	case m_video:
-		M_Video_Draw ();
-		break;
-
 	case m_help:
 		M_Help_Draw ();
 		break;
@@ -3011,9 +2970,6 @@
 		break;
 	case m_keys:
 		M_Keys_Key(key);
-		break;
-	case m_video:
-		M_Video_Key(key);
 		break;
 	case m_help:
 		M_Help_Key(key);
--- a/model.c
+++ b/model.c
@@ -1310,25 +1310,13 @@
 void *
 Mod_LoadAliasSkin(void * pin, int *pskinindex, int skinsize, aliashdr_t *pheader)
 {
-	int i;
 	uchar *pskin, *pinskin;
-	ushort *pusskin;
 
-	pskin = Hunk_AllocName(skinsize * r_pixbytes, loadname);
+	pskin = Hunk_AllocName(skinsize, loadname);
 	pinskin = (uchar *)pin;
 	*pskinindex = (uchar *)pskin - (uchar *)pheader;
-
-	if(r_pixbytes == 1)
-		memcpy(pskin, pinskin, skinsize);
-	else if(r_pixbytes == 2){
-		pusskin = (ushort *)pskin;
-		for(i=0; i<skinsize; i++)
-			pusskin[i] = d_8to16table[pinskin[i]];
-	}else
-		fatal("Mod_LoadAliasSkin: invalid r_pixbytes: %d\n", r_pixbytes);
-
+	memcpy(pskin, pinskin, skinsize);
 	pinskin += skinsize;
-
 	return (void *)pinskin;
 }
 
@@ -1615,9 +1603,7 @@
 void *
 Mod_LoadSpriteFrame(void * pin, mspriteframe_t **ppframe)
 {
-	int i, width, height, size, origin[2];
-	ushort *ppixout;
-	uchar *ppixin;
+	int width, height, size, origin[2];
 	dspriteframe_t *pinframe;
 	mspriteframe_t *pspriteframe;
 
@@ -1627,7 +1613,7 @@
 	height = LittleLong(pinframe->height);
 	size = width * height;
 
-	pspriteframe = Hunk_AllocName(size*r_pixbytes + sizeof *pspriteframe, loadname);
+	pspriteframe = Hunk_AllocName(size + sizeof *pspriteframe, loadname);
 
 	memset(pspriteframe, 0, size + sizeof *pspriteframe);
 	*ppframe = pspriteframe;
@@ -1642,17 +1628,7 @@
 	pspriteframe->left = origin[0];
 	pspriteframe->right = width + origin[0];
 
-	if(r_pixbytes == 1)
-		memcpy(&pspriteframe->pixels[0], (uchar *)(pinframe + 1), size);
-	else if(r_pixbytes == 2){
-		ppixin = (uchar *)(pinframe + 1);
-		ppixout = (ushort *)&pspriteframe->pixels[0];
-
-		for(i=0 ; i<size ; i++)
-			ppixout[i] = d_8to16table[ppixin[i]];
-	}else
-		fatal("Mod_LoadSpriteFrame: invalid r_pixbytes: %d\n", r_pixbytes);
-
+	memcpy(&pspriteframe->pixels[0], (uchar *)(pinframe + 1), size);
 	return (void *)((byte *)pinframe + size + sizeof *pinframe);
 }
 
--- a/qk1.c
+++ b/qk1.c
@@ -119,6 +119,7 @@
 	if(n = COM_CheckParm("-mem"))
 		memsize = atoi(com_argv[n+1]) * KB;
 	membase = emalloc(memsize);
+	srand(getpid());
 	Host_Init();
 	t = dtime() - 1.0 / Fpsmax;
 	for(;;){
--- a/r_local.h
+++ b/r_local.h
@@ -116,12 +116,10 @@
 void R_TransformPlane (mplane_t *p, float *normal, float *dist);
 void R_TransformFrustum (void);
 void R_SetSkyFrame (void);
-void R_DrawSurfaceBlock16 (void);
 void R_DrawSurfaceBlock8 (void);
 texture_t *R_TextureAnimation (texture_t *base);
 
 void R_GenSkyTile (void *pdest);
-void R_GenSkyTile16 (void *pdest);
 void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags);
 void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel);
 
@@ -235,7 +233,6 @@
 extern	edge_t	edge_tail;
 extern	edge_t	edge_aftertail;
 extern int		r_bmodelactive;
-extern vrect_t	*pconupdate;
 
 extern float		aliasxscale, aliasyscale, aliasxcenter, aliasycenter;
 extern float		r_aliastransition, r_resfudge;
@@ -266,7 +263,6 @@
 extern qboolean	r_fov_greater_than_90;
 
 void R_StoreEfrags (efrag_t **ppefrag);
-void R_TimeRefresh_f (void);
 void R_TimeGraph (void);
 void R_PrintAliasStats (void);
 void R_PrintTimes (void);
--- a/r_main.c
+++ b/r_main.c
@@ -15,7 +15,6 @@
 qboolean	r_drawculledpolys;
 qboolean	r_worldpolysbacktofront;
 qboolean	r_recursiveaffinetriangles = true;
-int			r_pixbytes = 1;
 float		r_aliasuvscale = 1.0;
 int			r_outofsurfaces;
 int			r_outofedges;
@@ -170,8 +169,7 @@
 	r_stack_start = (byte *)&dummy;
 	
 	R_InitTurb ();
-	
-	Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);	
+
 	Cmd_AddCommand("pointfile", loadpoints);
 
 	Cvar_RegisterVariable (&r_draworder);
@@ -286,16 +284,12 @@
 	int		h;
 	float	size;
 
-	size = scr_viewsize.value > 100 ? 100 : scr_viewsize.value;
-	if (cl.intermission)
-	{
-		size = 100;
+	if(cl.intermission)
 		lineadj = 0;
-	}
-	size /= 100;
+	size = 1;
 
 	h = pvrectin->height - lineadj;
-	pvrect->width = pvrectin->width * size;
+	pvrect->width = pvrectin->width;
 	if (pvrect->width < 96)
 	{
 		size = 96.0 / pvrectin->width;
@@ -863,10 +857,6 @@
 
 	if (r_drawculledpolys)
 		R_ScanEdges ();
-
-// only the world can be drawn back to front with no z reads or compares, just
-// z writes, so have the driver turn z compares on now
-	D_TurnZOn ();
 
 	if (r_dspeeds.value)
 	{
--- a/r_misc.c
+++ b/r_misc.c
@@ -20,70 +20,8 @@
 	}
 }
 
-
 /*
-============
-Show
-
-Debugging use
-============
-*/
-void Show (void)
-{
-	vrect_t	vr;
-
-	vr.x = vr.y = 0;
-	vr.width = vid.width;
-	vr.height = vid.height;
-	vr.pnext = nil;
-	VID_Update (&vr);
-}
-
-
-/*
-====================
-R_TimeRefresh_f
-
-For program optimization
-====================
-*/
-void R_TimeRefresh_f (void)
-{
-	int			i;
-	float		start, stop, time;
-	int			startangle;
-	vrect_t		vr;
-
-	startangle = r_refdef.viewangles[1];
-	
-	start = dtime ();
-	for (i=0 ; i<128 ; i++)
-	{
-		r_refdef.viewangles[1] = i/128.0*360.0;
-
-		VID_LockBuffer ();
-
-		R_RenderView ();
-
-		VID_UnlockBuffer ();
-
-		vr.x = r_refdef.vrect.x;
-		vr.y = r_refdef.vrect.y;
-		vr.width = r_refdef.vrect.width;
-		vr.height = r_refdef.vrect.height;
-		vr.pnext = nil;
-		VID_Update (&vr);
-	}
-	stop = dtime ();
-	time = stop-start;
-	Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
-	
-	r_refdef.viewangles[1] = startangle;
-}
-
-
-/*
-================
+================
 R_LineGraph
 
 Only called by R_DisplayTime
@@ -242,7 +180,7 @@
 		}
 	}
 	
-	VID_ShiftPalette (newpalette);
+	setpal(newpalette);
 }
 
 
--- a/r_sky.c
+++ b/r_sky.c
@@ -193,48 +193,6 @@
 	}
 }
 
-
-/*
-=================
-R_GenSkyTile16
-=================
-*/
-void R_GenSkyTile16 (void *pdest)
-{
-	int				x, y;
-	int				ofs, baseofs;
-	int				xshift, yshift;
-	byte			*pnewsky;
-	unsigned short	*pd;
-
-	xshift = skytime * skyspeed;
-	yshift = skytime * skyspeed;
-
-	pnewsky = (byte *)&newsky[0];
-	pd = (unsigned short *)pdest;
-
-	for (y=0 ; y<SKYSIZE ; y++)
-	{
-		baseofs = ((y+yshift) & SKYMASK) * 131;
-
-// FIXME: clean this up
-// FIXME: do faster unaligned version?
-		for (x=0 ; x<SKYSIZE ; x++)
-		{
-			ofs = baseofs + ((x+xshift) & SKYMASK);
-
-			*pd = d_8to16table[(*(pnewsky + 128) &
-					*(byte *)&bottommask[ofs]) |
-					*(byte *)&bottomsky[ofs]];
-			pnewsky++;
-			pd++;
-		}
-
-		pnewsky += TILE_SIZE;
-	}
-}
-
-
 /*
 =============
 R_SetSkyFrame
--- a/r_surf.c
+++ b/r_surf.c
@@ -244,20 +244,9 @@
 	r_numhblocks = r_drawsurf.surfwidth >> blockdivshift;
 	r_numvblocks = r_drawsurf.surfheight >> blockdivshift;
 
-//==============================
-
-	if (r_pixbytes == 1)
-	{
-		pblockdrawer = surfmiptable[r_drawsurf.surfmip];
+	pblockdrawer = surfmiptable[r_drawsurf.surfmip];
 	// TODO: only needs to be set when there is a display settings change
-		horzblockstep = blocksize;
-	}
-	else
-	{
-		pblockdrawer = R_DrawSurfaceBlock16;
-	// TODO: only needs to be set when there is a display settings change
-		horzblockstep = blocksize << 1;
-	}
+	horzblockstep = blocksize;
 
 	smax = mt->width >> r_drawsurf.surfmip;
 	twidth = texwidth;
@@ -497,59 +486,8 @@
 	}
 }
 
-
 /*
 ================
-R_DrawSurfaceBlock16
-
-FIXME: make this work
-================
-*/
-void R_DrawSurfaceBlock16 (void)
-{
-	int				k;
-	unsigned char	*psource;
-	int				lighttemp, lightstep, light;
-	unsigned short	*prowdest;
-
-	prowdest = (unsigned short *)prowdestbase;
-
-	for (k=0 ; k<blocksize ; k++)
-	{
-		unsigned short	*pdest;
-		unsigned char	pix;
-		int				b;
-
-		psource = pbasesource;
-		lighttemp = lightright - lightleft;
-		lightstep = lighttemp >> blockdivshift;
-
-		light = lightleft;
-		pdest = prowdest;
-
-		for (b=0; b<blocksize; b++)
-		{
-			pix = *psource;
-			*pdest = vid.colormap16[(light & 0xFF00) + pix];
-			psource += sourcesstep;
-			pdest++;
-			light += lightstep;
-		}
-
-		pbasesource += sourcetstep;
-		lightright += lightrightstep;
-		lightleft += lightleftstep;
-		prowdest = (ushort *)((uintptr)prowdest + surfrowbytes);
-	}
-
-	prowdestbase = prowdest;
-}
-
-
-//============================================================================
-
-/*
-================
 R_GenTurbTile
 ================
 */
@@ -573,67 +511,15 @@
 	}
 }
 
-
-/*
-================
-R_GenTurbTile16
-================
-*/
-void R_GenTurbTile16 (pixel_t *pbasetex, void *pdest)
+void
+R_GenTile(msurface_t *psurf, void *pdest)
 {
-	int				*turb;
-	int				i, j, s, t;
-	unsigned short	*pd;
-
-	turb = sintable + ((int)(cl.time*SPEED)&(CYCLE-1));
-	pd = (unsigned short *)pdest;
-
-	for (i=0 ; i<TILE_SIZE ; i++)
-	{
-		for (j=0 ; j<TILE_SIZE ; j++)
-		{	
-			s = (((j << 16) + turb[i & (CYCLE-1)]) >> 16) & 63;
-			t = (((i << 16) + turb[j & (CYCLE-1)]) >> 16) & 63;
-			*pd++ = d_8to16table[*(pbasetex + (t<<6) + s)];
-		}
-	}
-}
-
-
-/*
-================
-R_GenTile
-================
-*/
-void R_GenTile (msurface_t *psurf, void *pdest)
-{
-	if (psurf->flags & SURF_DRAWTURB)
-	{
-		if (r_pixbytes == 1)
-		{
-			R_GenTurbTile ((pixel_t *)
-				((byte *)psurf->texinfo->texture + psurf->texinfo->texture->offsets[0]), pdest);
-		}
-		else
-		{
-			R_GenTurbTile16 ((pixel_t *)
-				((byte *)psurf->texinfo->texture + psurf->texinfo->texture->offsets[0]), pdest);
-		}
-	}
-	else if (psurf->flags & SURF_DRAWSKY)
-	{
-		if (r_pixbytes == 1)
-		{
-			R_GenSkyTile (pdest);
-		}
-		else
-		{
-			R_GenSkyTile16 (pdest);
-		}
-	}
+	if(psurf->flags & SURF_DRAWTURB){
+		R_GenTurbTile((pixel_t *)
+			((byte *)psurf->texinfo->texture
+			+ psurf->texinfo->texture->offsets[0]), pdest);
+	}else if(psurf->flags & SURF_DRAWSKY)
+		R_GenSkyTile(pdest);
 	else
-	{
-		fatal ("Unknown tile type");
-	}
+		fatal("Unknown tile type");
 }
-
--- a/screen.c
+++ b/screen.c
@@ -34,7 +34,6 @@
 
 viddef_t	vid;				// global video state
 
-vrect_t		*pconupdate;
 vrect_t		scr_vrect;
 
 qboolean	scr_disabled_for_loading;
@@ -211,8 +210,8 @@
 //========================================
 	
 // bound viewsize
-	if (scr_viewsize.value < 30)
-		setcvar ("viewsize","30");
+	if (scr_viewsize.value < 100)
+		setcvar ("viewsize","100");
 	if (scr_viewsize.value > 120)
 		setcvar ("viewsize","120");
 
@@ -620,7 +619,7 @@
 		SCR_UpdateScreen ();
 
 	cl.cshifts[0].percent = 0;		// no area contents palette on next frame
-	VID_SetPalette (host_basepal);
+	setpal(host_basepal);
 }
 
 
@@ -637,9 +636,7 @@
 */
 void SCR_UpdateScreen (void)
 {
-	static float	oldscr_viewsize;
 	static float	oldlcd_x;
-	vrect_t		vrect;
 	
 	if (scr_skipupdate || block_drawing)
 		return;
@@ -663,12 +660,6 @@
 
 	if (!scr_initialized || !con_initialized)
 		return;				// not initialized yet
-
-	if (scr_viewsize.value != oldscr_viewsize)
-	{
-		oldscr_viewsize = scr_viewsize.value;
-		vid.recalc_refdef = 1;
-	}
 	
 //
 // check for vid changes
@@ -700,8 +691,6 @@
 //
 // do 3D refresh drawing, and then update the screen
 //
-	D_EnableBackBufferAccess ();	// of all overlay stuff if drawing directly
-
 	if (scr_fullupdate++ < vid.numpages)
 	{	// clear the entire screen
 		scr_copyeverything = 1;
@@ -708,24 +697,12 @@
 		Draw_TileClear (0,0,vid.width,vid.height);
 		Sbar_Changed ();
 	}
-
-	pconupdate = nil;
-
-
 	SCR_SetUpToDrawConsole ();
 	SCR_EraseCenterString ();
-
-	D_DisableBackBufferAccess ();	// for adapters that can't stay mapped in
 									//  for linear writes all the time
 
-	VID_LockBuffer ();
-
 	V_RenderView ();
 
-	VID_UnlockBuffer ();
-
-	D_EnableBackBufferAccess ();	// of all overlay stuff if drawing directly
-
 	if (scr_drawdialog)
 	{
 		Sbar_Draw ();
@@ -762,60 +739,8 @@
 		SCR_DrawConsole ();
 		M_Draw ();
 	}
-
-	D_DisableBackBufferAccess ();	// for adapters that can't stay mapped in
-									//  for linear writes all the time
-	if (pconupdate)
-	{
-		D_UpdateRects (pconupdate);
-	}
-
 	V_UpdatePalette ();
 
-//
-// update one of three areas
-//
-
-	if (scr_copyeverything)
-	{
-		vrect.x = 0;
-		vrect.y = 0;
-		vrect.width = vid.width;
-		vrect.height = vid.height;
-		vrect.pnext = 0;
-	
-		VID_Update (&vrect);
-	}
-	else if (scr_copytop)
-	{
-		vrect.x = 0;
-		vrect.y = 0;
-		vrect.width = vid.width;
-		vrect.height = vid.height - sb_lines;
-		vrect.pnext = 0;
-	
-		VID_Update (&vrect);
-	}	
-	else
-	{
-		vrect.x = scr_vrect.x;
-		vrect.y = scr_vrect.y;
-		vrect.width = scr_vrect.width;
-		vrect.height = scr_vrect.height;
-		vrect.pnext = 0;
-	
-		VID_Update (&vrect);
-	}
-}
-
-
-/*
-==================
-SCR_UpdateWholeScreen
-==================
-*/
-void SCR_UpdateWholeScreen (void)
-{
-	scr_fullupdate = 0;
-	SCR_UpdateScreen ();
+	flipfb(scr_copyeverything ? vid.height :
+		scr_copytop ? vid.height-sb_lines : scr_vrect.height);
 }
--- a/screen.h
+++ b/screen.h
@@ -23,8 +23,6 @@
 extern	qboolean	scr_disabled_for_loading;
 extern	qboolean	scr_skipupdate;
 
-extern	cvar_t		scr_viewsize;
-
 extern cvar_t scr_viewsize;
 
 // only the refresh window will be updated unless these variables are flagged 
@@ -32,5 +30,3 @@
 extern	int			scr_copyeverything;
 
 extern qboolean		block_drawing;
-
-void SCR_UpdateWholeScreen (void);
--- a/vid.c
+++ b/vid.c
@@ -10,107 +10,40 @@
 int dumpwin;
 Point center;		/* of window */
 Rectangle grabr;
-int d_con_indirect;
-void (*vid_menudrawfn)(void);
-void (*vid_menukeyfn)(int key);
 
-typedef u32int px24;
-px24 st2d_8to24table[256];
-ushort d_8to16table[256];
+static int fbpal[256];
+static uchar *fb;
+static Image *fbi;
 
-enum{
-	Rmask	= 0xff0000,
-	Gmask	= 0xff00,
-	Bmask	= 0xff
-};
-static int shifton;
-static int rshift;
-static int gshift;
-static int bshift;
-static uchar *framebuf;	/* draw buffer */
-static Image *fbim;	/* framebuf image */
-
-
 static void
-mkmasks(void)
+drawfb(int dy)
 {
-	uint x;
+	uchar *s;
+	int n, we, w8, wr, *d;
 
-	for(rshift = -8, x = 1; x < Rmask; x <<= 1)
-		rshift++;
-	for(gshift = -8, x = 1; x < Gmask; x <<= 1)
-		gshift++;
-	for(bshift = -8, x = 1; x < Bmask; x <<= 1)
-		bshift++;
-	shifton = 1;
-}
-
-static px24
-rgb24(int r, int g, int b)
-{
-	px24 p = 0;
-
-	if(!shifton)
-		mkmasks();
-
-	if(rshift > 0)
-		p = r<<rshift & Rmask;
-	else if(rshift < 0)
-		p = r>>-rshift & Rmask;
-	else
-		p |= r & Rmask;
-	if(gshift > 0)
-		p |= g<<gshift & Gmask;
-	else if(gshift < 0)
-		p |= g>>-gshift & Gmask;
-	else
-		p |= g & Gmask;
-	if(bshift > 0)
-		p |= b<<bshift & Bmask;
-	else if(bshift < 0)
-		p |= b>>-bshift & Bmask;
-	else
-		p |= b & Bmask;
-	return p;
-}
-
-static void
-st3_fixup(uchar *data, int x, int y, int width, int height)
-{
-	int yi;
-	uchar *src;
-	px24 *dest;
-	register int count, n;
-
-	if(x < 0 || y < 0)
-		return;
-
-	for(yi = y; yi < y+height; yi++){
-		src = &data[yi*vid.rowbytes];
-
-		// Duff's Device
-		count = width;
-		n = (count+7) / 8;
-		dest = ((px24 *)src) + x+width-1;
-		src += x+width-1;
-
-		switch(count % 8){
-		case 0:	do{	*dest-- = st2d_8to24table[*src--];
-		case 7:		*dest-- = st2d_8to24table[*src--];
-		case 6:		*dest-- = st2d_8to24table[*src--];
-		case 5:		*dest-- = st2d_8to24table[*src--];
-		case 4:		*dest-- = st2d_8to24table[*src--];
-		case 3:		*dest-- = st2d_8to24table[*src--];
-		case 2:		*dest-- = st2d_8to24table[*src--];
-		case 1:		*dest-- = st2d_8to24table[*src--];
+	we = vid.width - 1;
+	w8 = vid.width + 7 >> 3;
+	wr = vid.width % 8;
+	dy *= vid.rowbytes;
+	while((dy -= vid.rowbytes) >= 0){
+		s = fb + dy;
+		d = ((int *)s) + we;
+		s += we;
+		n = w8;
+		switch(wr){
+		case 0:	do{	*d-- = fbpal[*s--];
+		case 7:		*d-- = fbpal[*s--];
+		case 6:		*d-- = fbpal[*s--];
+		case 5:		*d-- = fbpal[*s--];
+		case 4:		*d-- = fbpal[*s--];
+		case 3:		*d-- = fbpal[*s--];
+		case 2:		*d-- = fbpal[*s--];
+		case 1:		*d-- = fbpal[*s--];
 			}while(--n > 0);
 		}
-		//for(xi = x+width-1; xi >= x; xi--)
-		//	dest[xi] = st2d_8to24table[src[xi]];
 	}
 }
 
-/* vid.height and vid.width must be set correctly before this call */
 static void
 resetfb(void)
 {
@@ -119,6 +52,8 @@
 	int hunkvbuf, scachesz;
 	Point p;
 
+	vid.width = Dx(screen->r);
+	vid.height = Dy(screen->r);
 	if(d_pzbuffer != nil){
 		D_FlushCaches();
 		Hunk_FreeToHighMark(highhunk);
@@ -135,7 +70,7 @@
 	surfcache = (byte *)d_pzbuffer + vid.width * vid.height * sizeof *d_pzbuffer;
 	D_InitCaches(surfcache, scachesz);
 
-	vid.rowbytes = vid.width * 32/8;
+	vid.rowbytes = vid.width * sizeof *fbpal;
 	vid.aspect = (float)vid.height / (float)vid.width * (320.0/240.0);
 	vid.conrowbytes = vid.rowbytes;
 	vid.conwidth = vid.width;
@@ -144,60 +79,16 @@
 	center = addpt(screen->r.min, Pt(vid.width/2, vid.height/2));
 	p = Pt(vid.width/4, vid.height/4);
 	grabr = Rpt(subpt(center, p), addpt(center, p));
-	freeimage(fbim);
-	free(framebuf);
-	fbim = allocimage(display, Rect(0,0,vid.width,vid.height), XRGB32, 0, 0);
-	if(fbim == nil)
+	freeimage(fbi);
+	free(fb);
+	fbi = allocimage(display, Rect(0,0,vid.width,vid.height), XRGB32, 0, 0);
+	if(fbi == nil)
 		sysfatal("resetfb: %r");
-	framebuf = emalloc(vid.width * vid.height * 32/8 * sizeof *framebuf);
-	vid.buffer = framebuf;
-	vid.conbuffer = framebuf;
+	fb = emalloc(vid.rowbytes * vid.height * sizeof *fb);
+	vid.buffer = fb;
+	vid.conbuffer = fb;
 }
 
-// Called at startup to set up translation tables, takes 256 8 bit RGB values
-// the palette data will go away after the call, so it must be copied off if
-// the video driver will need it again
-void
-VID_Init(uchar */*palette*/)
-{
-	vid.maxwarpwidth = WARP_WIDTH;
-	vid.maxwarpheight = WARP_HEIGHT;
-	vid.numpages = 2;
-	vid.colormap = host_colormap;
-	vid.fullbright = 256 - LittleLong(*((int *)vid.colormap + 2048));
-
-	srand(getpid());
-
-	if(initdraw(nil, nil, "quake") < 0)
-		sysfatal("initdraw: %r\n");
-	vid.width = Dx(screen->r);
-	vid.height = Dy(screen->r);
-	resetfb();
-	vid.direct = 0;
-}
-
-void
-VID_ShiftPalette(uchar *p)
-{
-	VID_SetPalette(p);
-}
-
-void
-VID_SetPalette(uchar *palette)
-{
-	int i;
-
-	for(i = 0; i < 256; i++)
-		st2d_8to24table[i] = rgb24(palette[i*3], palette[i*3+1], palette[i*3+2]);
-}
-
-void
-VID_Shutdown(void)
-{
-	free(framebuf);
-	freeimage(fbim);
-}
-
 /* only exists to allow taking tear-free screenshots ingame... */
 static int
 writebit(void)
@@ -216,7 +107,7 @@
 	}
 	if(fd = create(s, OWRITE, 0644), fd < 0)
 		return -1;
-	n = writeimage(fd, fbim, 0);
+	n = writeimage(fd, fbi, 0);
 	close(fd);
 	if(n >= 0)
 		Con_Printf("Wrote %s\n", s);
@@ -223,16 +114,13 @@
 	return n;
 }
 
-/* flush given rectangles from view buffer to the screen */
 void
-VID_Update(vrect_t *rects)
+flipfb(int dy)
 {
 	if(resized){		/* skip this frame if window resize */
 		resized = 0;
 		if(getwindow(display, Refnone) < 0)
 			sysfatal("getwindow: %r");
-		vid.width = Dx(screen->r);
-		vid.height = Dy(screen->r);
 		resetfb();
 		vid.recalc_refdef = 1;	/* force a surface cache flush */
 		Con_CheckResize();
@@ -239,15 +127,10 @@
 		Con_Clear_f();
 		return;
 	}
-
-	scr_fullupdate = 0;	/* force full update if not 8bit (cf. screen.h) */
-
-	while(rects != nil){
-		st3_fixup(framebuf, rects->x, rects->y, rects->width, rects->height);
-		rects = rects->pnext;
-	}
-	loadimage(fbim, fbim->r, framebuf, vid.height * vid.rowbytes);
-	draw(screen, screen->r, fbim, nil, ZP);
+	drawfb(dy);
+	loadimage(fbi, Rect(0,0,vid.width,dy), fb, dy * vid.rowbytes);
+	draw(screen, Rpt(screen->r.min, Pt(screen->r.max.x,
+		screen->r.max.y - vid.height + dy)), fbi, nil, ZP);
 	flushimage(display, 1);
 	if(dumpwin){
 		if(writebit() < 0)
@@ -256,15 +139,25 @@
 	}
 }
 
-/* direct drawing of the "accessing disk" icon */
 void
-D_BeginDirectRect(int x, int y, byte *pbitmap, int width, int height)
+setpal(uchar *p)
 {
-	USED(x, y, pbitmap, width, height);
+	int *fp;
+
+	for(fp=fbpal; fp<fbpal+nelem(fbpal); p+=3)
+		*fp++ = p[0] << 16 | p[1] << 8 | p[2];
+	scr_fullupdate = 0;
 }
 
 void
-D_EndDirectRect(int x, int y, int width, int height)
+initfb(void)
 {
-	USED(x, y, width, height);
+	vid.maxwarpwidth = WARP_WIDTH;
+	vid.maxwarpheight = WARP_HEIGHT;
+	vid.numpages = 2;
+	vid.colormap = host_colormap;
+	vid.fullbright = 256 - LittleLong(*((int *)vid.colormap + 2048));
+	if(initdraw(nil, nil, "quake") < 0)
+		sysfatal("initdraw: %r\n");
+	resetfb();
 }
--- a/vid.h
+++ b/vid.h
@@ -35,24 +35,3 @@
 } viddef_t;
 
 extern	viddef_t	vid;				// global video state
-extern	unsigned short	d_8to16table[256];
-extern	unsigned	d_8to24table[256];
-extern void (*vid_menudrawfn)(void);
-extern void (*vid_menukeyfn)(int key);
-
-void	VID_SetPalette (uchar *palette);
-// called at startup and after any gamma correction
-
-void	VID_ShiftPalette (uchar *palette);
-// called for bonus and pain flashes, and for underwater color changes
-
-void	VID_Init (uchar *palette);
-// Called at startup to set up translation tables, takes 256 8 bit RGB values
-// the palette data will go away after the call, so it must be copied off if
-// the video driver will need it again
-
-void	VID_Shutdown (void);
-// Called at shutdown
-
-void	VID_Update (vrect_t *rects);
-// flushes the given rectangles from the view buffer to the screen
--- a/view.c
+++ b/view.c
@@ -517,8 +517,7 @@
 		newpal[2] = gammatable[b];
 		newpal += 3;
 	}
-
-	VID_ShiftPalette (pal);	
+	setpal(pal);	
 }
 
 
@@ -786,10 +785,6 @@
 		view->origin[2] += 1;
 	else if (scr_viewsize.value == 100)
 		view->origin[2] += 2;
-	else if (scr_viewsize.value == 90)
-		view->origin[2] += 1;
-	else if (scr_viewsize.value == 80)
-		view->origin[2] += 0.5;
 
 	view->model = cl.model_precache[cl.stats[STAT_WEAPON]];
 	view->frame = cl.stats[STAT_WEAPONFRAME];