Skip to content

Commit

Permalink
Remove/tidy up unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
doomhack committed Oct 10, 2019
1 parent f3442d2 commit 8551d44
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 290 deletions.
1 change: 0 additions & 1 deletion GBADoom.pro
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ SOURCES += \
source/tables.c \
source/v_video.c \
source/version.c \
source/w_memcache.c \
source/w_wad.c \
source/wi_stuff.c \
source/z_bmalloc.c \
Expand Down
5 changes: 0 additions & 5 deletions include/global_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,6 @@ visplane_t **freehead; // killough

int spanstart[MAX_SCREENHEIGHT]; // killough 2/8/98

//
// texture mapping
//
fixed_t planeheight;

// killough 2/8/98: make variables static


Expand Down
2 changes: 0 additions & 2 deletions include/i_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ boolean I_StartDisplay(void);
void I_EndDisplay(void);
int I_GetTime(void); /* killough */

unsigned long I_GetRandomTimeSeed(void); /* cphipps */

/* cphipps - I_GetVersionString
* Returns a version string in the given buffer
*/
Expand Down
39 changes: 3 additions & 36 deletions include/w_wad.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,59 +57,26 @@ typedef struct
char name[8];
} filelump_t;

void W_Init(void); // CPhipps - uses the above array
void W_InitCache(void);
void W_DoneCache(void);

typedef struct
{
// WARNING: order of some fields important (see info.c).

char name[9];
int size;

// killough 1/31/98: hash table fields, used for ultra-fast hash table lookup
int index, next;

// killough 4/17/98: namespace tags, to prevent conflicts between resources
enum {
ns_global=0,
ns_sprites,
ns_flats,
ns_colormaps,
ns_prboom
} li_namespace; // haleyjd 05/21/02: renamed from "namespace"

int position;
} lumpinfo_t;

// killough 4/17/98: if W_CheckNumForName() called with only
// one argument, pass ns_global as the default namespace

void W_Init(void); // CPhipps - uses the above array

#define W_CheckNumForName(name) (W_CheckNumForName)(name, 0)
int (W_CheckNumForName)(const char* name, int); // killough 4/17/98
int W_GetNumForName (const char* name);
const char* W_GetNameForNum(int lump);


int W_LumpLength (int lump);
void W_ReadLump (int lump, void *dest);
const void* W_GetLumpPtr(int lump);

// CPhipps - modified for 'new' lump locking
const void* W_CacheLumpNum (int lump);
const void* W_LockLumpNum(int lump);
void W_UnlockLumpNum(int lump);

// CPhipps - convenience macros
//#define W_CacheLumpNum(num) (W_CacheLumpNum)((num),1)
#define W_CacheLumpName(name) W_CacheLumpNum (W_GetNumForName(name))

//#define W_UnlockLumpNum(num) (W_UnlockLumpNum)((num),1)
#define W_UnlockLumpName(name) W_UnlockLumpNum (W_GetNumForName(name))
#define W_CacheLumpName(name) W_CacheLumpNum(W_GetNumForName(name))

void ExtractFileBase(const char *, char *); // killough
unsigned W_LumpNameHash(const char *s); // killough 1/31/98
void W_HashLumps(void); // cph 2001/07/07 - made public

#endif
5 changes: 2 additions & 3 deletions source/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -1789,9 +1789,8 @@ boolean G_CheckDemoStatus (void)
if (_g->singledemo)
exit(0); // killough

if (demolumpnum != -1) {
// cph - unlock the demo lump
W_UnlockLumpNum(demolumpnum);
if (demolumpnum != -1)
{
demolumpnum = -1;
}
G_ReloadDefaults(); // killough 3/1/98
Expand Down
16 changes: 1 addition & 15 deletions source/i_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,11 @@ int I_GetTime(void)

}

/*
* I_GetRandomTimeSeed
*
* CPhipps - extracted from G_ReloadDefaults because it is O/S based
*/
unsigned long I_GetRandomTimeSeed(void)
{
/* killough 3/26/98: shuffle random seed, use the clock */
struct timeval tv;
struct timezone tz;
gettimeofday(&tv,&tz);
return (tv.tv_sec*1000ul + tv.tv_usec/1000ul);
}

/* cphipps - I_GetVersionString
* Returns a version string in the given buffer
*/
const char* I_GetVersionString(char* buf, size_t sz)
{
sprintf(buf,"PsionDoom v%s",VERSION);
sprintf(buf,"GBADoom v%s",VERSION);
return buf;
}
2 changes: 0 additions & 2 deletions source/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ static void I_UploadNewPalette(int pal)
_g->current_pallete = palette;

I_SetPallete_e32(palette);

W_UnlockLumpNum(pplump);

#ifdef RANGECHECK
if ((size_t)pal >= num_pals)
Expand Down
28 changes: 3 additions & 25 deletions source/p_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ static void P_LoadVertexes (int lump)
_g->vertexes[i].x = SHORT(data[i].x)<<FRACBITS;
_g->vertexes[i].y = SHORT(data[i].y)<<FRACBITS;
}

// Free buffer memory.
W_UnlockLumpNum(lump);
}

//
Expand Down Expand Up @@ -139,8 +136,6 @@ static void P_LoadSegs (int lump)
else
li->backsector = 0;
}

W_UnlockLumpNum(lump); // cph - release the data
}

//
Expand All @@ -166,8 +161,6 @@ static void P_LoadSubsectors (int lump)
_g->subsectors[i].numlines = (unsigned short)SHORT(data[i].numsegs );
_g->subsectors[i].firstline = (unsigned short)SHORT(data[i].firstseg);
}

W_UnlockLumpNum(lump); // cph - release the data
}

//
Expand Down Expand Up @@ -202,8 +195,6 @@ static void P_LoadSectors (int lump)
ss->thinglist = NULL;
ss->touching_thinglist = NULL; // phares 3/14/98
}

W_UnlockLumpNum(lump); // cph - release the data
}


Expand Down Expand Up @@ -261,9 +252,6 @@ static void P_LoadThings (int lump)
// Do spawn all other stuff.
P_SpawnMapThing(&mt);
}


W_UnlockLumpNum(lump); // cph - release the data
}

//
Expand Down Expand Up @@ -345,8 +333,6 @@ static void P_LoadLineDefs (int lump)
if (ld->sidenum[0] != NO_INDEX && ld->special)
_g->sides[*ld->sidenum].special = ld->special;
}

W_UnlockLumpNum(lump); // cph - release the lump
}

// killough 4/4/98: delay using sidedefs until they are loaded
Expand Down Expand Up @@ -405,8 +391,6 @@ static void P_LoadSideDefs2(int lump)
sd->toptexture = R_LoadTextureByName(msd->toptexture);
sd->bottomtexture = R_LoadTextureByName(msd->bottomtexture);
}

W_UnlockLumpNum(lump); // cph - release the lump
}

//
Expand Down Expand Up @@ -441,8 +425,6 @@ static void P_LoadBlockMap (int lump)
{
_g->blockmaplump = W_CacheLumpNum(lump);

W_UnlockLumpNum(lump); // cph - unlock the lump

_g->bmaporgx = _g->blockmaplump[0]<<FRACBITS;
_g->bmaporgy = _g->blockmaplump[1]<<FRACBITS;
_g->bmapwidth = _g->blockmaplump[2];
Expand Down Expand Up @@ -471,9 +453,6 @@ static void P_LoadReject(int lumpnum, int totallines)
unsigned int length, required;
byte *newreject;

// dump any old cached reject lump, then cache the new one
if (_g->rejectlump != -1)
W_UnlockLumpNum(_g->rejectlump);
_g->rejectlump = lumpnum + ML_REJECT;
_g->rejectmatrix = W_CacheLumpNum(_g->rejectlump);

Expand All @@ -488,8 +467,7 @@ static void P_LoadReject(int lumpnum, int totallines)
newreject = Z_Malloc(required, PU_LEVEL, NULL);
_g->rejectmatrix = (const byte *)memmove(newreject, _g->rejectmatrix, length);
memset(newreject + length, 0, required - length);
// unlock the original lump, it is no longer needed
W_UnlockLumpNum(_g->rejectlump);

_g->rejectlump = -1;

lprintf(LO_WARN, "P_LoadReject: REJECT too short (%u<%u) - padded\n",
Expand Down Expand Up @@ -636,8 +614,8 @@ void P_SetupLevel(int episode, int map, int playermask, skill_t skill)
//Load the sky texture.
R_GetTexture(_g->skytexture);

if (_g->rejectlump != -1) { // cph - unlock the reject table
W_UnlockLumpNum(_g->rejectlump);
if (_g->rejectlump != -1)
{ // cph - unlock the reject table
_g->rejectlump = -1;
}

Expand Down
19 changes: 3 additions & 16 deletions source/p_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ void P_InitPicAnims (void)
if (R_CheckTextureNumForName(animdefs[i].startname) == -1)
continue;

_g->lastanim->picnum = R_LoadTextureByName (animdefs[i].endname);
_g->lastanim->basepic = R_LoadTextureByName (animdefs[i].startname);
_g->lastanim->picnum = R_CheckTextureNumForName (animdefs[i].endname);
_g->lastanim->basepic = R_CheckTextureNumForName (animdefs[i].startname);
}
else
{
if (W_CheckNumForName(animdefs[i].startname) == -1)
continue;
continue;

_g->lastanim->picnum = R_FlatNumForName (animdefs[i].endname);
_g->lastanim->basepic = R_FlatNumForName (animdefs[i].startname);
Expand All @@ -171,16 +171,6 @@ void P_InitPicAnims (void)

_g->lastanim->speed = animdefs[i].speed;

//Load in animated textures.
if(animdefs[i].istexture)
{
for(int a = _g->lastanim->basepic; a <= _g->lastanim->picnum; a++)
{
R_GetTexture(a);
}
}


_g->lastanim++;
}

Expand Down Expand Up @@ -2265,9 +2255,6 @@ void P_UpdateSpecials (void)
{
pic = anim->basepic + ( (_g->leveltime/anim->speed + i)%anim->numpics );
texturetranslation[i] = pic;

//Load the texture.
R_GetTexture(pic);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/p_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void P_InitSwitchList(void)

if (alphSwitchList[i].episode <= episode)
{
_g->switchlist[index++] = R_LoadTextureByName(alphSwitchList[i].name1);
_g->switchlist[index++] = R_LoadTextureByName(alphSwitchList[i].name2);
_g->switchlist[index++] = R_CheckTextureNumForName(alphSwitchList[i].name1);
_g->switchlist[index++] = R_CheckTextureNumForName(alphSwitchList[i].name2);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions source/r_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static int R_GetTextureNumForName(const char* tex_name)

const maptexture_t* mtexture = (const maptexture_t *) ( (const byte *)maptex + offset);

if(!strnicmp(tex_name, mtexture->name, 8))
if(!strncmp(tex_name, mtexture->name, 8))
return i;
}

Expand Down Expand Up @@ -358,7 +358,8 @@ void R_InitData(void)

int R_FlatNumForName(const char *name) // killough -- const added
{
int i = (W_CheckNumForName)(name, ns_flats);
int i = W_CheckNumForName(name);

if (i == -1)
I_Error("R_FlatNumForName: %.8s not found", name);
return i - _g->firstflat;
Expand Down
37 changes: 4 additions & 33 deletions source/r_hotpath.iwram.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ static int worldlow;
static lighttable_t current_colormap[256];
static const lighttable_t* current_colormap_ptr;

static fixed_t planeheight;

//*****************************************
//Column cache stuff.
//GBA has 16kb of Video Memory for columns
Expand Down Expand Up @@ -710,41 +712,12 @@ static void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2)
{
dcvars.colormap = R_LoadColorMap(rw_lightlevel);

// killough 3/2/98:
//
// This calculation used to overflow and cause crashes in Doom:
//
// sprtopscreen = centeryfrac - FixedMul(dcvars.texturemid, spryscale);
//
// This code fixes it, by using double-precision intermediate
// arithmetic and by skipping the drawing of 2s normals whose
// mapping to screen coordinates is totally out of range:

/*
{
int_64_t t = ((int_64_t) centeryfrac << FRACBITS) -
(int_64_t) dcvars.texturemid * spryscale;
if (t + (int_64_t) textureheight[texnum] * spryscale < 0 ||
t > (int_64_t) MAX_SCREENHEIGHT << FRACBITS*2)
continue; // skip if the texture is out of screen's range
sprtopscreen = (long)(t >> FRACBITS);
}
*/

sprtopscreen = centeryfrac - FixedMul(dcvars.texturemid, spryscale);

dcvars.iscale = UDiv32(0xffffffffu, (unsigned) spryscale);

//dcvars.iscale = 0xffffffffu / (unsigned) spryscale;

// killough 1/25/98: here's where Medusa came in, because
// it implicitly assumed that the column was all one patch.
// Originally, Doom did not construct complete columns for
// multipatched textures, so there were no header or trailer
// bytes in the column referred to below, which explains
// the Medusa effect. The fix is to construct true columns
// when forming multipatched textures (see r_data.c).

// draw the texture

int xc = maskedtexturecol[dcvars.x];
Expand Down Expand Up @@ -1146,7 +1119,7 @@ static void R_MapPlane(int y, int x1, int x2, draw_span_vars_t *dsvars)
I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y);
#endif

distance = FixedMul(_g->planeheight, yslope[y]);
distance = FixedMul(planeheight, yslope[y]);
dsvars->xstep = FixedMul(distance,basexscale);
dsvars->ystep = FixedMul(distance,baseyscale);

Expand Down Expand Up @@ -1257,7 +1230,7 @@ static void R_DoDrawPlane(visplane_t *pl)
xoffs = pl->xoffs; // killough 2/28/98: Add offsets
yoffs = pl->yoffs;

_g->planeheight = D_abs(pl->height-viewz);
planeheight = D_abs(pl->height-viewz);

dsvars.colormap = R_LoadColorMap(pl->lightlevel);

Expand All @@ -1270,8 +1243,6 @@ static void R_DoDrawPlane(visplane_t *pl)
{
R_MakeSpans(x,pl->top[x-1],pl->bottom[x-1], pl->top[x],pl->bottom[x], &dsvars);
}

W_UnlockLumpNum(_g->firstflat + flattranslation[pl->picnum]);
}
}
}
Expand Down
Loading

0 comments on commit 8551d44

Please sign in to comment.