Iskhodnyy_kod_Doom
.pdf}
rw_toptexturemid += sidedef->rowoffset; rw_bottomtexturemid += sidedef->rowoffset;
// allocate space for masked texture tables if (sidedef->midtexture)
{
// masked midtexture maskedtexture = true;
ds_p->maskedtexturecol = maskedtexturecol = lastopening - rw_x; lastopening += rw_stopx - rw_x;
}
}
// calculate rw_offset (only needed for textured lines)
segtextured = midtexture | toptexture | bottomtexture | maskedtexture;
if (segtextured)
{
offsetangle = rw_normalangle-rw_angle1;
if (offsetangle > ANG180) offsetangle = -offsetangle;
if (offsetangle > ANG90) offsetangle = ANG90;
sineval = finesine[offsetangle >>ANGLETOFINESHIFT]; rw_offset = FixedMul (hyp, sineval);
if (rw_normalangle-rw_angle1 < ANG180) rw_offset = -rw_offset;
rw_offset += sidedef->textureoffset + curline->offset; rw_centerangle = ANG90 + viewangle - rw_normalangle;
//calculate light table
//use different light tables
//for horizontal / vertical / diagonal
//OPTIMIZE: get rid of LIGHTSEGSHIFT globally if (!fixedcolormap)
{
lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight;
if (curline->v1->y == curline->v2->y) lightnum--;
else if (curline->v1->x == curline->v2->x) lightnum++;
if (lightnum < 0)
walllights = scalelight[0]; else if (lightnum >= LIGHTLEVELS)
walllights = scalelight[LIGHTLEVELS-1];
else
walllights = scalelight[lightnum];
}
}
//if a floor / ceiling plane is on the wrong side
//of the view plane, it is definitely invisible
//and doesn’t need to be marked.
if (frontsector->floorheight >= viewz)
{
681
// above view plane markfloor = false;
}
if (frontsector->ceilingheight <= viewz
&& frontsector->ceilingpic != skyflatnum)
{
// below view plane markceiling = false;
}
// calculate incremental stepping values for texture edges worldtop >>= 4;
worldbottom >>= 4;
topstep = -FixedMul (rw_scalestep, worldtop);
topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale);
bottomstep = -FixedMul (rw_scalestep,worldbottom);
bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
if (backsector)
{
worldhigh >>= 4; worldlow >>= 4;
if (worldhigh < worldtop)
{
pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); pixhighstep = -FixedMul (rw_scalestep,worldhigh);
}
if (worldlow > worldbottom)
{
pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); pixlowstep = -FixedMul (rw_scalestep,worldlow);
}
}
// render it
if (markceiling)
ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1);
if (markfloor)
floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1);
R_RenderSegLoop ();
// save sprite clipping info
if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip)
{
memcpy (lastopening, ceilingclip+start, 2*(rw_stopx-start)); ds_p->sprtopclip = lastopening - start;
lastopening += rw_stopx - start;
}
if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip)
{
memcpy (lastopening, floorclip+start, 2*(rw_stopx-start)); ds_p->sprbottomclip = lastopening - start;
lastopening += rw_stopx - start;
682
}
if (maskedtexture && !(ds_p->silhouette&SIL_TOP))
{
ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = MININT;
}
if (maskedtexture && !(ds_p->silhouette&SIL_BOTTOM))
{
ds_p->silhouette |= SIL_BOTTOM; ds_p->bsilheight = MAXINT;
}
ds_p++;
}
10.14r segs.h
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------
//
//$Id:$
//Copyright (C) 1993-1996 by id Software, Inc.
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//DESCRIPTION:
//Refresh module, drawing LineSegs from BSP.
//-----------------------------------------------------------------------------
#ifndef __R_SEGS__ #define __R_SEGS__
#ifdef __GNUG__ #pragma interface #endif
void R_RenderMaskedSegRange
( drawseg_t* |
ds, |
|
int |
x1, |
|
int |
x2 |
); |
#endif //-----------------------------------------------------------------------------
//
// $Log:$
//
//-----------------------------------------------------------------------------
683
10.15 r sky.c
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------
//
//$Id:$
//Copyright (C) 1993-1996 by id Software, Inc.
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//$Log:$
//DESCRIPTION:
//Sky rendering. The DOOM sky is a texture map like any
//wall, wrapping around. A 1024 columns equal 360 degrees.
//The default sky map is 256 columns and repeats 4 times
//on a 320 screen?
//
//
//-----------------------------------------------------------------------------
static const char
rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
//Needed for FRACUNIT. #include "m_fixed.h"
//Needed for Flat retrieval. #include "r_data.h"
#ifdef __GNUG__
#pragma implementation "r_sky.h" #endif
#include "r_sky.h"
// |
|
// sky mapping |
|
// |
|
int |
skyflatnum; |
int |
skytexture; |
int |
skytexturemid; |
//
//R_InitSkyMap
//Called whenever the view size changes.
void R_InitSkyMap (void)
{
// skyflatnum = R_FlatNumForName ( SKYFLATNAME ); skytexturemid = 100*FRACUNIT;
}
684
10.16 r sky.h
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------
//
//$Id:$
//Copyright (C) 1993-1996 by id Software, Inc.
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//DESCRIPTION:
//Sky rendering.
//-----------------------------------------------------------------------------
#ifndef __R_SKY__ #define __R_SKY__
#ifdef __GNUG__ #pragma interface #endif
// SKY, store the number for name.
#define |
|
SKYFLATNAME "F_SKY1" |
// The sky map is 256*128*4 maps. |
||
#define |
ANGLETOSKYSHIFT |
22 |
extern |
int |
skytexture; |
extern int |
skytexturemid; |
|
// Called whenever the view size changes. |
||
void R_InitSkyMap (void); |
|
|
#endif |
|
|
//----------------------------------------------------------------------------- |
|
|
// |
|
|
// $Log:$ |
|
|
// |
|
|
//----------------------------------------------------------------------------- |
|
|
10.17 r state.h
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------
//
//$Id:$
//Copyright (C) 1993-1996 by id Software, Inc.
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//
685
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//DESCRIPTION:
//Refresh/render internal state variables (global).
//-----------------------------------------------------------------------------
#ifndef __R_STATE__ #define __R_STATE__
// Need data structure definitions. #include "d_player.h"
#include "r_data.h"
#ifdef __GNUG__ #pragma interface #endif
//
//Refresh internal data structures,
//for rendering.
//
// needed for texture pegging
extern |
fixed_t* |
textureheight; |
// needed for pre rendering (fracs) |
||
extern |
fixed_t* |
spritewidth; |
extern |
fixed_t* |
spriteoffset; |
extern |
fixed_t* |
spritetopoffset; |
extern |
lighttable_t* |
colormaps; |
extern |
int |
viewwidth; |
extern |
int |
scaledviewwidth; |
extern |
int |
viewheight; |
extern |
int |
firstflat; |
// for |
global animation |
|
extern |
int* |
flattranslation; |
extern |
int* |
texturetranslation; |
// Sprite.... |
|
|
extern |
int |
firstspritelump; |
extern |
int |
lastspritelump; |
extern |
int |
numspritelumps; |
//
// Lookup tables for map data.
//
extern |
int |
numsprites; |
extern |
spritedef_t* |
sprites; |
686
extern |
int |
numvertexes; |
extern |
vertex_t* |
vertexes; |
extern |
int |
numsegs; |
extern |
seg_t* |
segs; |
extern |
int |
numsectors; |
extern |
sector_t* |
sectors; |
extern |
int |
numsubsectors; |
extern |
subsector_t* |
subsectors; |
extern |
int |
numnodes; |
extern |
node_t* |
nodes; |
extern |
int |
numlines; |
extern |
line_t* |
lines; |
extern |
int |
numsides; |
extern |
side_t* |
sides; |
// |
|
|
// POV |
data. |
|
// |
|
|
extern |
fixed_t |
viewx; |
extern |
fixed_t |
viewy; |
extern |
fixed_t |
viewz; |
extern |
angle_t |
viewangle; |
extern |
player_t* |
viewplayer; |
// ? |
|
|
extern |
angle_t |
clipangle; |
extern |
int |
viewangletox[FINEANGLES/2]; |
extern |
angle_t |
xtoviewangle[SCREENWIDTH+1]; |
//extern fixed_t |
finetangent[FINEANGLES/2]; |
|
extern |
fixed_t |
rw_distance; |
extern |
angle_t |
rw_normalangle; |
// angle to line origin |
|
|
extern |
int |
rw_angle1; |
// Segs count? |
|
|
extern |
int |
sscount; |
extern |
visplane_t* |
floorplane; |
extern |
visplane_t* |
ceilingplane; |
#endif |
|
|
//----------------------------------------------------------------------------- |
|
|
// |
|
|
// $Log:$
//
//-----------------------------------------------------------------------------
687
10.18 r things.c
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------
//
//$Id:$
//Copyright (C) 1993-1996 by id Software, Inc.
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//$Log:$
//DESCRIPTION:
//Refresh of things, i.e. objects represented by sprites.
//-----------------------------------------------------------------------------
static const char
rcsid[] = "$Id: r_things.c,v 1.5 1997/02/03 16:47:56 b1 Exp $";
#include <stdio.h> #include <stdlib.h>
#include "doomdef.h" #include "m_swap.h"
#include "i_system.h" #include "z_zone.h" #include "w_wad.h"
#include "r_local.h"
#include "doomstat.h"
#define |
MINZ |
(FRACUNIT*4) |
#define |
BASEYCENTER |
100 |
//void R_DrawColumn (void); //void R_DrawFuzzColumn (void);
typedef struct |
|
{ |
|
int |
x1; |
int |
x2; |
int |
column; |
int |
topclip; |
int |
bottomclip; |
} maskdraw_t; |
|
688
//
//Sprite rotation 0 is facing the viewer,
//rotation 1 is one angle turn CLOCKWISE around the axis.
//This is not the same as the angle,
//which increases counter clockwise (protractor).
//There was a lot of stuff grabbed wrong, so I changed it...
fixed_t |
pspritescale; |
fixed_t |
pspriteiscale; |
lighttable_t** spritelights;
//constant arrays
//used for psprite clipping and initializing clipping
short |
negonearray[SCREENWIDTH]; |
short |
screenheightarray[SCREENWIDTH]; |
//
//INITIALIZATION FUNCTIONS
//variables used to look up
//and range check thing_t sprites patches
spritedef_t* |
sprites; |
int |
numsprites; |
spriteframe_t |
sprtemp[29]; |
int |
maxframe; |
char* |
spritename; |
//
//R_InstallSpriteLump
//Local function for R_InitSprites.
void R_InstallSpriteLump
( int |
lump, |
unsigned |
frame, |
unsigned |
rotation, |
boolean |
flipped ) |
{ |
|
int |
r; |
if (frame >= 29 || rotation > 8) I_Error("R_InstallSpriteLump: "
"Bad frame characters in lump %i", lump);
if ((int)frame > maxframe) maxframe = frame;
if (rotation == 0)
{
// the lump should be used for all rotations if (sprtemp[frame].rotate == false)
I_Error ("R_InitSprites: Sprite %s frame %c has " "multip rot=0 lump", spritename, ’A’+frame);
if (sprtemp[frame].rotate == true)
689
I_Error ("R_InitSprites: Sprite %s frame %c has rotations " "and a rot=0 lump", spritename, ’A’+frame);
sprtemp[frame].rotate = false; for (r=0 ; r<8 ; r++)
{
sprtemp[frame].lump[r] = lump - firstspritelump; sprtemp[frame].flip[r] = (byte)flipped;
}
return;
}
// the lump is only used for one rotation if (sprtemp[frame].rotate == false)
I_Error ("R_InitSprites: Sprite %s frame %c has rotations " "and a rot=0 lump", spritename, ’A’+frame);
sprtemp[frame].rotate = true;
// make 0 based rotation--;
if (sprtemp[frame].lump[rotation] != -1)
I_Error ("R_InitSprites: Sprite %s : %c : %c " "has two lumps mapped to it", spritename, ’A’+frame, ’1’+rotation);
sprtemp[frame].lump[rotation] = lump - firstspritelump; sprtemp[frame].flip[rotation] = (byte)flipped;
}
//
//R_InitSpriteDefs
//Pass a null terminated list of sprite names
//(4 chars exactly) to be used.
//Builds the sprite rotation matrixes to account
//for horizontally flipped sprites.
//Will report an error if the lumps are inconsistant.
//Only called at startup.
//
//Sprite lump names are 4 characters for the actor,
//a letter for the frame, and a number for the rotation.
//A sprite that is flippable will have an additional
//letter/number appended.
//The rotation character can be 0 to signify no rotations.
void R_InitSpriteDefs (char** namelist)
{
char** |
check; |
int |
i; |
int |
l; |
int |
intname; |
int |
frame; |
int |
rotation; |
int |
start; |
int |
end; |
int |
patched; |
// count the number of sprite names check = namelist;
while (*check != NULL) check++;
690