From 005e6871f9324d408eb719c496b6ad4360e06003 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Mar 2017 10:37:55 +0100 Subject: [PATCH] - increased the snd_channels default and minimum. The values were still 8 and 32 respectively which applied to hardware from last decade, but for modern mods these are simply too low. New values are 64 as minimum and 128 as default. - added script access to a sector's colormap and specialcolors fields. (Writing only through dedicated functions because these fields are render state which may need to trigger some form of refresh if the renderer changes.) --- src/fragglescript/t_func.cpp | 4 ++-- src/p_sectors.cpp | 30 ++++++++++++++++++++++++++++++ src/r_defs.h | 2 ++ src/s_sound.cpp | 5 ++++- wadsrc/static/menudef.txt | 2 +- wadsrc/static/zscript/mapdata.txt | 24 ++++++++++++++++++++---- 6 files changed, 59 insertions(+), 8 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index ea9600afa..2348448ac 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -3891,11 +3891,11 @@ void FParser::SF_SetColor(void) else { // little hack for testing the D64 color stuff. - for (int j = 0; j < 4; j++) level.sectors[i].SpecialColors[j] = color; + for (int j = 0; j < 4; j++) level.sectors[i].SetSpecialColor(j, color); // simulates 'nocoloredspritelighting' settings. int v = (color.r + color.g + color.b) / 3; v = (255 + v + v) / 3; - level.sectors[i].SpecialColors[sector_t::sprites] = PalEntry(255, v, v, v); + level.sectors[i].SetSpecialColor(sector_t::sprites, v, v, v); } } } diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 83abb6e58..834736719 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -845,6 +845,35 @@ DEFINE_ACTION_FUNCTION(_Sector, SetFade) // //===================================================================================== +void sector_t::SetSpecialColor(int slot, int r, int g, int b) +{ + SpecialColors[slot] = PalEntry(255, r, g, b); +} + +void sector_t::SetSpecialColor(int slot, PalEntry rgb) +{ + rgb.a = 255; + SpecialColors[slot] = rgb; +} + +DEFINE_ACTION_FUNCTION(_Sector, SetSpecialColor) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(num); + PARAM_COLOR(color); + if (num >= 0 && num < 5) + { + color.a = 255; + self->SetSpecialColor(num, color); + } + return 0; +} + +//===================================================================================== +// +// +//===================================================================================== + void sector_t::SetFogDensity(int dens) { Colormap.FogDensity = dens; @@ -2414,6 +2443,7 @@ DEFINE_ACTION_FUNCTION(_Secplane, PointToDist) DEFINE_FIELD_X(Sector, sector_t, floorplane) DEFINE_FIELD_X(Sector, sector_t, ceilingplane) DEFINE_FIELD_X(Sector, sector_t, Colormap) +DEFINE_FIELD_X(Sector, sector_t, SpecialColors) DEFINE_FIELD_X(Sector, sector_t, SoundTarget) DEFINE_FIELD_X(Sector, sector_t, special) DEFINE_FIELD_X(Sector, sector_t, lightlevel) diff --git a/src/r_defs.h b/src/r_defs.h index 011c1105a..a6d2b8fd2 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -640,6 +640,8 @@ public: void SetColor(int r, int g, int b, int desat); void SetFade(int r, int g, int b); void SetFogDensity(int dens); + void SetSpecialColor(int num, int r, int g, int b); + void SetSpecialColor(int num, PalEntry rgb); void ClosestPoint(const DVector2 &pos, DVector2 &out) const; int GetFloorLight () const; int GetCeilingLight () const; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 8e5ac7349..5e9760a3c 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -135,7 +135,10 @@ uint8_t *S_SoundCurve; int S_SoundCurveSize; FBoolCVar noisedebug ("noise", false, 0); // [RH] Print sound debugging info? -CVAR (Int, snd_channels, 32, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // number of channels available +CUSTOM_CVAR (Int, snd_channels, 128, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // number of channels available +{ + if (self < 64) self = 64; +} CVAR (Bool, snd_flipstereo, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // CODE -------------------------------------------------------------------- diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index b36572891..f6f699088 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1642,7 +1642,7 @@ OptionMenu SoundOptions StaticText " " Option "$SNDMNU_UNDERWATERREVERB", "snd_waterreverb", "OnOff" Option "$SNDMNU_RANDOMIZEPITCHES", "snd_pitched", "OnOff" - Slider "$SNDMNU_CHANNELS", "snd_channels", 8, 256, 8, 0 + Slider "$SNDMNU_CHANNELS", "snd_channels", 64, 256, 8, 0 StaticText " " ifoption(fmodex) diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index 3242fa1d0..8914fd405 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -199,10 +199,20 @@ struct SecSpecial play int Flags; } +struct FColormap +{ + Color LightColor; + Color FadeColor; + uint8 Desaturation; + uint8 BlendFactor; + uint16 FogDensity; +} + struct Sector native play { - //FDynamicColormap *ColorMap; + native readonly FColormap ColorMap; + native readonly Color SpecialColors[5]; native Actor SoundTarget; @@ -228,7 +238,11 @@ struct Sector native play enum EPlane { floor, - ceiling + ceiling, + // only used for specialcolors array + walltop, + wallbottom, + sprites }; enum EInterpolationType @@ -324,8 +338,6 @@ struct Sector native play native void RemoveForceField(); native static Sector PointInSector(Vector2 pt); - native void SetColor(color c, int desat = 0); - native void SetFade(color c); native bool PlaneMoving(int pos); native int GetFloorLight(); @@ -360,10 +372,14 @@ struct Sector native play native void ChangeFlags(int pos, int And, int Or); native int GetPlaneLight(int pos); native void SetPlaneLight(int pos, int level); + native void SetColor(color c, int desat = 0); + native void SetFade(color c); + native void SetFogDensity(int dens); native double GetGlowHeight(int pos); native color GetGlowColor(int pos); native void SetGlowHeight(int pos, double height); native void SetGlowColor(int pos, color color); + native void SetSpecialColor(int pos, color color); native TextureID GetTexture(int pos); native void SetTexture(int pos, TextureID tex, bool floorclip = true);