SW: Parallaxed skies.

git-svn-id: https://svn.eduke32.com/eduke32@5211 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-05-19 22:05:20 +00:00
parent 91d6935c88
commit 93d6d61180
12 changed files with 77 additions and 29 deletions

View file

@ -371,8 +371,8 @@ SW_EDITOR ?= voidsw-editor
SW_TARGET:=$(SW)$(EXESUFFIX) SW_TARGET:=$(SW)$(EXESUFFIX)
SW_EDITOR_TARGET:=$(SW_EDITOR)$(EXESUFFIX) SW_EDITOR_TARGET:=$(SW_EDITOR)$(EXESUFFIX)
SW_OBJS=actor ai anim border break bunny cache cheats colormap config console coolg coolie copysect demo draw eel game girlninj goro grpscan hornet interp interpsh inv jplayer jsector jweapon lava light mclip mdastr menus miscactr morph net ninja panel player predict quake ripper ripper2 rooms rotator rts save scrip2 sector serp setup skel skull slidor sounds spike sprite sumo swconfig sync text track vator vis wallmove warp weapon zilla zombie saveable SW_OBJS=actor ai anim border break bunny cache cheats colormap common config console coolg coolie copysect demo draw eel game girlninj goro grpscan hornet interp interpsh inv jplayer jsector jweapon lava light mclip mdastr menus miscactr morph net ninja panel player predict quake ripper ripper2 rooms rotator rts save scrip2 sector serp setup skel skull slidor sounds spike sprite sumo swconfig sync text track vator vis wallmove warp weapon zilla zombie saveable
SW_EDITOR_OBJS=jnstub brooms bldscript jbhlp colormap grpscan SW_EDITOR_OBJS=jnstub brooms bldscript jbhlp colormap grpscan common
ifeq ($(RENDERTYPE),SDL) ifeq ($(RENDERTYPE),SDL)
ifeq (1,$(HAVE_GTK2)) ifeq (1,$(HAVE_GTK2))

View file

@ -749,6 +749,8 @@ FORCE_INLINE int32_t getpskyidx(int32_t picnum)
} }
EXTERN char parallaxtype; EXTERN char parallaxtype;
EXTERN int32_t parallaxyoffs_override, parallaxyscale_override;
extern int16_t pskybits_override;
// last sprite in the freelist, that is the spritenum for which // last sprite in the freelist, that is the spritenum for which
// .statnum==MAXSTATUS && nextspritestat[spritenum]==-1 // .statnum==MAXSTATUS && nextspritestat[spritenum]==-1

View file

@ -140,6 +140,8 @@ static void drawpixel_safe(void *s, char a)
#endif #endif
} }
int16_t pskybits_override = -1;
//void loadvoxel(int32_t voxindex) { UNREFERENCED_PARAMATER(voxindex); } //void loadvoxel(int32_t voxindex) { UNREFERENCED_PARAMATER(voxindex); }
int16_t tiletovox[MAXTILES]; int16_t tiletovox[MAXTILES];
int32_t usevoxels = 1; int32_t usevoxels = 1;
@ -4679,14 +4681,14 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i
globaltilesizy = tsizy; globaltilesizy = tsizy;
globalyscale = 65536 / tsizy; globalyscale = 65536 / tsizy;
globalshiftval = 0; globalshiftval = 0;
globalzd = divscale32(((tsizy>>1)/*+g_psky.yoffs*/), tsizy) + ((uint32_t)globalypanning<<24); globalzd = divscale32(((tsizy>>1)+parallaxyoffs_override/*+g_psky.yoffs*/), tsizy) + ((uint32_t)globalypanning<<24);
} }
else else
#endif #endif
{ {
globalshiftval = 32-globalshiftval; globalshiftval = 32-globalshiftval;
globalyscale = (8<<(globalshiftval-19)); globalyscale = (8<<(globalshiftval-19));
globalzd = (((tsizy>>1)/*+g_psky.yoffs*/)<<globalshiftval) + ((uint32_t)globalypanning<<24); globalzd = (((tsizy>>1)+parallaxyoffs_override/*+g_psky.yoffs*/)<<globalshiftval) + ((uint32_t)globalypanning<<24);
} }
//if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd; //if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd;

View file

@ -224,9 +224,9 @@ static inline const int8_t *getpsky(int32_t picnum, int32_t *dapyscale, int32_t
int32_t j = getpskyidx(picnum); int32_t j = getpskyidx(picnum);
if (dapskybits) if (dapskybits)
*dapskybits = multipsky[j].lognumtiles; *dapskybits = (pskybits_override == -1 ? multipsky[j].lognumtiles : pskybits_override);
if (dapyscale) if (dapyscale)
*dapyscale = multipsky[j].horizfrac; *dapyscale = (parallaxyscale_override == 0 ? multipsky[j].horizfrac : parallaxyscale_override);
return multipsky[j].tileofs; return multipsky[j].tileofs;
} }

View file

@ -2619,7 +2619,7 @@ static void polymost_drawalls(int32_t const bunch)
float vv[2]; float vv[2];
float t = (float)((1<<(picsiz[globalpicnum]&15))<<dapskybits); float t = (float)((1<<(picsiz[globalpicnum]&15))<<dapskybits);
vv[1] = dd*((float)xdimscale*fviewingrange) * (1.f/(65536.f*65536.f)); vv[1] = dd*((float)xdimscale*fviewingrange) * (1.f/(65536.f*65536.f));
vv[0] = dd*((float) ((tilesiz[globalpicnum].y>>1)/*+g_psky.yoffs*/)) - vv[1]*ghoriz; vv[0] = dd*((float) ((tilesiz[globalpicnum].y>>1)+parallaxyoffs_override/*+g_psky.yoffs*/)) - vv[1]*ghoriz;
int i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i; int i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i;
//Hack to draw black rectangle below sky when looking down... //Hack to draw black rectangle below sky when looking down...
@ -2885,7 +2885,7 @@ static void polymost_drawalls(int32_t const bunch)
float vv[2]; float vv[2];
float t = (float)((1<<(picsiz[globalpicnum]&15))<<dapskybits); float t = (float)((1<<(picsiz[globalpicnum]&15))<<dapskybits);
vv[1] = dd*((float)xdimscale*viewingrange) * (1.f/(65536.f*65536.f)); vv[1] = dd*((float)xdimscale*viewingrange) * (1.f/(65536.f*65536.f));
vv[0] = dd*((float)((tilesiz[globalpicnum].y>>1)/*+g_psky.yoffs*/)) - vv[1]*ghoriz; vv[0] = dd*((float)((tilesiz[globalpicnum].y>>1)+parallaxyoffs_override/*+g_psky.yoffs*/)) - vv[1]*ghoriz;
int i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i; int i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i;
//Hack to draw black rectangle below sky when looking down... //Hack to draw black rectangle below sky when looking down...

View file

@ -0,0 +1,38 @@
#include "build.h"
#include "common_game.h"
#define NUMPSKYMULTIS 1
EDUKE32_STATIC_ASSERT(NUMPSKYMULTIS <= MAXPSKYMULTIS);
EDUKE32_STATIC_ASSERT(PSKYOFF_MAX <= MAXPSKYTILES);
// Set up new-style multi-psky handling.
void SW_InitMultiPsky(void)
{
int32_t i;
static int32_t inited;
if (inited)
return;
inited = 1;
multipskytile[0] = -1;
pskynummultis = NUMPSKYMULTIS;
// 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.)
// The default sky properties (all others are implicitly zero):
multipsky[0].lognumtiles = 1;
multipsky[0].horizfrac = 8192;
for (i=0; i<pskynummultis; ++i)
{
int32_t j;
for (j=0; j<(1<<multipsky[i].lognumtiles); ++j)
Bassert(multipsky[i].tileofs[j] <= PSKYOFF_MAX);
}
}

View file

@ -131,6 +131,10 @@ extern "C" {
#define MACRO9 "Hope you were paying attention." #define MACRO9 "Hope you were paying attention."
#define MACRO10 "ITTAIIIUUU!!!" #define MACRO10 "ITTAIIIUUU!!!"
void SW_InitMultiPsky(void);
#ifdef __cplusplus #ifdef __cplusplus
}; };
#endif #endif

View file

@ -89,6 +89,8 @@ Things required to make savegames work:
#include "text.h" #include "text.h"
#include "music.h" #include "music.h"
#include "common_game.h"
#include "crc32.h" #include "crc32.h"
#if DEBUG #if DEBUG
@ -223,7 +225,6 @@ const GAME_SET gs_defaults =
}; };
GAME_SET gs; GAME_SET gs;
char PlaxBits = 0;
SWBOOL PlayerTrackingMode = FALSE; SWBOOL PlayerTrackingMode = FALSE;
SWBOOL PauseMode = FALSE; SWBOOL PauseMode = FALSE;
SWBOOL PauseKeySet = FALSE; SWBOOL PauseKeySet = FALSE;
@ -1048,13 +1049,8 @@ InitGame(int32_t argc, const char **argv)
Connect(); Connect();
SortBreakInfo(); SortBreakInfo();
//parallaxyoffs = 40;
parallaxyoffs = 0;
parallaxtype = 1; parallaxtype = 1;
pskyoff[0] = 0; SW_InitMultiPsky();
pskybits = PlaxBits;
// Default scale value for parallax skies
parallaxyscale = 8192;
memset(Track, 0, sizeof(Track)); memset(Track, 0, sizeof(Track));
@ -1249,8 +1245,6 @@ void InitLevelGlobals(void)
PlayerGravity = 24; PlayerGravity = 24;
wait_active_check_offset = 0; wait_active_check_offset = 0;
PlaxCeilGlobZadjust = PlaxFloorGlobZadjust = Z(500); PlaxCeilGlobZadjust = PlaxFloorGlobZadjust = Z(500);
pskyoff[0] = 0;
pskybits = PlaxBits;
FinishedLevel = FALSE; FinishedLevel = FALSE;
AnimCnt = 0; AnimCnt = 0;
left_foot = FALSE; left_foot = FALSE;
@ -4408,10 +4402,10 @@ DebugKeys(PLAYERp pp)
KEY_PRESSED(KEYSC_LSHIFT) = FALSE; KEY_PRESSED(KEYSC_LSHIFT) = FALSE;
KEY_PRESSED(KEYSC_X) = 0; KEY_PRESSED(KEYSC_X) = 0;
parallaxyoffs += 10; parallaxyoffs_override += 10;
if (parallaxyoffs > 100) if (parallaxyoffs_override > 100)
parallaxyoffs = 0; parallaxyoffs_override = 0;
} }
else else
{ {

View file

@ -36,6 +36,8 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "tags.h" #include "tags.h"
#include "pal.h" #include "pal.h"
#include "common_game.h"
#define M_RED 102 #define M_RED 102
#define M_BLUE 198 #define M_BLUE 198
@ -754,6 +756,7 @@ ExtInit(void)
initmouse(); initmouse();
InitPalette(); InitPalette();
SW_InitMultiPsky();
defaultspritecstat = 0; // use old centering mode defaultspritecstat = 0; // use old centering mode
kensplayerheight = 58; kensplayerheight = 58;

View file

@ -587,9 +587,9 @@ int SaveGame(short save_num)
MWRITE(&NormalVisibility,sizeof(NormalVisibility),1,fil); MWRITE(&NormalVisibility,sizeof(NormalVisibility),1,fil);
MWRITE(&g_visibility,sizeof(g_visibility),1,fil); MWRITE(&g_visibility,sizeof(g_visibility),1,fil);
MWRITE(&parallaxtype,sizeof(parallaxtype),1,fil); MWRITE(&parallaxtype,sizeof(parallaxtype),1,fil);
MWRITE(&parallaxyoffs,sizeof(parallaxyoffs),1,fil); MWRITE(&parallaxyoffs_override,sizeof(parallaxyoffs_override),1,fil);
MWRITE(pskyoff,sizeof(pskyoff),1,fil); MWRITE(&parallaxyscale_override,sizeof(parallaxyscale_override),1,fil);
MWRITE(&pskybits,sizeof(pskybits),1,fil); MWRITE(&pskybits_override,sizeof(pskybits_override),1,fil);
MWRITE(&BorderInfo,sizeof(BorderInfo),1,fil); MWRITE(&BorderInfo,sizeof(BorderInfo),1,fil);
MWRITE(&MoveSkip2,sizeof(MoveSkip2),1,fil); MWRITE(&MoveSkip2,sizeof(MoveSkip2),1,fil);
@ -1078,9 +1078,9 @@ int LoadGame(short save_num)
MREAD(&NormalVisibility,sizeof(NormalVisibility),1,fil); MREAD(&NormalVisibility,sizeof(NormalVisibility),1,fil);
MREAD(&g_visibility,sizeof(g_visibility),1,fil); MREAD(&g_visibility,sizeof(g_visibility),1,fil);
MREAD(&parallaxtype,sizeof(parallaxtype),1,fil); MREAD(&parallaxtype,sizeof(parallaxtype),1,fil);
MREAD(&parallaxyoffs,sizeof(parallaxyoffs),1,fil); MREAD(&parallaxyoffs_override,sizeof(parallaxyoffs_override),1,fil);
MREAD(pskyoff,sizeof(pskyoff),1,fil); MREAD(&parallaxyscale_override,sizeof(parallaxyscale_override),1,fil);
MREAD(&pskybits,sizeof(pskybits),1,fil); MREAD(&pskybits_override,sizeof(pskybits_override),1,fil);
MREAD(&BorderInfo,sizeof(BorderInfo),1,fil); MREAD(&BorderInfo,sizeof(BorderInfo),1,fil);
MREAD(&MoveSkip2,sizeof(MoveSkip2),1,fil); MREAD(&MoveSkip2,sizeof(MoveSkip2),1,fil);

View file

@ -1797,6 +1797,10 @@ SpriteSetup(void)
sector[i].extra = 0; sector[i].extra = 0;
} }
// Clear PARALLAX_LEVEL overrides
parallaxyscale_override = 0;
pskybits_override = -1;
// Call my little sprite setup routine first // Call my little sprite setup routine first
JS_SpriteSetup(); JS_SpriteSetup();
@ -2053,9 +2057,10 @@ SpriteSetup(void)
case PARALLAX_LEVEL: case PARALLAX_LEVEL:
{ {
pskybits = sp->lotag; parallaxyscale_override = 8192;
pskybits_override = sp->lotag;
if (SP_TAG4(sp) > 2048) if (SP_TAG4(sp) > 2048)
parallaxyscale = SP_TAG4(sp); parallaxyscale_override = SP_TAG4(sp);
KillSprite(SpriteNum); KillSprite(SpriteNum);
break; break;
} }

View file

@ -64,7 +64,7 @@ void Ken_InitMultiPsky(void)
multipsky[1].lognumtiles = 1; multipsky[1].lognumtiles = 1;
multipsky[1].horizfrac = 65536; multipsky[1].horizfrac = 65536;
// DAYSKY // NIGHTSKY
multipsky[2].lognumtiles = 3; multipsky[2].lognumtiles = 3;
multipsky[2].horizfrac = 65536; multipsky[2].horizfrac = 65536;