mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-23 12:04:38 -04:00
add support for SMMU swirling flats (#591)
* ad support for SMMU swirling flats * formatting glitch * shorten sequence length to 256 * create distorted flat lookup table on demand * make init function static * add config key and menu switch
This commit is contained in:
parent
5819f54bcf
commit
e75e03d9e0
@ -99,6 +99,7 @@ set(WOOF_SOURCES
|
||||
r_segs.c r_segs.h
|
||||
r_sky.c r_sky.h
|
||||
r_state.h
|
||||
r_swirl.c r_swirl.h
|
||||
r_things.c r_things.h
|
||||
s_sound.c s_sound.h
|
||||
s_musinfo.c s_musinfo.h
|
||||
|
@ -3648,12 +3648,13 @@ void M_DrawEnemy(void)
|
||||
|
||||
extern int realtic_clock_rate, tran_filter_pct;
|
||||
|
||||
setup_menu_t gen_settings1[], gen_settings2[];
|
||||
setup_menu_t gen_settings1[], gen_settings2[], gen_settings3[];
|
||||
|
||||
setup_menu_t* gen_settings[] =
|
||||
{
|
||||
gen_settings1,
|
||||
gen_settings2,
|
||||
gen_settings3,
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -3803,6 +3804,7 @@ enum {
|
||||
general_title4,
|
||||
general_sky1,
|
||||
general_sky2,
|
||||
general_swirl,
|
||||
general_smoothlight,
|
||||
general_brightmaps,
|
||||
general_diskicon,
|
||||
@ -3854,6 +3856,9 @@ setup_menu_t gen_settings2[] = { // General Settings screen2
|
||||
{"Linear Sky Scrolling", S_YESNO, m_null, M_X,
|
||||
G_Y3 + general_sky2*M_SPC, {"linearsky"}, 0, R_InitPlanes},
|
||||
|
||||
{"Swirling Animated Flats", S_YESNO, m_null, M_X,
|
||||
G_Y3 + general_swirl*M_SPC, {"r_swirl"}},
|
||||
|
||||
{"Smooth Diminishing Lighting", S_YESNO, m_null, M_X,
|
||||
G_Y3 + general_smoothlight*M_SPC, {"smoothlight"}, 0, M_SmoothLight},
|
||||
|
||||
@ -3866,18 +3871,28 @@ setup_menu_t gen_settings2[] = { // General Settings screen2
|
||||
{"Show ENDOOM screen", S_CHOICE, m_null, M_X,
|
||||
G_Y3 + general_endoom*M_SPC, {"show_endoom"}, 0, NULL, default_endoom_strings},
|
||||
|
||||
{"Miscellaneous" ,S_SKIP|S_TITLE, m_null, M_X, G_Y4},
|
||||
{"<- PREV",S_SKIP|S_PREV, m_null, M_X_PREV, M_Y_PREVNEXT, {gen_settings1}},
|
||||
{"NEXT ->",S_SKIP|S_NEXT, m_null, M_X_NEXT, M_Y_PREVNEXT, {gen_settings3}},
|
||||
|
||||
// Final entry
|
||||
|
||||
{0,S_SKIP|S_END,m_null}
|
||||
};
|
||||
|
||||
setup_menu_t gen_settings3[] = { // General Settings screen3
|
||||
|
||||
{"Miscellaneous" ,S_SKIP|S_TITLE, m_null, M_X, M_Y},
|
||||
|
||||
{"Game speed, percentage of normal", S_NUM|S_PRGWARN, m_null, M_X,
|
||||
G_Y4 + general_realtic*M_SPC, {"realtic_clock_rate"}},
|
||||
M_Y + general_realtic*M_SPC, {"realtic_clock_rate"}},
|
||||
|
||||
{"Default skill level", S_CHOICE|S_LEVWARN, m_null, M_X,
|
||||
G_Y4 + general_skill*M_SPC, {"default_skill"}, 0, NULL, default_skill_strings},
|
||||
M_Y + general_skill*M_SPC, {"default_skill"}, 0, NULL, default_skill_strings},
|
||||
|
||||
{"Show demo progress bar", S_YESNO, m_null, M_X,
|
||||
G_Y4 + general_demobar*M_SPC, {"demobar"}},
|
||||
M_Y + general_demobar*M_SPC, {"demobar"}},
|
||||
|
||||
{"<- PREV",S_SKIP|S_PREV, m_null, M_X_PREV, M_Y_PREVNEXT, {gen_settings1}},
|
||||
{"<- PREV",S_SKIP|S_PREV, m_null, M_X_PREV, M_Y_PREVNEXT, {gen_settings2}},
|
||||
|
||||
// Final entry
|
||||
|
||||
|
@ -96,6 +96,7 @@ extern boolean mus_reverb;
|
||||
extern boolean demobar;
|
||||
extern boolean smoothlight;
|
||||
extern boolean brightmaps;
|
||||
extern boolean r_swirl;
|
||||
|
||||
extern char *chat_macros[], *wad_files[], *deh_files[]; // killough 10/98
|
||||
|
||||
@ -226,6 +227,13 @@ default_t defaults[] = {
|
||||
"set percentage of foreground/background translucency mix"
|
||||
},
|
||||
|
||||
{
|
||||
"r_swirl",
|
||||
(config_t *) &r_swirl, NULL,
|
||||
{0}, {0,1}, number, ss_gen, wad_yes,
|
||||
"1 to enable swirling animated flats"
|
||||
},
|
||||
|
||||
{
|
||||
"smoothlight",
|
||||
(config_t *) &smoothlight, NULL,
|
||||
|
@ -162,13 +162,17 @@ void P_InitPicAnims (void)
|
||||
|
||||
lastanim->istexture = animdefs[i].istexture;
|
||||
lastanim->numpics = lastanim->picnum - lastanim->basepic + 1;
|
||||
lastanim->speed = LONG(animdefs[i].speed); // killough 5/5/98: add LONG()
|
||||
|
||||
// [crispy] add support for SMMU swirling flats
|
||||
if (lastanim->speed < 65536 && lastanim->numpics != 1)
|
||||
{
|
||||
if (lastanim->numpics < 2)
|
||||
I_Error ("P_InitPicAnims: bad cycle from %s to %s",
|
||||
animdefs[i].startname,
|
||||
animdefs[i].endname);
|
||||
}
|
||||
|
||||
lastanim->speed = LONG(animdefs[i].speed); // killough 5/5/98: add LONG()
|
||||
lastanim++;
|
||||
}
|
||||
Z_ChangeTag (animdefs,PU_CACHE); //jff 3/23/98 allow table to be freed
|
||||
@ -2258,6 +2262,8 @@ int levelTimeCount;
|
||||
boolean levelFragLimit; // Ty 03/18/98 Added -frags support
|
||||
int levelFragLimitCount; // Ty 03/18/98 Added -frags support
|
||||
|
||||
int r_swirl;
|
||||
|
||||
void P_UpdateSpecials (void)
|
||||
{
|
||||
anim_t* anim;
|
||||
@ -2298,7 +2304,12 @@ void P_UpdateSpecials (void)
|
||||
if (anim->istexture)
|
||||
texturetranslation[i] = pic;
|
||||
else
|
||||
{
|
||||
flattranslation[i] = pic;
|
||||
// [crispy] add support for SMMU swirling flats
|
||||
if (anim->speed > 65535 || anim->numpics == 1 || r_swirl)
|
||||
flattranslation[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Check buttons (retriggerable switches) and change texture on timeout
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "r_sky.h"
|
||||
#include "r_plane.h"
|
||||
#include "r_bmaps.h" // [crispy] R_BrightmapForTexName()
|
||||
#include "r_swirl.h" // [crispy] R_DistortedFlat()
|
||||
|
||||
#define MAXVISPLANES 128 /* must be a power of 2 */
|
||||
|
||||
@ -440,10 +441,20 @@ static void do_draw_plane(visplane_t *pl)
|
||||
else // regular flat
|
||||
{
|
||||
int stop, light;
|
||||
boolean swirling = (flattranslation[pl->picnum] == -1);
|
||||
|
||||
// [crispy] add support for SMMU swirling flats
|
||||
if (swirling)
|
||||
{
|
||||
ds_source = R_DistortedFlat(firstflat + pl->picnum);
|
||||
ds_brightmap = R_BrightmapForFlatNum(pl->picnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
ds_source = W_CacheLumpNum(firstflat + flattranslation[pl->picnum],
|
||||
PU_STATIC);
|
||||
ds_brightmap = R_BrightmapForFlatNum(flattranslation[pl->picnum]);
|
||||
}
|
||||
|
||||
xoffs = pl->xoffs; // killough 2/28/98: Add offsets
|
||||
yoffs = pl->yoffs;
|
||||
@ -463,7 +474,7 @@ static void do_draw_plane(visplane_t *pl)
|
||||
for (x = pl->minx ; x <= stop ; x++)
|
||||
R_MakeSpans(x,pl->top[x-1],pl->bottom[x-1],pl->top[x],pl->bottom[x]);
|
||||
|
||||
Z_ChangeTag (ds_source, PU_CACHE);
|
||||
if (!swirling) Z_ChangeTag (ds_source, PU_CACHE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
126
Source/r_swirl.c
Normal file
126
Source/r_swirl.c
Normal file
@ -0,0 +1,126 @@
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2000, 2005-2014 Simon Howard
|
||||
// Copyright(C) 2019 Fabian Greffrath
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// [crispy] add support for SMMU swirling flats
|
||||
//
|
||||
|
||||
// [crispy] adapted from smmu/r_ripple.c, by Simon Howard
|
||||
|
||||
#include "doomstat.h"
|
||||
|
||||
#include "i_system.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
#include "tables.h"
|
||||
|
||||
|
||||
// swirl factors determine the number of waves per flat width
|
||||
|
||||
// 1 cycle per 64 units
|
||||
#define swirlfactor (FINEANGLES/64)
|
||||
|
||||
// 1 cycle per 32 units (2 in 64)
|
||||
#define swirlfactor2 (FINEANGLES/32)
|
||||
|
||||
#define SEQUENCE 256
|
||||
#define FLATSIZE (64 * 64)
|
||||
|
||||
static int *offsets = NULL;
|
||||
static int *offset;
|
||||
|
||||
#define AMP 2
|
||||
#define AMP2 2
|
||||
#define SPEED 32
|
||||
|
||||
static void R_InitDistortedFlats()
|
||||
{
|
||||
int i;
|
||||
|
||||
offsets = I_Realloc(offsets, SEQUENCE * FLATSIZE * sizeof(*offsets));
|
||||
offset = offsets;
|
||||
|
||||
for (i = 0; i < SEQUENCE; i++)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for (x = 0; x < 64; x++)
|
||||
{
|
||||
for (y = 0; y < 64; y++)
|
||||
{
|
||||
int x1, y1;
|
||||
int sinvalue, sinvalue2;
|
||||
|
||||
sinvalue = (y * swirlfactor + i * SPEED * 5 + 900) & FINEMASK;
|
||||
sinvalue2 = (x * swirlfactor2 + i * SPEED * 4 + 300) & FINEMASK;
|
||||
x1 = x + 128
|
||||
+ ((finesine[sinvalue] * AMP) >> FRACBITS)
|
||||
+ ((finesine[sinvalue2] * AMP2) >> FRACBITS);
|
||||
|
||||
sinvalue = (x * swirlfactor + i * SPEED * 3 + 700) & FINEMASK;
|
||||
sinvalue2 = (y * swirlfactor2 + i * SPEED * 4 + 1200) & FINEMASK;
|
||||
y1 = y + 128
|
||||
+ ((finesine[sinvalue] * AMP) >> FRACBITS)
|
||||
+ ((finesine[sinvalue2] * AMP2) >> FRACBITS);
|
||||
|
||||
x1 &= 63;
|
||||
y1 &= 63;
|
||||
|
||||
offset[(y << 6) + x] = (y1 << 6) + x1;
|
||||
}
|
||||
}
|
||||
|
||||
offset += FLATSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
byte *R_DistortedFlat(int flatnum)
|
||||
{
|
||||
static int swirltic = -1;
|
||||
static int swirlflat = -1;
|
||||
static byte distortedflat[FLATSIZE];
|
||||
|
||||
if (!offsets)
|
||||
{
|
||||
R_InitDistortedFlats();
|
||||
}
|
||||
|
||||
if (swirltic != leveltime)
|
||||
{
|
||||
offset = offsets + ((leveltime & (SEQUENCE - 1)) * FLATSIZE);
|
||||
|
||||
swirltic = leveltime;
|
||||
swirlflat = -1;
|
||||
}
|
||||
|
||||
if (swirlflat != flatnum)
|
||||
{
|
||||
char *normalflat;
|
||||
int i;
|
||||
|
||||
normalflat = W_CacheLumpNum(flatnum, PU_STATIC);
|
||||
|
||||
for (i = 0; i < FLATSIZE; i++)
|
||||
{
|
||||
distortedflat[i] = normalflat[offset[i]];
|
||||
}
|
||||
|
||||
Z_ChangeTag(normalflat, PU_CACHE);
|
||||
|
||||
swirlflat = flatnum;
|
||||
}
|
||||
|
||||
return distortedflat;
|
||||
}
|
25
Source/r_swirl.h
Normal file
25
Source/r_swirl.h
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2000, 2005-2014 Simon Howard
|
||||
// Copyright(C) 2019 Fabian Greffrath
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// [crispy] add support for SMMU swirling flats
|
||||
//
|
||||
|
||||
#ifndef __R_SWIRL__
|
||||
#define __R_SWIRL__
|
||||
|
||||
byte *R_DistortedFlat(int flatnum);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user