- eliminated half of the remaining tileWidth and tileHeight calls.

This commit is contained in:
Christoph Oelckers 2022-12-09 14:24:36 +01:00
parent e78fd90f67
commit c41dc29885
12 changed files with 57 additions and 41 deletions

View file

@ -1692,7 +1692,7 @@ static double getRangeAttackDist(DBloodActor* actor, double minDist, double maxD
int dist = 0;
int seqId = actor->xspr.data2;
int mul = 550;
int picnum = actor->spr.picnum;
auto texid = actor->spr.spritetexture();
if (yscale > 0)
{
@ -1701,11 +1701,11 @@ static double getRangeAttackDist(DBloodActor* actor, double minDist, double maxD
Seq* pSeq = getSequence(seqId);
if (pSeq)
{
picnum = seqGetTile(&pSeq->frames[0]);
texid = seqGetTexture(&pSeq->frames[0]);
}
}
dist = tileHeight(picnum) << 8;
auto tex = TexMan.GetGameTexture(texid);
dist = int(tex->GetDisplayHeight() * 256);
if (yscale < 64) dist -= (64 - yscale) * mul;
else if (yscale > 64) dist += (yscale - 64) * (mul / 3);
}

View file

@ -119,6 +119,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
auto pTSprite = tsprites.get(nTSprite);
auto owneractor = static_cast<DBloodActor*>(pTSprite->ownerActor);
if (gDetail < effectDetail[nViewEffect]) return NULL;
auto pTTex = TexMan.GetGameTexture(pTSprite->spritetexture());
switch (nViewEffect)
{
case kViewEffectSpotProgress: {
@ -289,7 +290,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
pNSprite->pos.Z = pTSprite->pos.Z;
pNSprite->picnum = 908;
pNSprite->statnum = kStatDecoration;
s = (tileWidth(pTSprite->picnum) * pTSprite->scale.X) / 64.;
s = (pTTex->GetDisplayWidth() * pTSprite->scale.X) / 64.;
pNSprite->scale = DVector2(s, s);
break;
}
@ -340,7 +341,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
pNSprite->pos.Z = top;
pNSprite->picnum = 2101;
pNSprite->shade = -128;
s = (tileWidth(pTSprite->picnum) * pTSprite->scale.X) / 32.;
s = (pTTex->GetDisplayWidth() * pTSprite->scale.X) / 32.;
pNSprite->scale = DVector2(s, s);
break;
}
@ -355,7 +356,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
pNSprite->pos.Z = bottom;
pNSprite->picnum = 2101;
pNSprite->shade = -128;
s = (tileWidth(pTSprite->picnum) * pTSprite->scale.X) / 32.;
s = (pTTex->GetDisplayWidth() * pTSprite->scale.X) / 32.;
pNSprite->scale = DVector2(s, s);
break;
}

View file

@ -692,7 +692,7 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
int top = 0;
if (gGameOptions.nGameType > 0 && gGameOptions.nGameType <= 3)
{
top = (tileHeight(2229) * ((gNetPlayers + 3) / 4));
top = (tileHeight(kSBPlayerSlot) * ((gNetPlayers + 3) / 4));
}
return { top, 25 };
}

View file

@ -1423,7 +1423,7 @@ int getSpriteMassBySize(DBloodActor* actor)
return cached->mass;
}
int picnum = actor->spr.picnum;
auto texid = actor->spr.spritetexture();
int massDiv = 30;
int addMul = 2;
int subMul = 2;
@ -1433,15 +1433,15 @@ int getSpriteMassBySize(DBloodActor* actor)
auto pSeq = getSequence(seqId);
if (pSeq)
{
picnum = seqGetTile(&pSeq->frames[0]);
texid = seqGetTexture(&pSeq->frames[0]);
}
else
picnum = actor->spr.picnum;
}
auto tex = TexMan.GetGameTexture(texid);
if (!tex) return 0;
clipDist = max(actor->clipdist, 0.25);
int x = tileWidth(picnum);
int y = tileHeight(picnum);
int x = (int)tex->GetDisplayWidth();
int y = (int)tex->GetDisplayHeight();
int xscale = int(actor->spr.scale.X * 64);
int yscale = int(actor->spr.scale.Y * 64);

View file

@ -60,13 +60,17 @@ void DrawAbs(int tile, double x, double y, int shade = 0)
DrawTexture(twod, tileGetTexture(tile), x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TopLeft, true, DTA_Color, shadeToLight(shade), TAG_DONE);
}
void DrawRel(int tile, double x, double y, int shade)
void DrawRel(FGameTexture* tex, double x, double y, int shade = 0)
{
// This is slightly different than what the backend does here, but critical for some graphics.
auto tex = tileGetTexture(tile);
int offx = (int(tex->GetDisplayWidth()) >> 1) + int(tex->GetDisplayLeftOffset());
int offy = (int(tex->GetDisplayHeight()) >> 1) + int(tex->GetDisplayTopOffset());
DrawAbs(tile, x - offx, y - offy, shade);
DrawTexture(twod, tex, x - offx, y - offy, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TopLeft, true, DTA_Color, shadeToLight(shade), TAG_DONE);
}
void DrawRel(int tile, double x, double y, int shade)
{
DrawRel(tileGetTexture(tile), x, y, shade);
}
//---------------------------------------------------------------------------
@ -102,9 +106,10 @@ enum
void menu_DoPlasma()
{
auto nLogoTile = GameLogo();
int lw = tileWidth(nLogoTile);
int lh = tileHeight(nLogoTile);
auto nLogoTexid = GameLogo();
auto pLogoTex = TexMan.GetGameTexture(nLogoTexid);
int lw = (int)pLogoTex->GetDisplayWidth();
int lh = (int)pLogoTex->GetDisplayHeight();
int ptile = nPlasmaTile;
int pclock = I_GetBuildTime();
@ -233,7 +238,7 @@ void menu_DoPlasma()
r_ebx += 2;
}
auto logopix = GetRawPixels(tileGetTextureID(nLogoTile));
auto logopix = GetRawPixels(nLogoTexid);
for (int j = 0; j < 5; j++)
{
@ -303,7 +308,7 @@ void menu_DoPlasma()
}
}
DrawAbs(ptile, 0, 0);
DrawRel(nLogoTile, 160, 40);
DrawRel(pLogoTex, 160, 40);
// draw the fire urn/lamp thingies
int dword_9AB5F = (pclock / 16) & 3;

View file

@ -93,7 +93,7 @@ using namespace Exhumed;
DEFINE_ACTION_FUNCTION(_ListMenuItemExhumedLogo, Draw)
{
auto nLogoTile = GameLogo();
DrawRel(nLogoTile, 160, 40);
DrawRel(TexMan.GetGameTexture(nLogoTile), 160, 40);
return 0;
}

View file

@ -117,7 +117,7 @@ void GameInterface::loadPalette()
LoadPaletteLookups();
}
void CopyTileToBitmap(int nSrcTile, int nDestTile, int xPos, int yPos);
void CopyTileToBitmap(FTextureID nSrcTile, FTextureID nDestTile, int xPos, int yPos);
// void TestSaveLoad();
void LoadStatus();
@ -252,9 +252,11 @@ void DrawClock()
while (nVal)
{
int v2 = nVal & 0xF;
auto texid = tileGetTextureID(v2 + kClockSymbol1);
auto tex = TexMan.GetGameTexture(texid);
int yPos = 32 - tileHeight(v2 + kClockSymbol1) / 2;
CopyTileToBitmap(v2 + kClockSymbol1, kTile3603, ebp - tileWidth(v2 + kClockSymbol1) / 2, yPos);
CopyTileToBitmap(texid, tileGetTextureID(kTile3603), ebp - tex->GetTexelWidth() / 2, yPos);
ebp -= 15;
@ -622,20 +624,24 @@ void DeleteActor(DExhumedActor* actor)
//
//---------------------------------------------------------------------------
void CopyTileToBitmap(int nSrcTile, int nDestTile, int xPos, int yPos)
void CopyTileToBitmap(FTextureID nSrcTile, FTextureID nDestTile, int xPos, int yPos)
{
int nOffs = tileHeight(nDestTile) * xPos;
auto pSrcTex = TexMan.GetGameTexture(nSrcTile);
auto pDestTex = TexMan.GetGameTexture(nDestTile);
int nOffs = pDestTex->GetTexelHeight() * xPos;
auto pixels = GetWritablePixels(tileGetTextureID(nDestTile));
auto pixels = GetWritablePixels(nDestTile);
if (!pixels) return;
uint8_t *pDest = pixels + nOffs + yPos;
uint8_t *pDestB = pDest;
int destYSize = tileHeight(nDestTile);
int srcYSize = tileHeight(nSrcTile);
int destYSize = pDestTex->GetTexelHeight();
int srcYSize = pSrcTex->GetTexelHeight();
const uint8_t *pSrc = GetRawPixels(tileGetTextureID(nSrcTile));
const uint8_t *pSrc = GetRawPixels(nSrcTile);
if (!pSrc) return;
for (int x = 0; x < tileWidth(nSrcTile); x++)
for (int x = 0; x < pSrcTex->GetTexelWidth(); x++)
{
pDest += destYSize;

View file

@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "names.h"
#include "exhumedactor.h"
#include "serialize_obj.h"
#include "texturemanager.h"
BEGIN_PS_NS
@ -142,9 +143,9 @@ extern bool bDoFlashes;
extern int bVanilla;
inline int GameLogo()
inline FTextureID GameLogo()
{
return (g_gameType & GAMEFLAG_EXHUMED) ? kExhumedLogo : kPowerslaveLogo;
return TexMan.CheckForTexture((g_gameType & GAMEFLAG_EXHUMED) ? "ExhumedLogo" : "PowerslaveLogo", ETextureType::Any);
}
extern double g_frameDelay;

View file

@ -117,7 +117,7 @@ void GameInterface::DrawBackground()
DrawRel(kSkullHead, 160, 100, 0);
DrawRel(kSkullJaw, 161, 130, 0);
DrawRel(nLogoTile, 160, 40, 0);
DrawRel(TexMan.GetGameTexture(nLogoTile), 160, 40, 0);
// draw the fire urn/lamp thingies
DrawRel(kTile3512 + dword_9AB5F, 50, 150, 0);

View file

@ -258,10 +258,11 @@ void DoSpiritHead()
if (nMouthTile != 0)
{
int srctile = nMouthTile + 598;
auto src = GetRawPixels(tileGetTextureID(srctile));
int sizx = tileWidth(srctile);
int sizy = tileHeight(srctile);
FTextureID srctile = tileGetTextureID(nMouthTile + 598);
auto src = GetRawPixels(srctile);
auto tex = TexMan.GetGameTexture(srctile);
int sizx = tex->GetTexelWidth();
int sizy = tex->GetTexelHeight();
int workptr = 212 * (97 - sizx / 2) + 159 - sizy;
int srcptr = 0;
while (sizx > 0)

View file

@ -185,7 +185,8 @@ void AISpider::Tick(RunListEvent* ev)
if (spp->spr.cstat & CSTAT_SPRITE_YFLIP)
{
spp->vel.Z = 0;
spp->spr.pos.Z = pSector->ceilingz + (tileHeight(spp->spr.picnum) / 8.); // was << 5 in Build coordinates
auto tex = TexMan.GetGameTexture(spp->spr.spritetexture());
spp->spr.pos.Z = pSector->ceilingz + (tex->GetDisplayHeight() / 8.); // was << 5 in Build coordinates
if (pSector->ceilingstat & CSTAT_SECTOR_SKY)
{

View file

@ -105,7 +105,8 @@ static void analyzesprites(tspriteArray& tsprites, const DVector3& view, double
if ((pTSprite->picnum == kTorch1 || pTSprite->picnum == kTorch2) && (pTSprite->cstat & CSTAT_SPRITE_YCENTER) == 0)
{
pTSprite->cstat |= CSTAT_SPRITE_YCENTER;
double nTileY = (tileHeight(pTSprite->picnum) * pTSprite->scale.Y) * 0.5;
auto tex = TexMan.GetGameTexture(pTSprite->spritetexture());
double nTileY = (tex->GetDisplayHeight() * pTSprite->scale.Y) * 0.5;
pTSprite->pos.Z -= nTileY;
}