Skip to content

Commit

Permalink
- animation precaching cleanup.
Browse files Browse the repository at this point in the history
No need to handle animations on the,game side. markTileForPrecache already handles this - now also for oscillating animations.
  • Loading branch information
coelckers committed Aug 5, 2022
1 parent 4f21706 commit 738c133
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 69 deletions.
4 changes: 2 additions & 2 deletions source/core/precache.cpp
Expand Up @@ -102,15 +102,15 @@ TMap<int64_t, bool> cachemap;
void markTileForPrecache(int tilenum, int palnum)
{
int i, j;
if ((picanm[tilenum].sf & PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK)
if (picanm[tilenum].type() == PICANM_ANIMTYPE_BACK)
{
i = tilenum - picanm[tilenum].num;
j = tilenum;
}
else
{
i = tilenum;
j = tilenum + picanm[tilenum].num;
j = tilenum + picanm[tilenum].num * ((picanm[tilenum].type() == PICANM_ANIMTYPE_OSC) ? 2 : 1);
}

for (; i <= j; i++)
Expand Down
6 changes: 3 additions & 3 deletions source/core/textures/buildtiles.cpp
Expand Up @@ -818,9 +818,9 @@ int tileAnimateOfs(int tilenum, int randomize)
frametime += Bcrc32(&randomize, 2, 0);
}

int curframe = (frametime & 0x7fffffff) >> (picanm[tilenum].sf & PICANM_ANIMSPEED_MASK);
int curframe = (frametime & 0x7fffffff) >> (picanm[tilenum].speed());

switch (picanm[tilenum].sf & PICANM_ANIMTYPE_MASK)
switch (picanm[tilenum].type())
{
case PICANM_ANIMTYPE_FWD:
return curframe % (framecount + 1);
Expand Down Expand Up @@ -869,7 +869,7 @@ void tileUpdateAnimations()
{
for (int i = 0; i < MAXTILES; i++)
{
if (TileFiles.tiledata[i].picanm.sf & PICANM_ANIMTYPE_MASK)
if (TileFiles.tiledata[i].picanm.type())
{
int j = i + tileAnimateOfs(i);

Expand Down
13 changes: 12 additions & 1 deletion source/core/textures/buildtiles.h
Expand Up @@ -61,6 +61,17 @@ struct picanm_t
extra = sf = 0;
num = 0;
}

int speed()
{
return sf & PICANM_ANIMSPEED_MASK;
}

int type()
{
return sf & PICANM_ANIMTYPE_MASK;
}

};
picanm_t tileConvertAnimFormat(int32_t const picanmdisk, int* lo, int* to);

Expand Down Expand Up @@ -467,7 +478,7 @@ inline void tileUpdatePicnum(int* const tileptr, bool mayrotate = false, int ran
{
auto& tile = *tileptr;

if (picanm[tile].sf & PICANM_ANIMTYPE_MASK)
if (picanm[tile].type())
tile += tileAnimateOfs(tile, randomize);

if (mayrotate && RotTile(tile).newtile != -1)
Expand Down
18 changes: 1 addition & 17 deletions source/games/blood/src/preload.cpp
Expand Up @@ -62,23 +62,7 @@ void tilePrecacheTile(int nTile, int nType, int palette)
}
while (n--)
{
if (picanm[nTile].sf & PICANM_ANIMTYPE_MASK)
{
for (int frame = picanm[nTile].num; frame >= 0; frame--)
{
int tile;
if ((picanm[nTile].sf & PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK)
tile = nTile - frame;
else
tile = nTile + frame;

markTileForPrecache(tile, palette);
}
}
else
{
markTileForPrecache(nTile, palette);
}
markTileForPrecache(nTile, palette);
nTile += 1 + picanm[nTile].num;
}
}
Expand Down
11 changes: 0 additions & 11 deletions source/games/exhumed/src/enginesubs.cpp
Expand Up @@ -42,29 +42,20 @@ void precache()
{
int j = sect.ceilingpicnum;
markTileForPrecache(j, sect.ceilingpal);
if (picanm[j].sf & PICANM_ANIMTYPE_MASK)
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, sect.ceilingpal);

j = sect.floorpicnum;
markTileForPrecache(j, sect.floorpal);
if (picanm[j].sf & PICANM_ANIMTYPE_MASK)
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, sect.floorpal);
}

for(auto& wal : wall)
{
int j = wal.picnum;
markTileForPrecache(j, wal.pal);
if (picanm[j].sf & PICANM_ANIMTYPE_MASK)
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, wal.pal);

if (wal.twoSided())
{
j = wal.overpicnum;
markTileForPrecache(j, wal.pal);
if (picanm[j].sf & PICANM_ANIMTYPE_MASK)
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, wal.pal);

}
}

Expand All @@ -73,8 +64,6 @@ void precache()
{
int j = ac->spr.picnum;
markTileForPrecache(j, ac->spr.pal);
if (picanm[j].sf & PICANM_ANIMTYPE_MASK)
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, ac->spr.pal);
}
precacheMarkedTiles();
}
Expand Down
35 changes: 0 additions & 35 deletions source/games/sw/src/cache.cpp
Expand Up @@ -80,54 +80,19 @@ void precacheMap(void)
j = sec.ceilingpicnum;
markTileForPrecache(j, sec.ceilingpal);

if ((picanm[j].sf & PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT)
{
for (i = 1; i <= picanm[j].num; i++)
{
markTileForPrecache(j + i, sec.ceilingpal);
}
}

j = sec.floorpicnum;

markTileForPrecache(j, sec.floorpal);

if ((picanm[j].sf & PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT)
{
for (i = 1; i <= picanm[j].num; i++)
{
markTileForPrecache(j + i, sec.floorpal);
}
}

}

for (auto& wal : wall)
{
j = wal.picnum;

markTileForPrecache(j, wal.pal);

if ((picanm[j].sf & PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT)
{
for (i = 1; i <= picanm[j].num; i++)
{
markTileForPrecache(j + i, wal.pal);
}
}

if (wal.overpicnum > 0 && wal.overpicnum < MAXTILES)
{
j = wal.overpicnum;
markTileForPrecache(j, wal.pal);

if ((picanm[j].sf & PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT)
{
for (i = 1; i <= picanm[j].num; i++)
{
markTileForPrecache(j + i, wal.pal);
}
}
}
}
}
Expand Down

0 comments on commit 738c133

Please sign in to comment.