Properly cache animations at level start. Switches still need some caching code. Added a debug cache flag for use in the sim to w_wad.c. Should be taken out when switches are handled.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9706 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2006-04-17 19:42:08 +00:00
parent 239564c80e
commit 08b417f149
3 changed files with 51 additions and 4 deletions

View file

@ -95,8 +95,8 @@ typedef struct
#define MAXANIMS 32 // no longer a strict limit -- killough #define MAXANIMS 32 // no longer a strict limit -- killough
static anim_t* lastanim; anim_t* lastanim;
static anim_t* anims; // new structure w/o limits -- killough anim_t* anims; // new structure w/o limits -- killough
static size_t maxanims; static size_t maxanims;
// killough 3/7/98: Initialize generalized scrolling // killough 3/7/98: Initialize generalized scrolling

View file

@ -897,10 +897,36 @@ int R_TextureNumForName(const char *name) // const added -- killough
// to avoid using alloca(), and to improve performance. // to avoid using alloca(), and to improve performance.
// cph - new wad lump handling, calls cache functions but acquires no locks // cph - new wad lump handling, calls cache functions but acquires no locks
// Structures from p_spec.c
// Used to fully cache animations in the level -> avoids stalls on Hard Drive Systems
typedef struct
{
boolean istexture;
int picnum;
int basepic;
int numpics;
int speed;
} anim_t;
extern anim_t* anims;
extern anim_t* lastanim;
anim_t * isAnim(int flatnum, boolean texcheck)
{
anim_t *checkf;
for(checkf=anims; checkf<lastanim; checkf++)
{
if((flatnum>=checkf->basepic || flatnum<=checkf->numpics)&&checkf->istexture==texcheck)
return checkf;
}
return 0;
}
void R_PrecacheLevel(void) void R_PrecacheLevel(void)
{ {
register int i; register int i, j;
register byte *hitlist; register byte *hitlist;
anim_t *cacheanim;
if (demoplayback) if (demoplayback)
return; return;
@ -916,6 +942,14 @@ void R_PrecacheLevel(void)
for (i = numsectors; --i >= 0; ) for (i = numsectors; --i >= 0; )
hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1; hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1;
// If flat is an animation, load those too
// Definately not the most efficient, but better then stalls in game
for(i=0; i<numflats; i++)
if(hitlist[i])
if((cacheanim=isAnim(i,0)))
for(j=0; j<cacheanim->numpics; j++)
hitlist[cacheanim->basepic+j]=1;
for (i = numflats; --i >= 0; ) for (i = numflats; --i >= 0; )
if (hitlist[i]) if (hitlist[i])
(W_CacheLumpNum)(firstflat + i, 0); (W_CacheLumpNum)(firstflat + i, 0);
@ -929,6 +963,14 @@ void R_PrecacheLevel(void)
hitlist[sides[i].toptexture] = hitlist[sides[i].toptexture] =
hitlist[sides[i].midtexture] = 1; hitlist[sides[i].midtexture] = 1;
// If texture is an animation, load those too
// Definately not the most efficient, but better then stalls in game
for(i=0; i<numsides; i++)
if(hitlist[i])
if((cacheanim=isAnim(i,1)))
for(j=0; j<cacheanim->numpics; j++)
hitlist[cacheanim->basepic+j]=1;
// Sky texture is always present. // Sky texture is always present.
// Note that F_SKY1 is the name used to // Note that F_SKY1 is the name used to
// indicate a sky floor/ceiling as a flat, // indicate a sky floor/ceiling as a flat,

View file

@ -494,7 +494,7 @@ int W_LumpLength (int lump)
// Loads the lump into the given buffer, // Loads the lump into the given buffer,
// which must be >= W_LumpLength(). // which must be >= W_LumpLength().
// //
#undef DEBUGCACHE
void W_ReadLump(int lump, void *dest) void W_ReadLump(int lump, void *dest)
{ {
lumpinfo_t *l = lumpinfo + lump; lumpinfo_t *l = lumpinfo + lump;
@ -512,6 +512,11 @@ void W_ReadLump(int lump, void *dest)
{ {
int c; int c;
#if DEBUGCACHE
if(gamestate==GS_LEVEL)
printf("Loading %s\n", lumpinfo[lump].name);
#endif
// killough 1/31/98: Reload hack (-wart) removed // killough 1/31/98: Reload hack (-wart) removed
lseek(l->handle, l->position, SEEK_SET); lseek(l->handle, l->position, SEEK_SET);