2012-03-26 22:03:20 +00:00
|
|
|
//
|
|
|
|
// Common non-engine code/data for EDuke32 and Mapster32
|
|
|
|
//
|
|
|
|
|
2019-09-21 18:59:54 +00:00
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2012-03-26 22:03:20 +00:00
|
|
|
#include "compat.h"
|
2012-06-03 16:09:33 +00:00
|
|
|
#include "build.h"
|
2014-08-31 11:15:23 +00:00
|
|
|
#include "baselayer.h"
|
2016-06-21 00:33:06 +00:00
|
|
|
#include "palette.h"
|
2019-10-22 15:47:24 +00:00
|
|
|
#include "gamecvars.h"
|
2019-10-26 11:41:42 +00:00
|
|
|
#include "cmdlib.h"
|
2019-10-27 12:40:24 +00:00
|
|
|
#include "rts.h"
|
2019-10-31 22:25:21 +00:00
|
|
|
#include "gamecontrol.h"
|
2012-03-26 22:03:20 +00:00
|
|
|
|
2013-03-21 09:48:21 +00:00
|
|
|
|
2012-03-26 22:03:20 +00:00
|
|
|
#include "common.h"
|
2020-03-18 07:15:45 +00:00
|
|
|
#include "common_game.h"
|
2012-03-26 22:03:20 +00:00
|
|
|
|
2019-09-21 20:53:00 +00:00
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
|
|
|
|
2013-08-04 20:37:45 +00:00
|
|
|
// Set up new-style multi-psky handling.
|
2016-08-27 01:41:33 +00:00
|
|
|
void G_InitMultiPsky(int CLOUDYOCEAN__DYN, int MOONSKY1__DYN, int BIGORBIT1__DYN, int LA__DYN)
|
2012-11-25 04:25:31 +00:00
|
|
|
{
|
2013-08-04 20:37:45 +00:00
|
|
|
// When adding other multi-skies, take care that the tileofs[] values are
|
|
|
|
// <= PSKYOFF_MAX. (It can be increased up to MAXPSKYTILES, but should be
|
|
|
|
// set as tight as possible.)
|
2012-11-25 04:25:31 +00:00
|
|
|
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
// The default sky properties (all others are implicitly zero):
|
2018-04-12 21:03:47 +00:00
|
|
|
psky_t *sky = tileSetupSky(DEFAULTPSKY);
|
2016-08-27 01:41:33 +00:00
|
|
|
sky->lognumtiles = 3;
|
|
|
|
sky->horizfrac = 32768;
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
|
|
|
|
// CLOUDYOCEAN
|
|
|
|
// Aligns with the drawn scene horizon because it has one itself.
|
2018-04-12 21:03:47 +00:00
|
|
|
sky = tileSetupSky(CLOUDYOCEAN__DYN);
|
2016-08-27 01:41:33 +00:00
|
|
|
sky->lognumtiles = 3;
|
|
|
|
sky->horizfrac = 65536;
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
|
2012-11-25 04:25:31 +00:00
|
|
|
// MOONSKY1
|
|
|
|
// earth mountain mountain sun
|
2018-04-12 21:03:47 +00:00
|
|
|
sky = tileSetupSky(MOONSKY1__DYN);
|
2016-08-27 01:41:33 +00:00
|
|
|
sky->lognumtiles = 3;
|
|
|
|
sky->horizfrac = 32768;
|
|
|
|
sky->tileofs[6] = 1;
|
|
|
|
sky->tileofs[1] = 2;
|
|
|
|
sky->tileofs[4] = 2;
|
|
|
|
sky->tileofs[2] = 3;
|
2012-11-25 04:25:31 +00:00
|
|
|
|
|
|
|
// BIGORBIT1 // orbit
|
|
|
|
// earth1 2 3 moon/sun
|
2018-04-12 21:03:47 +00:00
|
|
|
sky = tileSetupSky(BIGORBIT1__DYN);
|
2016-08-27 01:41:33 +00:00
|
|
|
sky->lognumtiles = 3;
|
|
|
|
sky->horizfrac = 32768;
|
|
|
|
sky->tileofs[5] = 1;
|
|
|
|
sky->tileofs[6] = 2;
|
|
|
|
sky->tileofs[7] = 3;
|
|
|
|
sky->tileofs[2] = 4;
|
2012-11-25 04:25:31 +00:00
|
|
|
|
|
|
|
// LA // la city
|
|
|
|
// earth1 2 3 moon/sun
|
2018-04-12 21:03:47 +00:00
|
|
|
sky = tileSetupSky(LA__DYN);
|
2016-08-27 01:41:33 +00:00
|
|
|
sky->lognumtiles = 3;
|
|
|
|
sky->horizfrac = 16384 + 1024;
|
|
|
|
sky->tileofs[0] = 1;
|
|
|
|
sky->tileofs[1] = 2;
|
|
|
|
sky->tileofs[2] = 1;
|
|
|
|
sky->tileofs[3] = 3;
|
|
|
|
sky->tileofs[4] = 4;
|
|
|
|
sky->tileofs[5] = 0;
|
|
|
|
sky->tileofs[6] = 2;
|
|
|
|
sky->tileofs[7] = 3;
|
2013-08-04 20:37:45 +00:00
|
|
|
|
2015-05-27 08:47:34 +00:00
|
|
|
#if 0
|
|
|
|
// This assertion should hold. See note above.
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t i=0; i<pskynummultis; ++i)
|
|
|
|
for (bssize_t j=0; j<(1<<multipsky[i].lognumtiles); ++j)
|
2013-08-04 20:37:45 +00:00
|
|
|
Bassert(multipsky[i].tileofs[j] <= PSKYOFF_MAX);
|
2015-05-27 08:47:34 +00:00
|
|
|
#endif
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void G_SetupGlobalPsky(void)
|
|
|
|
{
|
2016-08-27 01:41:33 +00:00
|
|
|
int skyIdx = 0;
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
|
|
|
|
// NOTE: Loop must be running backwards for the same behavior as the game
|
|
|
|
// (greatest sector index with matching parallaxed sky takes precedence).
|
2018-11-18 18:08:14 +00:00
|
|
|
for (int i = numsectors - 1; i >= 0; i--)
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
{
|
|
|
|
if (sector[i].ceilingstat & 1)
|
|
|
|
{
|
2016-08-27 01:41:33 +00:00
|
|
|
skyIdx = getpskyidx(sector[i].ceilingpicnum);
|
|
|
|
if (skyIdx > 0)
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-11-25 04:25:31 +00:00
|
|
|
|
2016-08-27 01:41:33 +00:00
|
|
|
g_pskyidx = skyIdx;
|
2012-11-25 04:25:31 +00:00
|
|
|
}
|
|
|
|
|
2014-07-28 06:45:53 +00:00
|
|
|
|
|
|
|
//////////
|
|
|
|
|
2015-09-23 17:54:55 +00:00
|
|
|
void G_LoadLookups(void)
|
2014-07-28 06:45:53 +00:00
|
|
|
{
|
2019-03-01 08:51:50 +00:00
|
|
|
int32_t j;
|
2014-07-28 06:45:53 +00:00
|
|
|
|
2020-04-11 21:54:33 +00:00
|
|
|
auto fr = fileSystem.OpenFileReader("lookup.dat");
|
2019-10-20 20:26:53 +00:00
|
|
|
if (!fr.isOpen())
|
|
|
|
return;
|
2014-07-28 06:45:53 +00:00
|
|
|
|
2019-10-20 20:26:53 +00:00
|
|
|
j = paletteLoadLookupTable(fr);
|
2014-07-28 06:45:53 +00:00
|
|
|
|
|
|
|
if (j < 0)
|
|
|
|
{
|
|
|
|
if (j == -1)
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
|
2015-09-23 17:54:55 +00:00
|
|
|
|
2019-10-20 20:26:53 +00:00
|
|
|
return;
|
2014-07-28 06:45:53 +00:00
|
|
|
}
|
|
|
|
|
2015-09-23 17:55:02 +00:00
|
|
|
uint8_t paldata[768];
|
|
|
|
|
2014-07-28 06:45:53 +00:00
|
|
|
for (j=1; j<=5; j++)
|
|
|
|
{
|
|
|
|
// Account for TITLE and REALMS swap between basepal number and on-disk order.
|
|
|
|
int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j;
|
|
|
|
|
2019-10-20 20:26:53 +00:00
|
|
|
if (fr.Read(paldata, 768) != 768)
|
|
|
|
return;
|
2015-09-23 17:55:02 +00:00
|
|
|
|
2018-10-25 23:33:40 +00:00
|
|
|
for (unsigned char & k : paldata)
|
|
|
|
k <<= 2;
|
2015-09-23 17:55:11 +00:00
|
|
|
|
2020-05-23 12:40:54 +00:00
|
|
|
paletteSetColorTable(basepalnum, paldata, basepalnum == DREALMSPAL || basepalnum == ENDINGPAL, basepalnum < DREALMSPAL);
|
2014-07-28 06:45:53 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-25 12:17:59 +00:00
|
|
|
|
2019-09-21 20:53:00 +00:00
|
|
|
|
|
|
|
END_DUKE_NS
|