Example #1
0
static void LoadSideDefs(Word lump)
{
	Word i;
	mapsidedef_t *MapSide;
	side_t *sd;

	MapSide = (mapsidedef_t *)LoadAResource(lump);	/* Load in the data */
	numsides = ((Word *)MapSide)[0];			/* Get the side count */		
	MapSide = (mapsidedef_t *)&((Word *)MapSide)[1];	/* Index to the array */

	i = numsides*sizeof(side_t);		/* How much data do I need? */
	sd = (side_t *)AllocAPointer(i);	/* Allocate it */
	sides=sd;				/* Save the data */
	i = numsides;			/* Number of sides to process */
	do {
		sd->textureoffset = MapSide->textureoffset;	/* Copy the texture X offset */
		sd->rowoffset = MapSide->rowoffset;		/* Copy the texture Y offset */
		sd->toptexture = MapSide->toptexture;	/* Topmost texture */
		sd->bottomtexture = MapSide->bottomtexture;	/* Bottommost texture */
		sd->midtexture = MapSide->midtexture;	/* Center texture */
		sd->sector = &sectors[MapSide->sector];	/* Parent sector */
		++MapSide;		/* Next indexs */
		++sd;
	} while (--i);		/* Count down */
	KillAResource(lump);	/* Release the memory */
}
Example #2
0
static void LoadSectors(Word lump)
{
	Word i;
	mapsector_t *Map;
	sector_t *ss;

	Map = (mapsector_t *)LoadAResource(lump);		/* Load the data in */
	numsectors = ((Word *)Map)[0];			/* Get the number of entries */
	Map = (mapsector_t *)&((Word*)Map)[1];	/* Index past the entry count */
	i = numsectors*sizeof(sector_t);	/* Get the data size */
	ss = (sector_t *)AllocAPointer(i);		/* Get some memory */
	memset(ss,0,i);		/* Clear out the memory (Extra fields present) */
	sectors = ss;		/* Save the sector data */
	i = numsectors;		/* Init the loop count */
	do {
		ss->floorheight = Map->floorheight;		/* Copy the floor height */
		ss->ceilingheight = Map->ceilingheight;	/* Copy the ceiling height */
		ss->FloorPic = Map->floorpic;			/* Copy the floor texture # */
		ss->CeilingPic = Map->ceilingpic;		/* Copy the ceiling texture # */
		ss->lightlevel = Map->lightlevel;		/* Copy the ambient light */
		ss->special = Map->special;				/* Copy the event number type */
		ss->tag = Map->tag;						/* Copy the event tag ID */
		++ss;			/* Next indexs */
		++Map;
	} while (--i);		/* All done? */
	KillAResource(lump);	/* Dispose of the original */
}
Example #3
0
void DrawWeapons(void)
{
	Word i;
	Word Shadow;		/* Flag for shadowing */
	pspdef_t *psp;
	
	psp = players.psprites;	/* Get the first sprite in the array */ 
	Shadow = FALSE;			/* Assume no shadow draw mode */
	if (players.mo->flags & MF_SHADOW) {	/* Could be active? */
		i = players.powers[pw_invisibility];	/* Get flash time */
		if (i>=(5*TICKSPERSEC) || i&0x10) {	/* On a long time or if flashing... */
			Shadow = TRUE;		/* Draw as a shadow right now */
		}
	}
	i = 0;		/* Init counter */
	do {
		if (psp->StatePtr) {		/* Valid state record? */
			DrawAWeapon(psp,Shadow);	/* Draw the weapon */
		}
		++psp;		/* Next... */
	} while (++i<NUMPSPRITES);	/* All done? */
	
	i = ScreenSize+rBACKGROUNDMASK;		/* Get the resource needed */
	DrawMShape(0,0,LoadAResource(i));	/* Draw the border */
	ReleaseAResource(i);				/* Release the resource */
}
Example #4
0
Word NewGameWindow(Word NewVidSize)
{
	LongWord *LongPtr;
	Byte *DestPtr;
	int i;
	
	printf("Called: %d\n", NewVidSize);
	
	if (NewVidSize == VidSize)
		return VidSize;
	
	printf("Setting Size: %d (from %d)\n", NewVidSize, VidSize);
		
	if (NewVidSize < 4) {
		w = VidXs[NewVidSize];
		h = VidYs[NewVidSize];
		v = VidVs[NewVidSize];
	} else {
		fprintf(stderr, "Invalid Vid size: %d\n", NewVidSize);
		exit(EXIT_FAILURE);
	}
	
	/* Free Image */
	
	/* Resize Window */
	
	gfxbuf = (Byte *)malloc(w * h);
	
	/* Create Image */
	
	VideoPointer = gfxbuf;
	VideoWidth = w;
	InitYTable();
	SetAPalette(rBlackPal);
	ClearTheScreen(BLACK);
	BlastScreen();
	
	LongPtr = (LongWord *) LoadAResource(VidPics[NewVidSize]);

	if (GameShapes)
		FreeSomeMem(GameShapes);
		
	GameShapes = (Byte **)AllocSomeMem(lMSB(LongPtr[0]));
	DLZSS((Byte *)GameShapes, (Byte *)&LongPtr[1], lMSB(LongPtr[0]));
	ReleaseAResource(VidPics[NewVidSize]);
	
	LongPtr = (LongWord *)GameShapes;
	DestPtr = (Byte *)GameShapes;
	for (i = 0; i < ((NewVidSize == 1) ? 57 : 47); i++) 
		GameShapes[i] = DestPtr + lMSB(LongPtr[i]);
	
	VidSize = NewVidSize;
	
	return VidSize;
}
Example #5
0
void D_DoomMain(void)
{
	BigNumFont = LoadAResource(rBIGNUMB);	/* Cache the large numeric font (Needed always) */
	R_Init();			/* Init refresh system */
	P_Init();			/* Init main code */
	O_Init();			/* Init controls */
	for (;;) {
		RunTitle();			/* Show the title page */
		RunDemo(rDEMO1);	/* Run the first demo */
		RunCredits();		/* Show the credits page */
		RunDemo(rDEMO2);	/* Run the second demo */
	}
}
Example #6
0
static void RunDemo(Word demoname)
{
#if 0
	Word *demo;
	Word exit;

	demo = (Word *)LoadAResource(demoname);	/* Load the demo */
	exit = G_PlayDemoPtr(demo);		/* Play the demo */
	ReleaseAResource(demoname);			/* Release the demo data */
	if (exit == ga_exitdemo) {		/* Quit? */
		RunMenu();				/* Show the main menu */
	}
#endif
}
Example #7
0
static void LoadSegs(Word lump)
{
	Word i;
	mapseg_t *ml;
	seg_t *li;
	Word numsegs;

	ml = (mapseg_t *)LoadAResource(lump);		/* Load in the map data */
	numsegs = ((Word*)ml)[0];		/* Get the count */
	i = numsegs*sizeof(seg_t);		/* Get the memory size */
	li = (seg_t *)AllocAPointer(i);	/* Allocate it */
	segs = li;				/* Save pointer to global */				
	memset(li,0,i);			/* Clear it out */

	ml = (mapseg_t *)&((Word *)ml)[1];	/* Init pointer to first record */
	i = 0;
	do {
		line_t *ldef;
		Word side;
		
		li->v1 = vertexes[ml->v1];	/* Get the line points */
		li->v2 = vertexes[ml->v2];
		li->angle = ml->angle;		/* Set the angle of the line */
		li->offset = ml->offset;	/* Get the texture offset */
		ldef = &lines[ml->linedef];	/* Get the line pointer */
		li->linedef = ldef;
		side = ml->side;		/* Get the side number */
		li->sidedef = ldef->SidePtr[side];	/* Grab the side pointer */
		li->frontsector = li->sidedef->sector;	/* Get the front sector */
		if (ldef->flags & ML_TWOSIDED) {		/* Two sided? */
			li->backsector = ldef->SidePtr[side^1]->sector;	/* Mark the back sector */
		}
		if (ldef->v1.x == li->v1.x && ldef->v1.y == li->v1.y) {	/* Init the fineangle */
			ldef->fineangle = li->angle>>ANGLETOFINESHIFT;	/* This is a point only */
		}
		++li;		/* Next entry */
		++ml;		/* Next resource entry */
	} while (++i<numsegs);
Example #8
0
static void DrawAWeapon(pspdef_t *psp,Word Shadow)
{
	Short *Input;		/* Pointer to the xy offset'd shape */
//	Word Color;
	Word RezNum;
	int x,y;
	state_t *StatePtr;

	StatePtr = psp->StatePtr;		/* Get the state struct pointer */
	RezNum = StatePtr->SpriteFrame>>FF_SPRITESHIFT;	/* Get the file */
	Input = (Short *)LoadAResource(RezNum);	/* Get the main pointer */
	Input = (Short *)GetShapeIndexPtr(Input,StatePtr->SpriteFrame & FF_FRAMEMASK);
	
	((LongWord *)Input)[7] = GunXScale;		/* Set the scale factor */
	((LongWord *)Input)[10] = GunYScale;
	if (Shadow) {
		((LongWord *)Input)[13] = 0x9C81;	/* Set the shadow bits */
	} else {
		((LongWord *)Input)[13] = 0x1F00;	/* Normal PMode */
#if 0
		if (StatePtr->SpriteFrame & FF_FULLBRIGHT) {
			Color = 255;			/* Full bright */
		} else {					/* Ambient light */
			Color = players.mo->subsector->sector->lightlevel;
		}
#endif
	}
	x = Input[0];
	y = Input[1];
	x = ((psp->WeaponX+x)*(int)GunXScale)>>20;
	y = ((psp->WeaponY+SCREENGUNY+y)*(int)GunYScale)>>16;
	x+=ScreenXOffset;
	y+=ScreenYOffset+2;			/* Add 2 pixels to cover up the hole in the bottom */
	DrawMShape(x,y,&Input[2]);	/* Draw the weapon's shape */
	ReleaseAResource(RezNum);
}
Example #9
0
static void LoadLineDefs(Word lump)
{
	Word i;
	maplinedef_t *mld;
	line_t *ld;

	mld = (maplinedef_t *)LoadAResource(lump);	/* Load in the data */
	numlines = ((Word*)mld)[0];			/* Get the number of lines in the struct array */	
	i = numlines*sizeof(line_t);		/* Get the size of the dest buffer */
	ld = (line_t *)AllocAPointer(i);	/* Get the memory for the lines array */
	lines = ld;					/* Save the lines */
	memset(ld,0,i);				/* Blank out the buffer */
	mld = (maplinedef_t *)&((Word *)mld)[1];	/* Index to the first record of the struct array */
	i = numlines;			
	do {
		Fixed dx,dy;
		ld->flags = mld->flags;		/* Copy the flags */
		ld->special = mld->special;	/* Copy the special type */
		ld->tag = mld->tag;			/* Copy the external tag ID trigger */
		ld->v1 = vertexes[mld->v1];		/* Copy the end points to the line */
		ld->v2 = vertexes[mld->v2];
		dx = ld->v2.x - ld->v1.x;	/* Get the delta offset (Line vector) */
		dy = ld->v2.y - ld->v1.y;
		
		/* What type of line is this? */
		
		if (!dx) {				/* No x motion? */
			ld->slopetype = ST_VERTICAL;		/* Vertical line only */
		} else if (!dy) {		/* No y motion? */
			ld->slopetype = ST_HORIZONTAL;		/* Horizontal line only */
		} else {
			if ((dy^dx) >= 0) {	/* Is this a positive or negative slope */
				ld->slopetype = ST_POSITIVE;	/* Like signs, positive slope */
			} else {
				ld->slopetype = ST_NEGATIVE;	/* Unlike signs, negative slope */
			}
		}
		
		/* Create the bounding box */
		
		if (dx>=0) {			/* V2>=V1? */
			ld->bbox[BOXLEFT] = ld->v1.x;		/* Leftmost x */
			ld->bbox[BOXRIGHT] = ld->v2.x;		/* Rightmost x */
		} else {
			ld->bbox[BOXLEFT] = ld->v2.x;
			ld->bbox[BOXRIGHT] = ld->v1.x;
		}
		if (dy>=0) {
			ld->bbox[BOXBOTTOM] = ld->v1.y;		/* Bottommost y */
			ld->bbox[BOXTOP] = ld->v2.y;		/* Topmost y */
		} else {
			ld->bbox[BOXBOTTOM] = ld->v2.y;
			ld->bbox[BOXTOP] = ld->v1.y;
		}
		
		/* Copy the side numbers and sector pointers */
		
		ld->SidePtr[0] = &sides[mld->sidenum[0]];		/* Get the side number */
		ld->frontsector = ld->SidePtr[0]->sector;	/* All lines have a front side */	
		if (mld->sidenum[1] != -1) {				/* But maybe not a back side */
			ld->SidePtr[1] = &sides[mld->sidenum[1]];
			ld->backsector = ld->SidePtr[1]->sector;	/* Get the sector pointed to */
		}
		++ld;			/* Next indexes */
		++mld;
	} while (--i);
	KillAResource(lump);	/* Release the resource */
}