2020-05-24 05:58:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "textures.h"
|
2020-04-10 16:17:26 +00:00
|
|
|
#include "image.h"
|
2020-05-24 17:12:22 +00:00
|
|
|
#include "i_time.h"
|
2020-06-20 16:17:49 +00:00
|
|
|
#include "intvec.h"
|
2020-05-24 11:53:27 +00:00
|
|
|
|
|
|
|
// picanm[].sf:
|
|
|
|
// |bit(1<<7)
|
|
|
|
// |animtype|animtype|texhitscan|nofullbright|speed|speed|speed|speed|
|
|
|
|
enum AnimFlags
|
|
|
|
{
|
|
|
|
PICANM_ANIMTYPE_NONE = 0,
|
|
|
|
PICANM_ANIMTYPE_OSC = (1 << 6),
|
|
|
|
PICANM_ANIMTYPE_FWD = (2 << 6),
|
|
|
|
PICANM_ANIMTYPE_BACK = (3 << 6),
|
|
|
|
|
|
|
|
PICANM_ANIMTYPE_SHIFT = 6,
|
|
|
|
PICANM_ANIMTYPE_MASK = (3 << 6), // must be 192
|
|
|
|
PICANM_MISC_MASK = (3 << 4),
|
|
|
|
PICANM_TEXHITSCAN_BIT = (2 << 4),
|
|
|
|
PICANM_NOFULLBRIGHT_BIT = (1 << 4),
|
|
|
|
PICANM_ANIMSPEED_MASK = 15, // must be 15
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAXTILES = 30720,
|
|
|
|
MAXUSERTILES = (MAXTILES-16) // reserve 16 tiles at the end
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-05-29 21:33:26 +00:00
|
|
|
enum ETexType
|
|
|
|
{
|
|
|
|
TT_INDEXED,
|
|
|
|
TT_TRUECOLOR,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-05-24 06:47:45 +00:00
|
|
|
enum class ReplacementType : int
|
|
|
|
{
|
|
|
|
Art,
|
|
|
|
Writable,
|
|
|
|
Restorable,
|
|
|
|
Canvas
|
|
|
|
};
|
|
|
|
|
2020-05-24 11:53:27 +00:00
|
|
|
|
|
|
|
// NOTE: If the layout of this struct is changed, loadpics() must be modified
|
|
|
|
// accordingly.
|
|
|
|
struct picanm_t
|
|
|
|
{
|
|
|
|
uint8_t num; // animate number
|
|
|
|
uint8_t sf; // anim. speed and flags
|
|
|
|
uint8_t extra;
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
extra = sf = num = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
picanm_t tileConvertAnimFormat(int32_t const picanmdisk, int* lo, int* to);
|
|
|
|
|
|
|
|
struct rottile_t
|
|
|
|
{
|
|
|
|
int16_t newtile;
|
|
|
|
int16_t owner;
|
|
|
|
};
|
|
|
|
|
2020-05-24 06:47:45 +00:00
|
|
|
struct HightileReplacement
|
|
|
|
{
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture* faces[6]; // only one gets used by a texture, the other 5 are for skyboxes only
|
2020-06-20 16:17:49 +00:00
|
|
|
FVector2 scale;
|
2020-05-24 06:47:45 +00:00
|
|
|
float alphacut, specpower, specfactor;
|
|
|
|
uint16_t palnum, flags;
|
|
|
|
};
|
|
|
|
|
2020-04-10 16:17:26 +00:00
|
|
|
class FTileTexture : public FImageSource
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-05-24 17:12:22 +00:00
|
|
|
FTileTexture()
|
2020-04-10 16:17:26 +00:00
|
|
|
{
|
|
|
|
bUseGamePalette = true;
|
|
|
|
bTranslucent = false;
|
|
|
|
}
|
2020-05-24 17:12:22 +00:00
|
|
|
virtual uint8_t* GetRawData() = 0;
|
2020-04-10 16:17:26 +00:00
|
|
|
virtual TArray<uint8_t> CreatePalettedPixels(int conversion);
|
|
|
|
virtual int CopyPixels(FBitmap* bmp, int conversion); // This will always ignore 'luminance'.
|
2020-05-24 05:58:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A tile coming from an ART file.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
class FArtTile : public FTileTexture
|
|
|
|
{
|
|
|
|
const TArray<uint8_t>& RawPixels;
|
|
|
|
const uint32_t Offset;
|
|
|
|
public:
|
2020-05-24 17:12:22 +00:00
|
|
|
FArtTile(const TArray<uint8_t>& backingstore, uint32_t offset, int width, int height)
|
2020-05-24 05:58:56 +00:00
|
|
|
: RawPixels(backingstore), Offset(offset)
|
|
|
|
{
|
2020-04-10 16:17:26 +00:00
|
|
|
Width = width;
|
|
|
|
Height = height;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
2020-05-24 17:12:22 +00:00
|
|
|
uint8_t* GetRawData() override final
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
2020-05-24 17:12:22 +00:00
|
|
|
return &RawPixels[Offset];
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A tile with its own pixel buffer
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
class FLooseTile : public FTileTexture
|
|
|
|
{
|
|
|
|
TArray<uint8_t> RawPixels;
|
|
|
|
public:
|
2020-05-24 17:12:22 +00:00
|
|
|
FLooseTile(TArray<uint8_t>& store, int width, int height)
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
|
|
|
RawPixels = std::move(store);
|
2020-04-10 16:17:26 +00:00
|
|
|
Width = width;
|
|
|
|
Height = height;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 17:12:22 +00:00
|
|
|
uint8_t* GetRawData() override
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
|
|
|
return RawPixels.Data();
|
|
|
|
}
|
2020-05-24 17:12:22 +00:00
|
|
|
|
2020-05-24 05:58:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A non-existent tile
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
class FDummyTile : public FTileTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FDummyTile(int width, int height)
|
|
|
|
{
|
2020-04-10 16:17:26 +00:00
|
|
|
Width = width;
|
|
|
|
Height = height;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 17:12:22 +00:00
|
|
|
uint8_t* GetRawData() override
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
2020-05-24 17:12:22 +00:00
|
|
|
return nullptr;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A tile with a writable surface
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
class FWritableTile : public FTileTexture
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
TArray<uint8_t> buffer;
|
|
|
|
|
|
|
|
public:
|
2020-05-24 17:12:22 +00:00
|
|
|
FWritableTile()
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
2020-05-24 17:12:22 +00:00
|
|
|
//useType = Writable;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 17:12:22 +00:00
|
|
|
uint8_t* GetRawData() override
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
|
|
|
return buffer.Data();
|
|
|
|
}
|
|
|
|
|
2020-04-10 16:17:26 +00:00
|
|
|
bool ResizeImage(int w, int h)
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
2020-05-24 17:12:22 +00:00
|
|
|
if (w <= 0 || h <= 0)
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
|
|
|
buffer.Reset();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-10 16:17:26 +00:00
|
|
|
Width = w;
|
|
|
|
Height = h;
|
2020-05-24 05:58:56 +00:00
|
|
|
buffer.Resize(w * h);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A tile with a writable surface
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
class FRestorableTile : public FWritableTile
|
|
|
|
{
|
2020-04-10 16:17:26 +00:00
|
|
|
FImageSource* Base;
|
2020-05-24 05:58:56 +00:00
|
|
|
|
|
|
|
public:
|
2020-04-10 16:17:26 +00:00
|
|
|
FRestorableTile(FImageSource* base)
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
|
|
|
Base = base;
|
2020-04-10 16:17:26 +00:00
|
|
|
|
|
|
|
CopySize(*base);
|
|
|
|
ResizeImage(Width, Height);
|
2020-05-24 05:58:56 +00:00
|
|
|
Reload();
|
|
|
|
}
|
|
|
|
|
2020-05-24 17:12:22 +00:00
|
|
|
void Reload()
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
2020-07-23 14:31:26 +00:00
|
|
|
buffer = Base->GetPalettedPixels(0);
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// One ART file.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
struct BuildArtFile
|
|
|
|
{
|
|
|
|
FString filename;
|
|
|
|
TArray<uint8_t> RawData;
|
|
|
|
|
|
|
|
BuildArtFile() = default;
|
|
|
|
BuildArtFile(const BuildArtFile&) = delete;
|
|
|
|
BuildArtFile& operator=(const BuildArtFile&) = delete;
|
|
|
|
BuildArtFile(const BuildArtFile&& other)
|
|
|
|
{
|
|
|
|
filename = std::move(other.filename);
|
|
|
|
RawData = std::move(other.RawData);
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildArtFile& operator=(const BuildArtFile&& other)
|
|
|
|
{
|
|
|
|
filename = std::move(other.filename);
|
|
|
|
RawData = std::move(other.RawData);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// THe tile container
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2020-05-24 06:47:45 +00:00
|
|
|
struct RawCacheNode
|
|
|
|
{
|
|
|
|
TArray<uint8_t> data;
|
|
|
|
uint64_t lastUseTime;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TileDesc
|
|
|
|
{
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture* texture; // the currently active tile
|
|
|
|
FGameTexture* backup; // original backup for map tiles
|
2020-05-24 06:47:45 +00:00
|
|
|
RawCacheNode rawCache; // this is needed for hitscan testing to avoid reloading the texture each time.
|
|
|
|
picanm_t picanm; // animation descriptor
|
2020-05-24 10:31:38 +00:00
|
|
|
picanm_t picanmbackup; // animation descriptor backup when using map tiles
|
2020-05-24 06:47:45 +00:00
|
|
|
rottile_t RotTile;// = { -1,-1 };
|
|
|
|
TArray<HightileReplacement> Hightiles;
|
|
|
|
ReplacementType replacement;
|
2020-05-29 21:33:26 +00:00
|
|
|
float alphaThreshold;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TexturePick
|
|
|
|
{
|
|
|
|
FGameTexture* texture; // which texture to use
|
|
|
|
int translation; // which translation table to use
|
|
|
|
int tintFlags; // which shader tinting options to use
|
|
|
|
PalEntry tintColor; // Tint color
|
|
|
|
PalEntry basepalTint; // can the base palette be done with a global tint effect?
|
2020-05-24 06:47:45 +00:00
|
|
|
};
|
|
|
|
|
2020-05-24 05:58:56 +00:00
|
|
|
struct BuildTiles
|
|
|
|
{
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture* Placeholder;
|
2020-05-24 05:58:56 +00:00
|
|
|
TDeletingArray<BuildArtFile*> ArtFiles;
|
2020-05-24 06:47:45 +00:00
|
|
|
TileDesc tiledata[MAXTILES];
|
2020-05-24 05:58:56 +00:00
|
|
|
TArray<FString> addedArt;
|
2020-05-25 21:59:07 +00:00
|
|
|
TMap<FGameTexture*, int> TextureToTile;
|
2020-05-24 21:26:47 +00:00
|
|
|
TArray<FString> maptilesadded;
|
2020-05-24 05:58:56 +00:00
|
|
|
|
2020-05-24 21:26:47 +00:00
|
|
|
void Init(); // This cannot be a constructor because it needs the texture manager running.
|
2020-05-24 05:58:56 +00:00
|
|
|
~BuildTiles()
|
|
|
|
{
|
|
|
|
CloseAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloseAll();
|
|
|
|
|
2020-05-25 21:59:07 +00:00
|
|
|
void AddTile(int tilenum, FGameTexture* tex, bool permap = false);
|
2020-05-24 05:58:56 +00:00
|
|
|
|
2020-05-24 21:26:47 +00:00
|
|
|
void AddTiles(int firsttile, TArray<uint8_t>& store, const char* mapname);
|
2020-05-24 05:58:56 +00:00
|
|
|
|
|
|
|
void AddFile(BuildArtFile* bfd, bool permap)
|
|
|
|
{
|
2020-05-25 14:53:35 +00:00
|
|
|
ArtFiles.Push(bfd);
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
int FindFile(const FString& filename)
|
|
|
|
{
|
|
|
|
return ArtFiles.FindEx([filename](const BuildArtFile* element) { return filename.CompareNoCase(element->filename) == 0; });
|
|
|
|
}
|
2020-05-24 21:26:47 +00:00
|
|
|
int LoadArtFile(const char* file, const char* mapname = nullptr, int firsttile = -1);
|
2020-05-24 05:58:56 +00:00
|
|
|
void LoadArtSet(const char* filename);
|
|
|
|
void AddArt(TArray<FString>& art)
|
|
|
|
{
|
|
|
|
addedArt = std::move(art);
|
|
|
|
}
|
2020-05-25 21:59:07 +00:00
|
|
|
int GetTileIndex(FGameTexture* tex)
|
2020-05-24 08:30:09 +00:00
|
|
|
{
|
|
|
|
auto p = TextureToTile.CheckKey(tex);
|
|
|
|
return p ? *p : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetupReverseTileMap()
|
|
|
|
{
|
|
|
|
TextureToTile.Clear();
|
|
|
|
for (int i = 0; i < MAXTILES; i++)
|
|
|
|
{
|
2020-05-24 13:02:20 +00:00
|
|
|
if (tiledata[i].texture != nullptr && tiledata[i].texture != Placeholder) TextureToTile.Insert(tiledata[i].texture, i);
|
2020-05-24 08:30:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture* ValidateCustomTile(int tilenum, ReplacementType type);
|
2020-05-24 05:58:56 +00:00
|
|
|
int32_t artLoadFiles(const char* filename);
|
|
|
|
uint8_t* tileMakeWritable(int num);
|
|
|
|
uint8_t* tileCreate(int tilenum, int width, int height);
|
|
|
|
int findUnusedTile(void);
|
|
|
|
int tileCreateRotated(int owner);
|
|
|
|
void InvalidateTile(int num);
|
|
|
|
void MakeCanvas(int tilenum, int width, int height);
|
2020-05-24 06:47:45 +00:00
|
|
|
HightileReplacement* FindReplacement(int picnum, int palnum, bool skybox = false);
|
|
|
|
void AddReplacement(int picnum, const HightileReplacement&);
|
|
|
|
void DeleteReplacement(int picnum, int palnum);
|
|
|
|
void DeleteReplacements(int picnum)
|
|
|
|
{
|
|
|
|
assert(picnum < MAXTILES);
|
|
|
|
tiledata[picnum].Hightiles.Clear();
|
|
|
|
}
|
|
|
|
|
2020-05-29 21:33:26 +00:00
|
|
|
void PostLoadSetup();
|
2020-05-24 06:47:45 +00:00
|
|
|
|
2020-05-24 05:58:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int tileGetCRC32(int tileNum);
|
|
|
|
int tileImportFromTexture(const char* fn, int tilenum, int alphacut, int istexture);
|
|
|
|
void tileCopy(int tile, int tempsource, int temppal, int xoffset, int yoffset, int flags);
|
|
|
|
void tileSetDummy(int tile, int width, int height);
|
|
|
|
void tileDelete(int tile);
|
|
|
|
void tileRemoveReplacement(int tile);
|
|
|
|
bool tileLoad(int tileNum);
|
|
|
|
void artClearMapArt(void);
|
|
|
|
void artSetupMapArt(const char* filename);
|
|
|
|
void tileSetAnim(int tile, const picanm_t& anm);
|
|
|
|
int tileSetHightileReplacement(int picnum, int palnum, const char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, uint8_t flags);
|
|
|
|
int tileSetSkybox(int picnum, int palnum, const char **facenames, int flags );
|
|
|
|
int tileDeleteReplacement(int picnum, int palnum);
|
|
|
|
void tileCopySection(int tilenum1, int sx1, int sy1, int xsiz, int ysiz, int tilenum2, int sx2, int sy2);
|
|
|
|
|
|
|
|
extern BuildTiles TileFiles;
|
|
|
|
inline bool tileCheck(int num)
|
|
|
|
{
|
2020-05-24 13:02:20 +00:00
|
|
|
auto tex = TileFiles.tiledata[num].texture;
|
2020-05-24 17:12:22 +00:00
|
|
|
return tex && tex->GetTexelWidth() > 0 && tex->GetTexelHeight() > 0;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline const uint8_t* tilePtr(int num)
|
|
|
|
{
|
2020-05-24 17:12:22 +00:00
|
|
|
if (TileFiles.tiledata[num].rawCache.data.Size() == 0)
|
|
|
|
{
|
|
|
|
auto tex = TileFiles.tiledata[num].texture;
|
|
|
|
if (!tex || tex->GetTexelWidth() <= 0 || tex->GetTexelHeight() <= 0) return nullptr;
|
2020-07-23 14:31:26 +00:00
|
|
|
TileFiles.tiledata[num].rawCache.data = tex->GetTexture()->Get8BitPixels(false);
|
2020-05-24 17:12:22 +00:00
|
|
|
}
|
|
|
|
TileFiles.tiledata[num].rawCache.lastUseTime = I_nsTime();
|
|
|
|
return TileFiles.tiledata[num].rawCache.data.Data();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool tileLoad(int tileNum)
|
|
|
|
{
|
|
|
|
return !!tilePtr(tileNum);
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline uint8_t* tileData(int num)
|
|
|
|
{
|
2020-05-28 16:42:26 +00:00
|
|
|
auto tex = dynamic_cast<FImageTexture*>(TileFiles.tiledata[num].texture->GetTexture());
|
|
|
|
if (!tex) return nullptr;
|
|
|
|
auto p = dynamic_cast<FWritableTile*>(tex->GetImage());
|
2020-05-24 17:12:22 +00:00
|
|
|
return p ? p->GetRawData() : nullptr;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Some hacks to allow accessing the no longer existing arrays as if they still were arrays to avoid changing hundreds of lines of code.
|
|
|
|
struct TileSiz
|
|
|
|
{
|
2020-05-24 13:02:20 +00:00
|
|
|
const vec2_16_t operator[](size_t index)
|
2020-05-24 05:58:56 +00:00
|
|
|
{
|
|
|
|
assert(index < MAXTILES);
|
2020-05-24 13:02:20 +00:00
|
|
|
vec2_16_t v = { (int16_t)TileFiles.tiledata[index].texture->GetDisplayWidth(), (int16_t)TileFiles.tiledata[index].texture->GetDisplayHeight() };
|
|
|
|
return v;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
extern TileSiz tilesiz;
|
|
|
|
|
|
|
|
struct PicAnm
|
|
|
|
{
|
|
|
|
picanm_t& operator[](size_t index)
|
|
|
|
{
|
|
|
|
assert(index < MAXTILES);
|
2020-05-24 11:53:27 +00:00
|
|
|
return TileFiles.tiledata[index].picanm;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
extern PicAnm picanm;
|
|
|
|
|
|
|
|
// Helpers to read the refactored tilesiz array.
|
|
|
|
inline int tileWidth(int num)
|
|
|
|
{
|
2020-05-24 10:31:38 +00:00
|
|
|
assert(num < MAXTILES);
|
2020-05-24 13:02:20 +00:00
|
|
|
return TileFiles.tiledata[num].texture->GetDisplayWidth();
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int tileHeight(int num)
|
|
|
|
{
|
2020-05-24 10:31:38 +00:00
|
|
|
assert(num < MAXTILES);
|
2020-05-24 13:02:20 +00:00
|
|
|
return TileFiles.tiledata[num].texture->GetDisplayHeight();
|
2020-05-24 10:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int tileLeftOffset(int num)
|
|
|
|
{
|
|
|
|
assert(num < MAXTILES);
|
2020-05-24 13:02:20 +00:00
|
|
|
return TileFiles.tiledata[num].texture->GetDisplayLeftOffset();
|
2020-05-24 10:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int tileTopOffset(int num)
|
|
|
|
{
|
|
|
|
assert(num < MAXTILES);
|
2020-05-24 13:02:20 +00:00
|
|
|
return TileFiles.tiledata[num].texture->GetDisplayTopOffset();
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int widthBits(int num)
|
|
|
|
{
|
|
|
|
int w = tileWidth(num);
|
|
|
|
int j = 15;
|
|
|
|
|
|
|
|
while ((j > 1) && ((1 << j) > w))
|
|
|
|
j--;
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int heightBits(int num)
|
|
|
|
{
|
|
|
|
int w = tileHeight(num);
|
|
|
|
int j = 15;
|
|
|
|
|
|
|
|
while ((j > 1) && ((1 << j) > w))
|
|
|
|
j--;
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline rottile_t& RotTile(int tile)
|
|
|
|
{
|
|
|
|
assert(tile < MAXTILES);
|
2020-05-24 11:53:27 +00:00
|
|
|
return TileFiles.tiledata[tile].RotTile;
|
2020-05-24 05:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-28 19:38:25 +00:00
|
|
|
int32_t animateoffs(int const tilenum, int fakevar);
|
|
|
|
|
|
|
|
inline FGameTexture* tileGetTexture(int tile, bool animate = false)
|
2020-05-24 10:31:38 +00:00
|
|
|
{
|
|
|
|
assert(tile < MAXTILES);
|
2020-06-28 19:38:25 +00:00
|
|
|
if (animate)
|
|
|
|
{
|
|
|
|
if (picanm[tile].sf & PICANM_ANIMTYPE_MASK)
|
|
|
|
tile += animateoffs(tile, 0);
|
|
|
|
|
|
|
|
}
|
2020-05-24 13:02:20 +00:00
|
|
|
return TileFiles.tiledata[tile].texture;
|
2020-05-29 21:33:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PickTexture(int picnum, FGameTexture* tex, int paletteid, TexturePick& pick);
|