shithub: qk1

Download patch

ref: bf5f906a21121a00f6b264c90539392d4a68e3ba
parent: 47eca22c0a296502f838d1b3676b0cd8f5ba57b9
author: Konstantinn Bonnet <qu7uux@gmail.com>
date: Wed Jan 28 16:36:00 EST 2015

remove more 386 code, id368 cppdef

--- a/README
+++ b/README
@@ -3,18 +3,22 @@
 Does not work. Nothing to see here, move along.
 
 builds only with p9p on linux/386 and amd64; bugged to hell.
+actually, untested on 386, because linux crosscompiling and p9p on not-OSX.
+
 plan9 shit missing completely, asm not ungccfied.
 
 intrusive changes:
 	- pr_strings: assumed 32bit pointer arithmetic: use PR_GetStr() instead of
 	  dealing with it directly; may be ass
+	- global cppdefotomy
 
+
 bugs
 ----
 	- compile with PARANOID -> MSG_WriteByte complains about range error and
-	  exits.  no idea why. (386/amd64)
-	- new game while already ingame -> R_RenderView: called without enough
-	  stack
+	  exits. no idea why. (386/amd64)
+	- new game while already ingame -> front falls off (amd64)
+		. most of the time: exit with R_RenderView: called without enough stack
 
 
 legal
--- a/d_init.c
+++ b/d_init.c
@@ -128,15 +128,7 @@
 	for (i=0 ; i<(NUM_MIPS-1) ; i++)
 		d_scalemip[i] = basemip[i] * d_mipscale.value;
 
-#ifdef	id386
-				if (d_subdiv16.value)
-					d_drawspans = D_DrawSpans16;
-				else
-					d_drawspans = D_DrawSpans8;
-#endif
-#ifndef id386
-				d_drawspans = D_DrawSpans8;
-#endif
+	d_drawspans = D_DrawSpans8;
 
 	d_aflatcolor = 0;
 }
--- a/d_local.h
+++ b/d_local.h
@@ -66,11 +66,6 @@
 
 extern int D_MipLevelForScale (float scale);
 
-#ifdef id386
-extern void D_PolysetAff8Start (void);
-extern void D_PolysetAff8End (void);
-#endif
-
 extern short *d_pzbuffer;
 extern unsigned int d_zrowbytes, d_zwidth;
 
--- a/d_modech.c
+++ b/d_modech.c
@@ -19,18 +19,6 @@
 */
 void D_Patch (void)
 {
-#ifdef id386
-
-	static qboolean protectset8 = false;
-
-	if (!protectset8)
-	{
-		Sys_MakeCodeWriteable ((int)D_PolysetAff8Start,
-						     (int)D_PolysetAff8End - (int)D_PolysetAff8Start);
-		protectset8 = true;
-	}
-
-#endif	// id386
 }
 
 
--- a/d_part.c
+++ b/d_part.c
@@ -28,8 +28,6 @@
 }
 
 
-#ifndef	id386
-
 /*
 ==============
 D_DrawParticle
@@ -185,6 +183,3 @@
 		break;
 	}
 }
-
-#endif	// !id386
-
--- a/d_polyse.c
+++ b/d_polyse.c
@@ -98,8 +98,6 @@
 void D_RasterizeAliasPolySmooth (void);
 void D_PolysetScanLeftEdge (int height);
 
-#ifndef	id386
-
 /*
 ================
 D_PolysetDraw
@@ -369,9 +367,7 @@
 	D_PolysetRecursiveTriangle (lp3, new, lp2);
 }
 
-#endif	// !id386
 
-
 /*
 ================
 D_PolysetUpdateTables
@@ -393,9 +389,6 @@
 	}
 }
 
-
-#ifndef	id386
-
 /*
 ===================
 D_PolysetScanLeftEdge
@@ -462,9 +455,7 @@
 	} while (--height);
 }
 
-#endif	// !id386
 
-
 /*
 ===================
 D_PolysetSetUpForLineScan
@@ -504,8 +495,6 @@
 }
 
 
-#ifndef id386
-
 /*
 ================
 D_PolysetCalcGradients
@@ -556,21 +545,12 @@
 	r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
 			ystepdenominv);
 
-#ifdef	id386
-	a_sstepxfrac = r_sstepx << 16;
-	a_tstepxfrac = r_tstepx << 16;
-#endif
-#ifndef id386
 	a_sstepxfrac = r_sstepx & 0xFFFF;
 	a_tstepxfrac = r_tstepx & 0xFFFF;
-#endif
-
 	a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
 }
 
-#endif	// !id386
 
-
 /*
 byte gelmap[256];
 void InitGel (byte *palette)
@@ -588,8 +568,6 @@
 */
 
 
-#ifndef	id386
-
 /*
 ================
 D_PolysetDrawSpans8
@@ -658,7 +636,6 @@
 		pspanpackage++;
 	} while (pspanpackage->count != -999999);
 }
-#endif	// !id386
 
 
 /*
@@ -738,14 +715,8 @@
 
 	d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) +
 			(plefttop[3] >> 16) * r_affinetridesc.skinwidth;
-#ifdef	id386
-	d_sfrac = (plefttop[2] & 0xFFFF) << 16;
-	d_tfrac = (plefttop[3] & 0xFFFF) << 16;
-#endif
-#ifndef id386
 	d_sfrac = plefttop[2] & 0xFFFF;
 	d_tfrac = plefttop[3] & 0xFFFF;
-#endif
 	d_light = plefttop[4];
 	d_zi = plefttop[5];
 
@@ -774,15 +745,8 @@
 		D_PolysetSetUpForLineScan(plefttop[0], plefttop[1],
 							  pleftbottom[0], pleftbottom[1]);
 
-	#ifdef	id386
-		d_pzbasestep = (d_zwidth + ubasestep) << 1;
-		d_pzextrastep = d_pzbasestep + 2;
-	#endif
-	#ifndef id386
 		d_pzbasestep = d_zwidth + ubasestep;
 		d_pzextrastep = d_pzbasestep + 1;
-	#endif
-
 		d_pdestbasestep = screenwidth + ubasestep;
 		d_pdestextrastep = d_pdestbasestep + 1;
 
@@ -800,14 +764,8 @@
 		d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
 				((r_tstepy + r_tstepx * ubasestep) >> 16) *
 				r_affinetridesc.skinwidth;
-	#ifdef	id386
-		d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) << 16;
-		d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) << 16;
-	#endif
-	#ifndef id386
 		d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
 		d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) & 0xFFFF;
-	#endif
 		d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
 		d_zibasestep = r_zistepy + r_zistepx * ubasestep;
 
@@ -814,14 +772,8 @@
 		d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
 				((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
 				r_affinetridesc.skinwidth;
-	#ifdef	id386
-		d_sfracextrastep = (r_sstepy + r_sstepx*d_countextrastep) << 16;
-		d_tfracextrastep = (r_tstepy + r_tstepx*d_countextrastep) << 16;
-	#endif
-	#ifndef id386
 		d_sfracextrastep = (r_sstepy + r_sstepx*d_countextrastep) & 0xFFFF;
 		d_tfracextrastep = (r_tstepy + r_tstepx*d_countextrastep) & 0xFFFF;
-	#endif
 		d_lightextrastep = d_lightbasestep + working_lstepx;
 		d_ziextrastep = d_zibasestep + r_zistepx;
 
@@ -877,15 +829,8 @@
 
 			d_pdestbasestep = screenwidth + ubasestep;
 			d_pdestextrastep = d_pdestbasestep + 1;
-
-	#ifdef	id386
-			d_pzbasestep = (d_zwidth + ubasestep) << 1;
-			d_pzextrastep = d_pzbasestep + 2;
-	#endif
-	#ifndef id386
 			d_pzbasestep = d_zwidth + ubasestep;
 			d_pzextrastep = d_pzbasestep + 1;
-	#endif
 
 			if (ubasestep < 0)
 				working_lstepx = r_lstepx - 1;
@@ -896,14 +841,8 @@
 			d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
 					((r_tstepy + r_tstepx * ubasestep) >> 16) *
 					r_affinetridesc.skinwidth;
-	#ifdef	id386
-			d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) << 16;
-			d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) << 16;
-	#endif
-	#ifndef id386
 			d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
 			d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) & 0xFFFF;
-	#endif
 			d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
 			d_zibasestep = r_zistepy + r_zistepx * ubasestep;
 
@@ -910,14 +849,8 @@
 			d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
 					((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
 					r_affinetridesc.skinwidth;
-	#ifdef	id386
-			d_sfracextrastep = ((r_sstepy+r_sstepx*d_countextrastep) & 0xFFFF)<<16;
-			d_tfracextrastep = ((r_tstepy+r_tstepx*d_countextrastep) & 0xFFFF)<<16;
-	#endif
-	#ifndef id386
 			d_sfracextrastep = (r_sstepy+r_sstepx*d_countextrastep) & 0xFFFF;
 			d_tfracextrastep = (r_tstepy+r_tstepx*d_countextrastep) & 0xFFFF;
-	#endif
 			d_lightextrastep = d_lightbasestep + working_lstepx;
 			d_ziextrastep = d_zibasestep + r_zistepx;
 
--- a/d_scan.c
+++ b/d_scan.c
@@ -73,8 +73,6 @@
 }
 
 
-#ifndef	id386
-
 /*
 =============
 D_DrawTurbulent8Span
@@ -94,9 +92,7 @@
 	} while (--r_turb_spancount > 0);
 }
 
-#endif	// !id386
 
-
 /*
 =============
 Turbulent8
@@ -230,8 +226,6 @@
 }
 
 
-#ifndef	id386
-
 /*
 =============
 D_DrawSpans8
@@ -365,11 +359,7 @@
 	} while ((pspan = pspan->pnext) != NULL);
 }
 
-#endif
 
-
-#ifndef	id386
-
 /*
 =============
 D_DrawZSpans
@@ -427,6 +417,3 @@
 
 	} while ((pspan = pspan->pnext) != NULL);
 }
-
-#endif
-
--- a/d_sprite.c
+++ b/d_sprite.c
@@ -10,8 +10,6 @@
 static int		minindex, maxindex;
 static sspan_t	*sprite_spans;
 
-#ifndef id386
-
 /*
 =====================
 D_SpriteDrawSpans
@@ -170,8 +168,6 @@
 
 	} while (pspan->count != DS_SPAN_LIST_END);
 }
-
-#endif
 
 
 /*
--- a/d_vars.c
+++ b/d_vars.c
@@ -1,7 +1,5 @@
 // r_vars.c: global refresh variables
 
-#ifndef	id386
-
 #include <u.h>
 #include <libc.h>
 #include	"quakedef.h"
@@ -28,6 +26,3 @@
 short			*d_pzbuffer;
 unsigned int	d_zrowbytes;
 unsigned int	d_zwidth;
-
-#endif	// !id386
-
--- a/mathlib.c
+++ b/mathlib.c
@@ -150,8 +150,6 @@
 }
 
 
-#ifndef	id386
-
 /*
 ==================
 BoxOnPlaneSide
@@ -259,9 +257,7 @@
 	return sides;
 }
 
-#endif // !id386
 
-
 void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
 {
 	float		angle;
@@ -534,8 +530,6 @@
 }
 
 
-#ifndef	id386
-
 // TODO: move to nonintel.c
 
 /*
@@ -554,5 +548,3 @@
 	return (fixed16_t)
 			(((double)0x10000 * (double)0x1000000 / (double)val) + 0.5);
 }
-
-#endif // !id386
--- a/mkfile
+++ b/mkfile
@@ -69,8 +69,8 @@
 	sv_phys.o\
 	sv_move.o\
 	sv_user.o\
-	zone.o	\
-	view.o	\
+	zone.o\
+	view.o\
 	wad.o\
 	world.o\
 	cd_linux.o\
--- a/nonintel.c
+++ b/nonintel.c
@@ -8,8 +8,6 @@
 #include "r_local.h"
 #include "d_local.h"
 
-#ifndef	id386
-
 /*
 ================
 R_Surf8Patch
@@ -41,7 +39,3 @@
 {
 	// we only patch code on Intel
 }
-
-
-#endif	// !id386
-
--- a/quakedef.h
+++ b/quakedef.h
@@ -19,11 +19,7 @@
 #define	VID_LockBuffer()
 #define	VID_UnlockBuffer()
 
-#ifdef __i386__ // && !defined __sun__
-#define id386
-#endif
-
-#ifdef id386
+#ifdef __id386__
 #define UNALIGNED_OK	// unset if unaligned accesses are not supported
 #endif
 
--- a/r_aclip.c
+++ b/r_aclip.c
@@ -75,8 +75,6 @@
 }
 
 
-#ifndef	id386
-
 void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
 {
 	float		scale;
@@ -167,8 +165,6 @@
 			out->v[i] = pfv1->v[i] + (pfv0->v[i] - pfv1->v[i])*scale + 0.5;
 	}
 }
-
-#endif // !id386
 
 
 int R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
--- a/r_alias.c
+++ b/r_alias.c
@@ -432,8 +432,6 @@
 }
 
 
-#ifndef	id386
-
 /*
 ================
 R_AliasTransformAndProjectFinalVerts
@@ -486,9 +484,7 @@
 	}
 }
 
-#endif //!id386
 
-
 /*
 ================
 R_AliasProjectFinalVert
@@ -711,15 +707,7 @@
 			r_recursiveaffinetriangles;
 
 	if (r_affinetridesc.drawtype)
-	{
 		D_PolysetUpdateTables ();		// FIXME: precalc...
-	}
-	else
-	{
-#ifdef	id386
-		D_Aff8Patch (currententity->colormap);
-#endif
-	}
 
 	acolormap = currententity->colormap;
 
@@ -733,4 +721,3 @@
 	else
 		R_AliasPreparePoints ();
 }
-
--- a/r_draw.c
+++ b/r_draw.c
@@ -50,8 +50,6 @@
 qboolean	r_lastvertvalid;
 
 
-#ifndef	id386
-
 /*
 ================
 R_EmitEdge
@@ -331,8 +329,6 @@
 // add the edge
 	R_EmitEdge (pv0, pv1);
 }
-
-#endif	// !id386
 
 
 /*
--- a/r_edge.c
+++ b/r_edge.c
@@ -138,8 +138,6 @@
 }
 
 
-#ifndef	id386
-
 /*
 ==============
 R_InsertNewEdges
@@ -181,11 +179,7 @@
 	} while ((edgestoadd = next_edge) != NULL);
 }
 
-#endif	// !id386
-	
 
-#ifndef id386
-
 /*
 ==============
 R_RemoveEdges
@@ -201,11 +195,7 @@
 	} while ((pedge = pedge->nextremove) != NULL);
 }
 
-#endif	// !id386
 
-
-#ifndef	id386
-
 /*
 ==============
 R_StepActiveU
@@ -271,9 +261,7 @@
 	}
 }
 
-#endif	// !id386
 
-
 /*
 ==============
 R_CleanupSpan
@@ -430,8 +418,6 @@
 }
 
 
-#ifndef	id386
-
 /*
 ==============
 R_LeadingEdge
@@ -595,8 +581,6 @@
 
 	R_CleanupSpan ();
 }
-
-#endif	// !id386
 
 
 /*
--- a/r_local.h
+++ b/r_local.h
@@ -120,15 +120,6 @@
 void R_DrawSurfaceBlock8 (void);
 texture_t *R_TextureAnimation (texture_t *base);
 
-#ifdef	id386
-
-void R_DrawSurfaceBlock8_mip0 (void);
-void R_DrawSurfaceBlock8_mip1 (void);
-void R_DrawSurfaceBlock8_mip2 (void);
-void R_DrawSurfaceBlock8_mip3 (void);
-
-#endif
-
 void R_GenSkyTile (void *pdest);
 void R_GenSkyTile16 (void *pdest);
 void R_Surf8Patch (void);
--- a/r_main.c
+++ b/r_main.c
@@ -210,12 +210,6 @@
 
 	R_InitParticles ();
 
-// TODO: collect 386-specific code in one place
-#ifdef	id386
-	Sys_MakeCodeWriteable ((uintptr)R_EdgeCodeStart,
-					     (uintptr)R_EdgeCodeEnd - (uintptr)R_EdgeCodeStart);
-#endif	// id386
-
 	D_Init ();
 }
 
@@ -441,24 +435,6 @@
 		r_fov_greater_than_90 = false;
 	else
 		r_fov_greater_than_90 = true;
-
-// TODO: collect 386-specific code in one place
-#ifdef	id386
-	if (r_pixbytes == 1)
-	{
-		Sys_MakeCodeWriteable ((uintptr)R_Surf8Start,
-						     (uintptr)R_Surf8End - (uintptr)R_Surf8Start);
-		colormap = vid.colormap;
-		R_Surf8Patch ();
-	}
-	else
-	{
-		Sys_MakeCodeWriteable ((uintptr)R_Surf16Start,
-						     (uintptr)R_Surf16End - (uintptr)R_Surf16Start);
-		colormap = vid.colormap16;
-		R_Surf16Patch ();
-	}
-#endif	// id386
 
 	D_ViewChanged ();
 }
--- a/r_misc.c
+++ b/r_misc.c
@@ -273,8 +273,6 @@
 }
 
 
-#ifndef	id386
-
 /*
 ================
 TransformVector
@@ -286,8 +284,6 @@
 	out[1] = DotProduct(in,vup);
 	out[2] = DotProduct(in,vpn);		
 }
-
-#endif //!id386
 
 
 /*
--- a/r_surf.c
+++ b/r_surf.c
@@ -299,8 +299,6 @@
 
 //=============================================================================
 
-#ifndef	id386
-
 /*
 ================
 R_DrawSurfaceBlock8_mip0
@@ -547,8 +545,6 @@
 
 	prowdestbase = prowdest;
 }
-
-#endif //!id386
 
 
 //============================================================================
--- a/r_vars.c
+++ b/r_vars.c
@@ -4,8 +4,6 @@
 #include <libc.h>
 #include	"quakedef.h"
 
-#ifndef	id386
-
 // all global and static refresh variables are collected in a contiguous block
 // to avoid cache conflicts.
 
@@ -17,6 +15,3 @@
 // FIXME: do separately for refresh engine and driver
 
 int	r_bmodelactive;
-
-#endif	// !id386
-
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -755,10 +755,6 @@
 
 // it is possible to miscount buffers if it has wrapped twice between
 // calls to S_Update.  Oh well.
-#ifdef __sun__
-	soundtime = SNDDMA_GetSamples();
-#endif
-#ifndef __sun__
 	samplepos = SNDDMA_GetDMAPos();
 
 
@@ -776,7 +772,6 @@
 	oldsamplepos = samplepos;
 
 	soundtime = buffers*fullsamples + samplepos/shm->channels;
-#endif
 }
 
 void S_ExtraUpdate (void)
--- a/snd_mix.c
+++ b/snd_mix.c
@@ -14,7 +14,6 @@
 
 void Snd_WriteLinearBlastStereo16 (void);
 
-#ifndef	id386
 void Snd_WriteLinearBlastStereo16 (void)
 {
 	int		i;
@@ -39,7 +38,6 @@
 			snd_out[i+1] = val;
 	}
 }
-#endif //!id386
 
 void S_TransferStereo16 (int endtime)
 {
@@ -228,8 +226,6 @@
 }
 
 
-#ifndef id386
-
 void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
 {
 	int 	data;
@@ -255,8 +251,6 @@
 	
 	ch->pos += count;
 }
-
-#endif	// !id386
 
 
 void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -133,9 +133,6 @@
 
 void Sys_Init(void)
 {
-#ifdef id386
-	Sys_SetFPCW();
-#endif
 }
 
 void Sys_Error (char *error, ...)
@@ -345,7 +342,6 @@
 	return NULL;
 }
 
-#ifndef id386
 void Sys_HighFPPrecision (void)
 {
 }
@@ -353,7 +349,6 @@
 void Sys_LowFPPrecision (void)
 {
 }
-#endif //!id386
 
 int main (int c, char **v)
 {
--- a/world.c
+++ b/world.c
@@ -435,8 +435,6 @@
 ===============================================================================
 */
 
-#ifndef	id386
-
 /*
 ==================
 SV_HullPointContents
@@ -469,8 +467,6 @@
 	
 	return num;
 }
-
-#endif	// !id386
 
 
 /*