Example #1
0
/*
================
=
= R_InitData
=
= Locates all the lumps that will be used by all views
= Must be called after W_Init
=================
*/

void R_InitData (void)
{
	tprintf("\nR_InitTextures ",0);
	R_InitTextures ();
//printf (".");
	tprintf("R_InitFlats\n",0);
	R_InitFlats ();
	IncThermo();
//printf (".");
	tprintf("R_InitSpriteLumps ",0);
	R_InitSpriteLumps ();
	IncThermo();
//printf (".");
	R_InitColormaps ();
Example #2
0
/*
================
=
= R_InitSpriteLumps
=
= Finds the width and hoffset of all sprites in the wad, so the sprite doesn't
= need to be cached just for the header during rendering
=================
*/

void R_InitSpriteLumps (void)
{
	int		i;
	patch_t	*patch;
	dstex_t			*sprite_ds;

	firstspritelump = W_GetNumForName ("S_START") + 1;
	lastspritelump = W_GetNumForName ("S_END") - 1;
	numspritelumps = lastspritelump - firstspritelump + 1;
	spritewidth = (fixed_t *)Z_Malloc (numspritelumps*4, PU_STATIC, 0);
	spriteheight = (fixed_t *)Z_Malloc (numspritelumps*4, PU_STATIC, 0);
	spriteoffset = (fixed_t *)Z_Malloc (numspritelumps*4, PU_STATIC, 0);
	spritetopoffset = (fixed_t *)Z_Malloc (numspritelumps*4, PU_STATIC, 0);
	sprites_ds = (dstex_t *)Z_Malloc (numspritelumps*sizeof(dstex_t), PU_STATIC, 0);

	for (i=0 ; i< numspritelumps ; i++)
	{
		#ifdef __NEXT__
		if (!(i&63))
			printf (".");
		#else
		IncThermo();
		#endif
		patch = (patch_t *)W_CacheLumpNum (firstspritelump+i, PU_CACHE);
		spritewidth[i] = SHORT(patch->width)<<FRACBITS;
		spriteheight[i] = SHORT(patch->height)<<FRACBITS;
		spriteoffset[i] = SHORT(patch->leftoffset)<<FRACBITS;
		spritetopoffset[i] = SHORT(patch->topoffset)<<FRACBITS;
		sprite_ds = &sprites_ds[i];
		ds_init_sprite(i,patch,sprite_ds);
	}
Example #3
0
void R_InitSpriteLumps (void)
{
    int		i;
    patch_t	*patch;

    firstspritelump = W_GetNumForName ("S_START") + 1;
    lastspritelump = W_GetNumForName ("S_END") - 1;
    numspritelumps = lastspritelump - firstspritelump + 1;
    spritewidth = Z_Malloc (numspritelumps*4, PU_STATIC, 0);
    spriteoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0);
    spritetopoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0);

    for (i=0 ; i< numspritelumps ; i++)
    {
#ifdef __NEXT__
        if (!(i&63))
            printf (".");
#else
        IncThermo();
#endif
        patch = W_CacheLumpNum (firstspritelump+i, PU_CACHE);
        spritewidth[i] = SHORT(patch->width)<<FRACBITS;
        spriteoffset[i] = SHORT(patch->leftoffset)<<FRACBITS;
        spritetopoffset[i] = SHORT(patch->topoffset)<<FRACBITS;
    }
}
Example #4
0
/*
==================
=
= R_InitTextures
=
= Initializes the texture list with the textures from the world map
=
==================
*/

void R_InitTextures (void)
{
	maptexture_t	*mtexture;
	texture_t		*texture;
	dstex_t			*texture_ds;
	mappatch_t	*mpatch;
	texpatch_t	*patch;
	int			i,j;
	int			*maptex, *maptex2, *maptex1;
	char		name[9], *names, *name_p;
	int			*patchlookup;
	int			totalwidth;
	int			nummappatches;
	int			offset, maxoff, maxoff2;
	int			numtextures1, numtextures2;
	int			*directory;

//
// load the patch names from pnames.lmp
//
	name[8] = 0;
	names = W_CacheLumpName ("PNAMES", PU_STATIC);
	nummappatches = LONG ( *((int *)names) );
	name_p = names+4;
	patchlookup = malloc (nummappatches*sizeof(*patchlookup));
	if(patchlookup == 0) {
		I_Error("patchlookup == 0\n");
	}
	for (i=0 ; i<nummappatches ; i++)
	{
		strncpy (name,name_p+i*8, 8);
		patchlookup[i] = W_CheckNumForName (name);
	}
	Z_Free (names);

//
// load the map texture definitions from textures.lmp
//
	maptex = maptex1 = W_CacheLumpName ("TEXTURE1", PU_STATIC);
	numtextures1 = LONG(*maptex);
	maxoff = W_LumpLength (W_GetNumForName ("TEXTURE1"));
	directory = maptex+1;

	if (W_CheckNumForName ("TEXTURE2") != -1)
	{
		maptex2 = W_CacheLumpName ("TEXTURE2", PU_STATIC);
		numtextures2 = LONG(*maptex2);
		maxoff2 = W_LumpLength (W_GetNumForName ("TEXTURE2"));
	}
	else
	{
		maptex2 = NULL;
		numtextures2 = 0;
		maxoff2 = 0;
	}
	numtextures = numtextures1 + numtextures2;

	printf("num textures %d\n",numtextures);

	//
	//	Init the startup thermometer at this point...
	//
	{
		int	spramount;
		spramount = W_GetNumForName("S_END") - W_GetNumForName("S_START") + 1;
		InitThermo(spramount + numtextures + 6);
	}

	textures = Z_Malloc (numtextures*4, PU_STATIC, 0);
	textures_ds = Z_Malloc (numtextures*sizeof(*textures_ds), PU_STATIC, 0);
	texturecolumnlump = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecolumnofs = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecomposite = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecompositesize = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturewidthmask = Z_Malloc (numtextures*4, PU_STATIC, 0);
	textureheight = Z_Malloc (numtextures*4, PU_STATIC, 0);

	totalwidth = 0;

	for (i=0 ; i<numtextures ; i++, directory++)
	{
		#ifdef __NEXT__
		if(!(i&63))
			printf (".");
		#else
		IncThermo();
		#endif
		if (i == numtextures1)
		{	// start looking in second texture file
			maptex = maptex2;
			maxoff = maxoff2;
			directory = maptex+1;
		}

		offset = LONG(*directory);
		if (offset > maxoff)
			I_Error ("R_InitTextures: bad texture directory");
		mtexture = (maptexture_t *) ( (byte *)maptex + offset);
		texture = textures[i] = Z_Malloc (sizeof(texture_t) 
			+ sizeof(texpatch_t)*(SHORT(mtexture->patchcount)-1), PU_STATIC,
			0);
		texture->width = SHORT(mtexture->width);
		texture->height = SHORT(mtexture->height);
		texture->patchcount = SHORT(mtexture->patchcount);
		texture_ds = &textures_ds[i];
		ds_init_texture(i,texture,texture_ds);
		memcpy (texture->name, mtexture->name, sizeof(texture->name));
		//printf("%d: %p %8s %p %8s\n",i,texture->name,texture->name,mtexture->name,mtexture->name);
		if(*texture->name == 0)
		{
			while(1);
		}
		mpatch = &mtexture->patches[0];
		patch = &texture->patches[0];
		for (j=0 ; j<texture->patchcount ; j++, mpatch++, patch++)
		{
			patch->originx = SHORT(mpatch->originx);
			patch->originy = SHORT(mpatch->originy);
			patch->patch = patchlookup[SHORT(mpatch->patch)];
			if (patch->patch == -1)
				I_Error (
				"R_InitTextures: Missing patch in texture %s",texture->name);
		}		
		texturecolumnlump[i] = Z_Malloc (texture->width*2, PU_STATIC,0);
		texturecolumnofs[i] = Z_Malloc (texture->width*2, PU_STATIC,0);
		j = 1;
		while (j*2 <= texture->width)
			j<<=1;
		texturewidthmask[i] = j-1;
		textureheight[i] = texture->height<<FRACBITS;
		
		totalwidth += texture->width;
	}

	free(patchlookup);
	Z_Free (maptex1);
	if (maptex2)
		Z_Free (maptex2);

//
// precalculate whatever possible
//		
	for(i = 0; i < numtextures; i++)
	{
		R_GenerateLookup(i);
		CheckAbortStartup();
	}

//
// translation table for global animation
//
	texturetranslation = Z_Malloc ((numtextures+1)*4, PU_STATIC, 0);
	for (i=0 ; i<numtextures ; i++)
		texturetranslation[i] = i;

	ds_init_textures();