From 8551d44d26fb74813bc595ced740a8b1f9cb9c0e Mon Sep 17 00:00:00 2001 From: Zak Larue-Buckley Date: Thu, 10 Oct 2019 23:15:59 +0100 Subject: [PATCH] Remove/tidy up unused code. --- GBADoom.pro | 1 - include/global_data.h | 5 --- include/i_system.h | 2 - include/w_wad.h | 39 ++---------------- source/g_game.c | 5 +-- source/i_system.c | 16 +------- source/i_video.c | 2 - source/p_setup.c | 28 ++----------- source/p_spec.c | 19 ++------- source/p_switch.c | 4 +- source/r_data.c | 5 ++- source/r_hotpath.iwram.c | 37 ++--------------- source/r_plane.c | 18 -------- source/r_things.c | 2 - source/v_video.c | 1 - source/w_memcache.c | 88 ---------------------------------------- source/w_wad.c | 42 ++----------------- 17 files changed, 24 insertions(+), 290 deletions(-) delete mode 100644 source/w_memcache.c diff --git a/GBADoom.pro b/GBADoom.pro index 200ca81..52d8374 100644 --- a/GBADoom.pro +++ b/GBADoom.pro @@ -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 \ diff --git a/include/global_data.h b/include/global_data.h index 57b6932..249b998 100644 --- a/include/global_data.h +++ b/include/global_data.h @@ -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 diff --git a/include/i_system.h b/include/i_system.h index a3edacd..425eecb 100644 --- a/include/i_system.h +++ b/include/i_system.h @@ -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 */ diff --git a/include/w_wad.h b/include/w_wad.h index c05cef1..df60798 100644 --- a/include/w_wad.h +++ b/include/w_wad.h @@ -57,35 +57,12 @@ 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); @@ -93,23 +70,13 @@ 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 diff --git a/source/g_game.c b/source/g_game.c index 14b6ae2..477c5a0 100644 --- a/source/g_game.c +++ b/source/g_game.c @@ -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 diff --git a/source/i_system.c b/source/i_system.c index 60e1ade..4545508 100644 --- a/source/i_system.c +++ b/source/i_system.c @@ -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; } diff --git a/source/i_video.c b/source/i_video.c index 10f0aeb..8987077 100644 --- a/source/i_video.c +++ b/source/i_video.c @@ -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) diff --git a/source/p_setup.c b/source/p_setup.c index 94c2117..2621e77 100644 --- a/source/p_setup.c +++ b/source/p_setup.c @@ -80,9 +80,6 @@ static void P_LoadVertexes (int lump) _g->vertexes[i].x = SHORT(data[i].x)<vertexes[i].y = SHORT(data[i].y)<backsector = 0; } - - W_UnlockLumpNum(lump); // cph - release the data } // @@ -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 } // @@ -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 } @@ -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 } // @@ -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 @@ -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 } // @@ -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]<bmaporgy = _g->blockmaplump[1]<bmapwidth = _g->blockmaplump[2]; @@ -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); @@ -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", @@ -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; } diff --git a/source/p_spec.c b/source/p_spec.c index 49ecd08..fee014f 100644 --- a/source/p_spec.c +++ b/source/p_spec.c @@ -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); @@ -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++; } @@ -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); } } } diff --git a/source/p_switch.c b/source/p_switch.c index 4cedef8..ccfd185 100644 --- a/source/p_switch.c +++ b/source/p_switch.c @@ -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); } } } diff --git a/source/r_data.c b/source/r_data.c index e6c195d..ab5369c 100644 --- a/source/r_data.c +++ b/source/r_data.c @@ -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; } @@ -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; diff --git a/source/r_hotpath.iwram.c b/source/r_hotpath.iwram.c index 62a535c..3ee3ee5 100644 --- a/source/r_hotpath.iwram.c +++ b/source/r_hotpath.iwram.c @@ -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 @@ -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]; @@ -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); @@ -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); @@ -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]); } } } diff --git a/source/r_plane.c b/source/r_plane.c index a2eebe6..41f73ce 100644 --- a/source/r_plane.c +++ b/source/r_plane.c @@ -71,24 +71,6 @@ void R_InitPlanes (void) { } -// -// R_MapPlane -// -// Uses global vars: -// planeheight -// dsvars.source -// basexscale -// baseyscale -// viewx -// viewy -// xoffs -// yoffs -// -// BASIC PRIMITIVE -// - - - // // R_ClearPlanes // At begining of frame. diff --git a/source/r_things.c b/source/r_things.c index 299326e..50efdd7 100644 --- a/source/r_things.c +++ b/source/r_things.c @@ -174,8 +174,6 @@ static void R_InitSpriteDefs(const char * const * namelist) { const char* sn = W_GetNameForNum(j + _g->firstspritelump); - //register lumpinfo_t *lump = _g->lumpinfo + j + _g->firstspritelump; - // Fast portable comparison -- killough // (using int pointer cast is nonportable): diff --git a/source/v_video.c b/source/v_video.c index 37283c6..20002c5 100644 --- a/source/v_video.c +++ b/source/v_video.c @@ -139,7 +139,6 @@ void V_DrawBackground(const char* flatname, int scrn) for (x=y ? 0 : 64; x= header->numlumps) return NULL; - fileinfo = (filelump_t*)&doom_iwad[header->infotableofs]; + fileinfo = (const filelump_t*)&doom_iwad[header->infotableofs]; return &fileinfo[num]; } @@ -249,15 +249,10 @@ void W_Init(void) if (!_g->numlumps) I_Error ("W_Init: No files found"); - - /* cph 2001/07/07 - separated cache setup */ - lprintf(LO_INFO,"W_InitCache\n"); - W_InitCache(); } void W_ReleaseAllWads(void) { - W_DoneCache(); _g->numlumps = 0; } @@ -278,22 +273,6 @@ int W_LumpLength(int lump) I_Error ("W_LumpLength: %i >= numlumps",lump); } -// -// W_ReadLump -// Loads the lump into the given buffer, -// which must be >= W_LumpLength(). -// - -void W_ReadLump(int lump, void* dest) -{ - const filelump_t* l = FindLumpByNum(lump); - - if(l) - { - memcpy(dest, &doom_iwad[l->filepos], l->size); - } -} - const void* W_GetLumpPtr(int lump) { const filelump_t* l = FindLumpByNum(lump); @@ -306,22 +285,7 @@ const void* W_GetLumpPtr(int lump) return NULL; } -// Hash function used for lump names. -// Must be mod'ed with table size. -// Can be used for any 8-character names. -// by Lee Killough - -unsigned W_LumpNameHash(const char *s) +const void *W_CacheLumpNum(int lump) { - unsigned hash; - (void) ((hash = toupper(s[0]), s[1]) && - (hash = hash*3+toupper(s[1]), s[2]) && - (hash = hash*2+toupper(s[2]), s[3]) && - (hash = hash*2+toupper(s[3]), s[4]) && - (hash = hash*2+toupper(s[4]), s[5]) && - (hash = hash*2+toupper(s[5]), s[6]) && - (hash = hash*2+toupper(s[6]), - hash = hash*2+toupper(s[7])) - ); - return hash; + return W_GetLumpPtr(lump); }