From e74aca291cc2e0e34a102ec41f0607bf30dd6369 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 8 May 2021 22:08:05 +0200 Subject: [PATCH] - position tweaking for Nam's skies. Why is this such an utter mess to get skies placed correctly? :( --- source/build/include/build.h | 5 +++-- source/build/src/engine.cpp | 7 ++++--- source/core/defparser.cpp | 1 + source/core/rendering/scene/hw_sky.cpp | 2 +- source/games/blood/src/loadsave.cpp | 1 + source/games/duke/src/game.cpp | 6 ++++++ source/games/exhumed/src/init.cpp | 1 + source/games/exhumed/src/save.cpp | 1 + 8 files changed, 18 insertions(+), 6 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 74c7ec3d9..1a57b1efb 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -213,6 +213,7 @@ typedef struct { // The texel index offset in the y direction of a parallaxed sky: // XXX: currently always 0. int yoffs; + int yoffs2; int lognumtiles; // 1<horizfrac = horiz; sky->lognumtiles = lognumtiles; sky->yoffs = yoff; + sky->yoffs2 = yoff2 == 0x7fffffff ? yoff : yoff2; memcpy(sky->tileofs, tileofs, 2 << lognumtiles); return sky; } // Get properties of parallaxed sky to draw. // 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); @@ -616,7 +617,7 @@ const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits, if (dapyscale) *dapyscale = (parallaxyscale_override == 0 ? psky->horizfrac : parallaxyscale_override); if (dapyoffs) - *dapyoffs = psky->yoffs + parallaxyoffs_override; + *dapyoffs = (alt? psky->yoffs2 : psky->yoffs) + parallaxyoffs_override; if (daptileyscale) *daptileyscale = psky->yscale; diff --git a/source/core/defparser.cpp b/source/core/defparser.cpp index d237eab71..65c00ab68 100644 --- a/source/core/defparser.cpp +++ b/source/core/defparser.cpp @@ -887,6 +887,7 @@ void parseMultiPsky(FScanner& sc, FScriptPosition& pos) if (sky.tilenum != DEFAULTPSKY && (unsigned)sky.tilenum >= MAXUSERTILES) return; if ((1 << sky.lognumtiles) > MAXPSKYTILES) return; + sky.yoffs2 = sky.yoffs; auto psky = tileSetupSky(sky.tilenum); *psky = sky; } diff --git a/source/core/rendering/scene/hw_sky.cpp b/source/core/rendering/scene/hw_sky.cpp index 1a008ece9..c708a8ba2 100644 --- a/source/core/rendering/scene/hw_sky.cpp +++ b/source/core/rendering/scene/hw_sky.cpp @@ -54,7 +54,7 @@ void initSkyInfo(HWDrawInfo *di, HWSkyInfo* sky, sectortype* sector, int plane, { 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); if ((1 << sizeToBits(tw)) < tw) dapskybits--; // Build math is weird. diff --git a/source/games/blood/src/loadsave.cpp b/source/games/blood/src/loadsave.cpp index d9da35f39..69d36a3ab 100644 --- a/source/games/blood/src/loadsave.cpp +++ b/source/games/blood/src/loadsave.cpp @@ -642,6 +642,7 @@ void SerializeState(FSerializer& arc) ("cheating", bPlayerCheated) ("skyhoriz", pSky->horizfrac) ("skyy", pSky->yoffs) + ("skyy2", pSky->yoffs2) ("scale", pSky->yscale) .Array("tileofs", pSky->tileofs, countof(pSky->tileofs)) ("numtiles", pSky->lognumtiles) diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index 9dc6d5d45..08f898c48 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -219,6 +219,12 @@ static void setupbackdrop() } } } + + if (isNam()) + { + defineSky(212, 65536, 3, pskyoff, 0, 140); + defineSky(225, 65536, 3, pskyoff, 0, 140); + } } //--------------------------------------------------------------------------- diff --git a/source/games/exhumed/src/init.cpp b/source/games/exhumed/src/init.cpp index 5c2c1db7c..031a057aa 100644 --- a/source/games/exhumed/src/init.cpp +++ b/source/games/exhumed/src/init.cpp @@ -156,6 +156,7 @@ uint8_t LoadLevel(MapRecord* map) pSky->tileofs[2] = 0; pSky->tileofs[3] = 0; pSky->yoffs = 256; + pSky->yoffs2 = 256; pSky->lognumtiles = 2; pSky->horizfrac = 65536; pSky->yscale = 65536; diff --git a/source/games/exhumed/src/save.cpp b/source/games/exhumed/src/save.cpp index de96ac106..e51bc81a5 100644 --- a/source/games/exhumed/src/save.cpp +++ b/source/games/exhumed/src/save.cpp @@ -110,6 +110,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) pSky->tileofs[2] = 0; pSky->tileofs[3] = 0; pSky->yoffs = 256; + pSky->yoffs2 = 256; pSky->lognumtiles = 2; pSky->horizfrac = 65536; pSky->yscale = 65536;