- position tweaking for Nam's skies.

Why is this such an utter mess to get skies placed correctly? :(
This commit is contained in:
Christoph Oelckers 2021-05-08 22:08:05 +02:00
parent fc11f9327a
commit e74aca291c
8 changed files with 18 additions and 6 deletions

View file

@ -213,6 +213,7 @@ typedef struct {
// The texel index offset in the y direction of a parallaxed sky: // The texel index offset in the y direction of a parallaxed sky:
// XXX: currently always 0. // XXX: currently always 0.
int yoffs; int yoffs;
int yoffs2;
int lognumtiles; // 1<<lognumtiles: number of tiles in multi-sky int lognumtiles; // 1<<lognumtiles: number of tiles in multi-sky
int16_t tileofs[MAXPSKYTILES]; // for 0 <= j < (1<<lognumtiles): tile offset relative to basetile int16_t tileofs[MAXPSKYTILES]; // for 0 <= j < (1<<lognumtiles): tile offset relative to basetile
@ -234,11 +235,11 @@ static inline psky_t *getpskyidx(int32_t picnum)
EXTERN psky_t * tileSetupSky(int32_t tilenum); EXTERN psky_t * tileSetupSky(int32_t tilenum);
psky_t* defineSky(int32_t const tilenum, int horiz, int lognumtiles, const uint16_t* tileofs, int yoff = 0); psky_t* defineSky(int32_t const tilenum, int horiz, int lognumtiles, const uint16_t* tileofs, int yoff = 0, int yoff2 = 0x7fffffff);
// Get properties of parallaxed sky to draw. // Get properties of parallaxed sky to draw.
// Returns: pointer to tile offset array. Sets-by-pointer the other three. // Returns: pointer to tile offset array. Sets-by-pointer the other three.
const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits, int32_t* dapyoffs, int32_t* daptileyscale); const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits, int32_t* dapyoffs, int32_t* daptileyscale, bool alt = false);
EXTERN char parallaxtype; EXTERN char parallaxtype;

View file

@ -595,19 +595,20 @@ psky_t * tileSetupSky(int32_t const tilenum)
return &multipskies.Last(); return &multipskies.Last();
} }
psky_t * defineSky(int32_t const tilenum, int horiz, int lognumtiles, const uint16_t *tileofs, int yoff) psky_t * defineSky(int32_t const tilenum, int horiz, int lognumtiles, const uint16_t *tileofs, int yoff, int yoff2)
{ {
auto sky = tileSetupSky(tilenum); auto sky = tileSetupSky(tilenum);
sky->horizfrac = horiz; sky->horizfrac = horiz;
sky->lognumtiles = lognumtiles; sky->lognumtiles = lognumtiles;
sky->yoffs = yoff; sky->yoffs = yoff;
sky->yoffs2 = yoff2 == 0x7fffffff ? yoff : yoff2;
memcpy(sky->tileofs, tileofs, 2 << lognumtiles); memcpy(sky->tileofs, tileofs, 2 << lognumtiles);
return sky; return sky;
} }
// Get properties of parallaxed sky to draw. // Get properties of parallaxed sky to draw.
// Returns: pointer to tile offset array. Sets-by-pointer the other three. // Returns: pointer to tile offset array. Sets-by-pointer the other three.
const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits, int32_t* dapyoffs, int32_t* daptileyscale) const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits, int32_t* dapyoffs, int32_t* daptileyscale, bool alt)
{ {
psky_t const* const psky = getpskyidx(picnum); psky_t const* const psky = getpskyidx(picnum);
@ -616,7 +617,7 @@ const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits,
if (dapyscale) if (dapyscale)
*dapyscale = (parallaxyscale_override == 0 ? psky->horizfrac : parallaxyscale_override); *dapyscale = (parallaxyscale_override == 0 ? psky->horizfrac : parallaxyscale_override);
if (dapyoffs) if (dapyoffs)
*dapyoffs = psky->yoffs + parallaxyoffs_override; *dapyoffs = (alt? psky->yoffs2 : psky->yoffs) + parallaxyoffs_override;
if (daptileyscale) if (daptileyscale)
*daptileyscale = psky->yscale; *daptileyscale = psky->yscale;

View file

@ -887,6 +887,7 @@ void parseMultiPsky(FScanner& sc, FScriptPosition& pos)
if (sky.tilenum != DEFAULTPSKY && (unsigned)sky.tilenum >= MAXUSERTILES) return; if (sky.tilenum != DEFAULTPSKY && (unsigned)sky.tilenum >= MAXUSERTILES) return;
if ((1 << sky.lognumtiles) > MAXPSKYTILES) return; if ((1 << sky.lognumtiles) > MAXPSKYTILES) return;
sky.yoffs2 = sky.yoffs;
auto psky = tileSetupSky(sky.tilenum); auto psky = tileSetupSky(sky.tilenum);
*psky = sky; *psky = sky;
} }

View file

@ -54,7 +54,7 @@ void initSkyInfo(HWDrawInfo *di, HWSkyInfo* sky, sectortype* sector, int plane,
{ {
int remap = TRANSLATION(Translation_Remap + curbasepal, palette); int remap = TRANSLATION(Translation_Remap + curbasepal, palette);
int16_t const* dapskyoff = getpsky(picnum, &dapyscale, &dapskybits, &dapyoffs, &daptileyscale); int16_t const* dapskyoff = getpsky(picnum, &dapyscale, &dapskybits, &dapyoffs, &daptileyscale, true);
int tw = tileWidth(picnum); int tw = tileWidth(picnum);
if ((1 << sizeToBits(tw)) < tw) dapskybits--; // Build math is weird. if ((1 << sizeToBits(tw)) < tw) dapskybits--; // Build math is weird.

View file

@ -642,6 +642,7 @@ void SerializeState(FSerializer& arc)
("cheating", bPlayerCheated) ("cheating", bPlayerCheated)
("skyhoriz", pSky->horizfrac) ("skyhoriz", pSky->horizfrac)
("skyy", pSky->yoffs) ("skyy", pSky->yoffs)
("skyy2", pSky->yoffs2)
("scale", pSky->yscale) ("scale", pSky->yscale)
.Array("tileofs", pSky->tileofs, countof(pSky->tileofs)) .Array("tileofs", pSky->tileofs, countof(pSky->tileofs))
("numtiles", pSky->lognumtiles) ("numtiles", pSky->lognumtiles)

View file

@ -219,6 +219,12 @@ static void setupbackdrop()
} }
} }
} }
if (isNam())
{
defineSky(212, 65536, 3, pskyoff, 0, 140);
defineSky(225, 65536, 3, pskyoff, 0, 140);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -156,6 +156,7 @@ uint8_t LoadLevel(MapRecord* map)
pSky->tileofs[2] = 0; pSky->tileofs[2] = 0;
pSky->tileofs[3] = 0; pSky->tileofs[3] = 0;
pSky->yoffs = 256; pSky->yoffs = 256;
pSky->yoffs2 = 256;
pSky->lognumtiles = 2; pSky->lognumtiles = 2;
pSky->horizfrac = 65536; pSky->horizfrac = 65536;
pSky->yscale = 65536; pSky->yscale = 65536;

View file

@ -110,6 +110,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
pSky->tileofs[2] = 0; pSky->tileofs[2] = 0;
pSky->tileofs[3] = 0; pSky->tileofs[3] = 0;
pSky->yoffs = 256; pSky->yoffs = 256;
pSky->yoffs2 = 256;
pSky->lognumtiles = 2; pSky->lognumtiles = 2;
pSky->horizfrac = 65536; pSky->horizfrac = 65536;
pSky->yscale = 65536; pSky->yscale = 65536;