Commit 4c1d40cc authored by Jordon Moss's avatar Jordon Moss Committed by Evan Ramos

engine: Implement tileflags member of picanm, and added support for new flag:...

engine: Implement tileflags member of picanm, and added support for new flag: TILEFLAGS_TRUENPOT, that allows you to enable true non-power-of-two texture support per-tile.

(Fixes classic's buggy tiling and panning behaviour and bypasses the emulation of it in Polymost)
parent 281d4943
......@@ -922,12 +922,18 @@ enum {
PICANM_ANIMSPEED_MASK = 15, // must be 15
};
enum {
TILEFLAGS_NONE = 0,
TILEFLAGS_TRUENPOT = (1<<1),
};
// NOTE: If the layout of this struct is changed, loadpics() must be modified
// accordingly.
typedef struct {
uint8_t num; // animate number
int8_t xofs, yofs;
uint8_t sf; // anim. speed and flags
uint8_t tileflags; // tile-specific flags, such as true non-power-of-2 drawing.
} picanm_t;
EXTERN picanm_t picanm[MAXTILES];
typedef struct { int16_t newtile; int16_t owner; } rottile_t;
......
......@@ -127,6 +127,7 @@ enum scripttoken_t
T_NEWGAMECHOICES,
T_LOCALIZATION, T_STRING,
T_TILEFONT, T_CHARACTER,
T_TRUENPOT,
};
static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0;
......@@ -811,6 +812,7 @@ static int32_t defsparser(scriptfile *script)
vec2_t tile_size{};
uint8_t have_crc32 = 0;
uint8_t have_size = 0;
uint8_t tile_flags = 0;
static const tokenlist tilefromtexturetokens[] =
{
......@@ -826,6 +828,7 @@ static int32_t defsparser(scriptfile *script)
{ "texture", T_TEXTURE },
{ "ifcrc", T_IFCRC },
{ "ifmatch", T_IFMATCH },
{ "truenpot", T_TRUENPOT },
};
if (scriptfile_getsymbol(script,&tile)) break;
......@@ -893,6 +896,9 @@ static int32_t defsparser(scriptfile *script)
case T_NOFULLBRIGHT:
flags |= PICANM_NOFULLBRIGHT_BIT;
break;
case T_TRUENPOT:
tile_flags |= TILEFLAGS_TRUENPOT;
break;
case T_TEXTURE:
istexture = 1;
break;
......@@ -944,6 +950,8 @@ static int32_t defsparser(scriptfile *script)
{
// tilefromtexture <tile> { texhitscan } sets the bit but doesn't change tile data
picanm[tile].sf |= flags;
picanm[tile].tileflags |= tile_flags;
if (havexoffset)
picanm[tile].xofs = xoffset;
if (haveyoffset)
......@@ -955,6 +963,8 @@ static int32_t defsparser(scriptfile *script)
break;
}
picanm[tile].tileflags |= tile_flags; // Set flags before loading, since we may need them before uploading.
int32_t const texstatus = Defs_ImportTileFromTexture(fn, tile, alphacut, istexture);
if (texstatus == -3)
initprintf("Error: No palette loaded, in tilefromtexture definition near line %s:%d\n",
......
......@@ -71,7 +71,7 @@ static FORCE_INLINE int32_t oldnonpow2(void)
#if !defined CLASSIC_NONPOW2_YSIZE_WALLS
return 1;
#else
return (g_loadedMapVersion < 10);
return ((g_loadedMapVersion < 10) && !(picanm[globalpicnum].tileflags & TILEFLAGS_TRUENPOT));
#endif
}
......
......@@ -2269,7 +2269,11 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
fixtransparency(pic,tsiz,siz,dameth);
if (polymost_want_npotytex(dameth, siz.y) && tsiz.x == siz.x && tsiz.y == siz.y) // XXX
if (picanm[dapic].tileflags & TILEFLAGS_TRUENPOT)
{
npoty = 0;
}
else if (polymost_want_npotytex(dameth, siz.y) && tsiz.x == siz.x && tsiz.y == siz.y) // XXX
{
const int32_t nextpoty = 1 << ((picsiz[dapic] >> 4) + 1);
const int32_t ydif = nextpoty - siz.y;
......@@ -3320,7 +3324,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
}
}
if (glinfo.texnpot && r_npotwallmode == 2 && (method & DAMETH_WALL) != 0)
if (glinfo.texnpot && r_npotwallmode == 2 && (method & DAMETH_WALL) != 0 && !(picanm[globalpicnum].tileflags & TILEFLAGS_TRUENPOT))
{
int32_t size = tilesiz[globalpicnum].y;
int32_t size2;
......@@ -4995,7 +4999,11 @@ static void calc_ypanning(int32_t refposz, float ryp0, float ryp1,
i = tilesiz[globalpicnum].y;
else
#endif
if (polymost_is_npotmode())
if (picanm[globalpicnum].tileflags & TILEFLAGS_TRUENPOT)
{
i = tilesiz[globalpicnum].y;
}
else if (polymost_is_npotmode())
{
t *= (float)tilesiz[globalpicnum].y / i;
i = tilesiz[globalpicnum].y;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment