- use special classes with [] operators to redirect the frequently used global arrays to the newly implemented texture manager.

This allows to use the contained storage without changing all the code.
This commit is contained in:
Christoph Oelckers 2019-10-16 20:39:59 +02:00
parent 4dc69620b7
commit 64e116a4b1
7 changed files with 44 additions and 46 deletions

View file

@ -795,10 +795,6 @@ EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1];
EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
extern const vec2_16_t * const tilesiz;
extern const uint8_t * const picsiz;
EXTERN uint8_t walock[MAXTILES];
extern const char pow2char_[];
static CONSTEXPR const int32_t pow2long[32] =
{
@ -812,9 +808,6 @@ static CONSTEXPR const int32_t pow2long[32] =
268435456, 536870912, 1073741824, 2147483647
};
EXTERN picanm_t picanm[MAXTILES];
EXTERN rottile_t rottile[MAXTILES];
EXTERN int32_t windowpos, windowx, windowy;
//These variables are for auto-mapping with the draw2dscreen function.
@ -839,12 +832,6 @@ EXTERN char gotsector[(MAXSECTORS+7)>>3];
EXTERN char editorcolors[256];
EXTERN char faketile[(MAXTILES+7)>>3];
EXTERN char *faketiledata[MAXTILES];
EXTERN char spritecol2d[MAXTILES][2];
EXTERN uint8_t tilecols[MAXTILES];
EXTERN char editwall[(MAXWALLS+7)>>3];
extern uint8_t vgapal16[4*256];

View file

@ -8463,7 +8463,6 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
RotTile(tile.newtile).owner = w.picnum+animateoffs(w.picnum,16384);
auto &siz = tilesiz[w.picnum+animateoffs(w.picnum,16384)];
}
}
}

View file

@ -122,7 +122,6 @@ extern int16_t searchbottomwall, searchisbottom;
extern char inpreparemirror;
extern const uint8_t * const picsiz;
extern int16_t sectorborder[256];
extern int32_t qsetmode;
extern int32_t hitallsprites;
@ -245,8 +244,8 @@ template <typename T> static FORCE_INLINE void tileUpdatePicnum(T * const tilept
if (picanm[tile].sf & PICANM_ANIMTYPE_MASK)
tile += animateoffs(tile, obj);
if (((obj & 16384) == 16384) && (globalorientation & CSTAT_WALL_ROTATE_90) && rottile[tile].newtile != -1)
tile = rottile[tile].newtile;
if (((obj & 16384) == 16384) && (globalorientation & CSTAT_WALL_ROTATE_90) && RotTile(tile).newtile != -1)
tile = RotTile(tile).newtile;
}
#endif /* ENGINE_PRIV_H */

View file

@ -16,16 +16,8 @@
#include "vfs.h"
static int32_t tilefileoffs[MAXTILES];
vec2_16_t tilesizearray[MAXTILES];
uint8_t picsizearray[MAXTILES];
// These may only be manipulated through a function interface so that the backing texture objects can be adjusted or replaced.
const vec2_16_t* const tilesiz = tilesizearray;
const uint8_t* const picsiz = picsizearray;
static const uint8_t *tileptr[MAXTILES]; // points to tile data -. may be constant
static uint8_t* tiledata[MAXTILES]; // points to modifiable tile data - only set by tileCreate!
//
// copytilepiece
//
void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz,

View file

@ -333,26 +333,12 @@ FTexture* BuildFiles::ValidateCustomTile(int tilenum, int type)
// global interface
//
//==========================================================================
extern vec2_16_t tilesizearray[MAXTILES];
extern uint8_t picsizearray[MAXTILES];
int32_t BuildFiles::artLoadFiles(const char* filename)
{
TileFiles.LoadArtSet(filename);
memset(gotpic, 0, MAXTILES);
memset(gotpic, 0, sizeof(gotpic));
cacheInitBuffer(MAXCACHE1DSIZE);
for (unsigned i = 0; i < MAXTILES; i++)
{
auto tex = TileFiles.tiles[i];
assert(tex);
picanm[i] = tex->PicAnim;
tilesizearray[i] = tex->GetSize();
picsizearray[i] = tex->PicSize;
rottile[i] = { -1, -1 };
}
return 0;
}
@ -643,3 +629,7 @@ void tileSetAnim(int tile, const picanm_t& anm)
{
}
TileSiz tilesiz;
PicAnm picanm;
PicSiz picsiz;

View file

@ -348,13 +348,12 @@ public:
//==========================================================================
//
// A tile with its own pixel buffer
// A non-existent tile
//
//==========================================================================
class FDummyTile : public FTileTexture
{
uint8_t pixel = 0;
public:
FDummyTile(int width, int height)
{
@ -364,7 +363,7 @@ public:
const uint8_t* Get8BitPixels() override
{
return &pixel; // do not return null.
return NULL;
}
};
@ -558,8 +557,40 @@ inline uint8_t* tileData(int num)
return tex->GetWritableBuffer();
}
// Some hacks to allow accessing the no lpnger existing arrays as if they still were arrays to avoid changing hundreds of lines of code.
struct TileSiz
{
const vec2_16_t &operator[](size_t index)
{
assert(index < MAXTILES);
return TileFiles.tiles[index]->GetSize();
}
};
extern TileSiz tilesiz;
struct PicAnm
{
picanm_t& operator[](size_t index)
{
assert(index < MAXTILES);
return TileFiles.tiles[index]->GetAnim();
}
};
extern PicAnm picanm;
struct PicSiz
{
uint8_t operator[](size_t index)
{
assert(index < MAXTILES);
return TileFiles.tiles[index]->GetPicSize();
}
};
extern PicSiz picsiz;
inline rottile_t& RotTile(int tile)
{
assert(tile < MAXTILES);
return TileFiles.tiles[tile]->GetRotTile();
}
#endif

View file

@ -1491,8 +1491,8 @@ void Gv_RefreshPointers(void)
# endif
aGameArrays[Gv_GetArrayIndex("gotpic")].pValues = (intptr_t *)&gotpic[0];
aGameArrays[Gv_GetArrayIndex("tilesizx")].pValues = (intptr_t *)&tilesiz[0].x;
aGameArrays[Gv_GetArrayIndex("tilesizy")].pValues = (intptr_t *)&tilesiz[0].y;
aGameArrays[Gv_GetArrayIndex("tilesizx")].pValues = (intptr_t *)tileWidth;
aGameArrays[Gv_GetArrayIndex("tilesizy")].pValues = (intptr_t *)tileHeight;
}
#endif