- got rid of all tile index constants in Exhumed.

This commit is contained in:
Christoph Oelckers 2023-05-20 18:57:19 +02:00
parent c707167c94
commit 1b2a249243
11 changed files with 73 additions and 28 deletions

View file

@ -125,10 +125,10 @@ void menu_DoPlasma()
if (!PlasmaBuffer)
{
auto pixels = GetWritablePixels(tileGetTextureID(kPlasmaTile1));
auto pixels = GetWritablePixels(aTexIds[kTexPlasmaTile1]);
memset(pixels, 96, kPlasmaWidth * kPlasmaHeight);
PlasmaBuffer = GetWritablePixels(tileGetTextureID(kPlasmaTile2));
PlasmaBuffer = GetWritablePixels(aTexIds[kTexPlasmaTile2]);
memset(PlasmaBuffer, 96, kPlasmaWidth * kPlasmaHeight);
nSmokeLeft = 160 - logowidth / 2;

View file

@ -463,7 +463,7 @@ HITSPRITE:
else if (pHitWall != nullptr)
{
HITWALL:
if (pHitWall->walltexture == tileGetTextureID(kEnergy1))
if (pHitWall->walltexture == aTexIds[kTexEnergy1])
{
if (pHitWall->twoSided())
{

View file

@ -222,7 +222,7 @@ void DrawClock()
{
int ebp = 49;
auto pixels = GetWritablePixels(tileGetTextureID(kClockTile));
auto pixels = GetWritablePixels(aTexIds[kTexClockTile]);
memset(pixels, TRANSPARENT_INDEX, 4096);
@ -237,11 +237,11 @@ void DrawClock()
while (nVal)
{
int v2 = nVal & 0xF;
auto texid = tileGetTextureID(v2 + kClockSymbol1);
auto texid = aTexIds[v2 + kTexClockSymbol1];
auto tex = TexMan.GetGameTexture(texid);
int yPos = 32 - tex->GetTexelHeight() / 2;
CopyTileToBitmap(texid, tileGetTextureID(kClockTile), ebp - tex->GetTexelWidth() / 2, yPos);
CopyTileToBitmap(texid, aTexIds[kTexClockTile], ebp - tex->GetTexelWidth() / 2, yPos);
ebp -= 15;
@ -389,6 +389,18 @@ static void SetTileNames(TilesetBuildInfo& info)
void GameInterface::SetupSpecialTextures(TilesetBuildInfo& info)
{
// This is the ONLY place that should use tile indices!
enum
{
kPlasmaTile1 = 4092,
kPlasmaTile2 = 4093,
kClockTile = 3603,
kEnergy1 = 3604,
kEnergy2 = 3605,
kTileLoboLaptop = 3623,
kTileRamsesWorkTile = 591,
};
SetTileNames(info);
info.CreateWritable(kPlasmaTile1, kPlasmaWidth, kPlasmaHeight);
info.CreateWritable(kPlasmaTile2, kPlasmaWidth, kPlasmaHeight);

View file

@ -91,7 +91,7 @@ void InitEnergyTile();
void setvalidpic(DExhumedActor* actor)
{
// all we want here is setting it to something that passes renderer validation. This is never used to draw the sprite.
actor->spr.setspritetexture(tileGetTextureID(1));
actor->spr.setspritetexture(aTexIds[kTexTorch1]);
}
extern int EndLevel;

View file

@ -91,8 +91,8 @@ void DoEnergyTile()
{
nButtonColor += nButtonColor < 0 ? 8 : 0;
auto energy1 = GetWritablePixels(tileGetTextureID(kEnergy1));
auto energy2 = GetWritablePixels(tileGetTextureID(kEnergy2));
auto energy1 = GetWritablePixels(aTexIds[kTexEnergy1]);
auto energy2 = GetWritablePixels(aTexIds[kTexEnergy2]);
uint8_t* ptr1 = energy1 + 1984;
uint8_t* ptr2 = energy1 + 2048;

View file

@ -5,7 +5,13 @@ x(WeaponSpriteM60, 490)
x(WeaponSpriteFlamethrower, 491)
x(TileRamsesGold, 590)
x(TileRamsesWorkTile, 591)
x(TileRamsesNormal, 592)
x(TileRamsesNormal1, 592)
x(TileRamsesNormal2, 593)
x(TileRamsesNormal3, 594)
x(TileRamsesNormal4, 595)
x(TileRamsesMouth1, 598)
x(TileRamsesMouth2, 599)
x(TileRamsesMouth3, 600)
x(TileStatusBar, 657)
x(KeyIcon1, 675)
x(KeyIcon2, 679)

View file

@ -20,12 +20,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS
/*
#define x(a, b) k##a = b,
enum
{
#include "namelist.h"
};
#undef x
*/
END_PS_NS

View file

@ -1398,7 +1398,7 @@ DExhumedActor* BuildSpark(DExhumedActor* pActor, int nVal)
if (nVal >= 2)
{
pSpark->spr.setspritetexture(aTexIds[kTexENERGY2]);
pSpark->spr.setspritetexture(aTexIds[kTexEnergy2]);
nSmokeSparks++;
if (nVal == 3)
@ -1466,7 +1466,7 @@ void AISpark::Tick(RunListEvent* ev)
BuildSpark(pActor, 2);
}
if (pActor->spr.spritetexture() == aTexIds[kTexENERGY2]) {
if (pActor->spr.spritetexture() == aTexIds[kTexEnergy2]) {
return;
}
@ -1486,7 +1486,7 @@ void AISpark::Tick(RunListEvent* ev)
pActor->vel.Y = 0;
pActor->vel.Z = 0;
if (pActor->spr.spritetexture() == aTexIds[kTexENERGY2]) {
if (pActor->spr.spritetexture() == aTexIds[kTexEnergy2]) {
nSmokeSparks--;
}
@ -2590,7 +2590,7 @@ void PostProcess()
}
else // nMap == kMap20)
{
auto texid3603 = tileGetTextureID(kClockTile);
auto clocktile = aTexIds[kTexClockTile];
for(auto& sect: sector)
{
sect.pSoundSect = &sect;
@ -2598,7 +2598,7 @@ void PostProcess()
for(auto& wal : sect.walls)
{
if (wal.walltexture == texid3603)
if (wal.walltexture == clocktile)
{
wal.pal = 1;
auto pActor = insertActor(&sect, 407);
@ -2610,7 +2610,7 @@ void PostProcess()
ExhumedSpriteIterator it;
while (auto act = it.Next())
{
if (act->spr.statnum < kMaxStatus && act->spr.spritetexture() == texid3603)
if (act->spr.statnum < kMaxStatus && act->spr.spritetexture() == clocktile)
{
ChangeActorStat(act, 407);
act->spr.pal = 1;

View file

@ -75,8 +75,8 @@ void InitSpiritHead()
}
}
auto pTile = GetRawPixels(tileGetTextureID(kTileRamsesNormal)); // Ramses Normal Head
auto pGold = GetRawPixels(tileGetTextureID(kTileRamsesGold));
auto pTile = GetRawPixels(aTexIds[kTexTileRamsesNormal1]); // Ramses Normal Head
auto pGold = GetRawPixels(aTexIds[kTexTileRamsesGold]);
for (int x = 0; x < 97; x++)
{
for (int y = 0; y < 106; y++)
@ -117,7 +117,7 @@ void InitSpiritHead()
nHeadStage = 0;
// work tile is twice as big as the normal head size
auto Worktile = GetWritablePixels(tileGetTextureID(kTileRamsesWorkTile));
auto Worktile = GetWritablePixels(aTexIds[kTexTileRamsesWorkTile]);
pSpiritSpr->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
@ -171,7 +171,7 @@ void DimSector(sectortype* pSector)
void CopyHeadToWorkTile(int nTile, uint8_t* Worktile)
{
const uint8_t* pSrc = GetRawPixels(tileGetTextureID(nTile));
const uint8_t* pSrc = GetRawPixels(aTexIds[nTile]);
uint8_t *pDest = &Worktile[212 * 49 + 53];
for (unsigned i = 0; i < kSpiritY; i++)
@ -193,7 +193,7 @@ void DoSpiritHead()
{
static int dimSectCount = 0;
auto pSpiritSpr = pSpiritSprite;
auto Worktile = GetWritablePixels(tileGetTextureID(kTileRamsesWorkTile));
auto Worktile = GetWritablePixels(aTexIds[kTexTileRamsesWorkTile]);
const auto pPlayer = &PlayerList[0];
const auto pPlayerActor = pPlayer->pActor;
@ -242,10 +242,10 @@ void DoSpiritHead()
word_964E8 = RandomSize(5) + 4;
}
int tilenum = kTileRamsesNormal;
int tilenum = kTexTileRamsesNormal1;
if (--word_964EC < 3)
{
tilenum = 593;
tilenum = kTexTileRamsesNormal2;
if (word_964EC <= 0)
word_964EC = RandomSize(6) + 4;
}
@ -262,7 +262,7 @@ void DoSpiritHead()
if (nMouthTile != 0)
{
FTextureID srctile = tileGetTextureID(nMouthTile + 598);
FTextureID srctile = aTexIds[nMouthTile + kTexTileRamsesMouth1];
auto src = GetRawPixels(srctile);
auto tex = TexMan.GetGameTexture(srctile);
int sizx = tex->GetTexelWidth();
@ -424,7 +424,7 @@ void DoSpiritHead()
}
if (PlayClock - lHeadStartClock > 600)
CopyHeadToWorkTile(590, Worktile);
CopyHeadToWorkTile(kTexTileRamsesGold, Worktile);
if (nCount < (15 * nPixels) / 16) {
SoundBigEntrance();
@ -432,7 +432,7 @@ void DoSpiritHead()
AddFlash(pSpiritSpr->sector(), pSpiritSpr->spr.pos, 128);
nHeadStage = 3;
TintPalette(255, 255, 255);
CopyHeadToWorkTile(kTileRamsesNormal, Worktile);
CopyHeadToWorkTile(kTexTileRamsesNormal1, Worktile);
}
}
break;

View file

@ -1,5 +1,4 @@
// list of textures that get referenced directly in game code.
x(ENERGY2)
x(Spark1)
x(Spark2)
x(Playermarker1)
@ -36,3 +35,29 @@ x(Urn4)
x(SkullHead)
x(SkullJaw)
x(TileLoboLaptop)
x(Energy1)
x(Energy2)
x(ClockSymbol1)
x(ClockSymbol2)
x(ClockSymbol3)
x(ClockSymbol4)
x(ClockSymbol5)
x(ClockSymbol6)
x(ClockSymbol7)
x(ClockSymbol8)
x(ClockSymbol9)
x(ClockSymbol10)
x(ClockSymbol11)
x(ClockSymbol12)
x(ClockSymbol13)
x(ClockSymbol14)
x(ClockSymbol15)
x(ClockSymbol16)
x(TileRamsesNormal1)
x(TileRamsesNormal2)
x(TileRamsesNormal3)
x(TileRamsesNormal4)
x(TileRamsesGold)
x(TileRamsesMouth1)
x(TileRamsesMouth2)
x(TileRamsesMouth3)

View file

@ -307,7 +307,7 @@ void GameInterface::processSprites(tspriteArray& tsprites, const DVector3& view,
pTSprite->pal = RemapPLU(pTSprite->pal);
// PowerSlaveGDX: Torch bouncing fix
if ((pTSprite->picnum == kTorch1 || pTSprite->picnum == kTorch2) && (pTSprite->cstat & CSTAT_SPRITE_YCENTER) == 0)
if ((pTSprite->spritetexture() == aTexIds[kTexTorch1] || pTSprite->spritetexture() == aTexIds[kTexTorch2]) && (pTSprite->cstat & CSTAT_SPRITE_YCENTER) == 0)
{
pTSprite->cstat |= CSTAT_SPRITE_YCENTER;
auto tex = TexMan.GetGameTexture(pTSprite->spritetexture());