- backend update from GZDoom.

This commit is contained in:
Christoph Oelckers 2020-11-23 15:54:06 +01:00
parent 26c7bcdca4
commit 5a5f9b8e02
15 changed files with 71 additions and 95 deletions

View file

@ -556,8 +556,6 @@ OpenALSoundRenderer::OpenALSoundRenderer()
ALC.EXT_disconnect = !!alcIsExtensionPresent(Device, "ALC_EXT_disconnect"); ALC.EXT_disconnect = !!alcIsExtensionPresent(Device, "ALC_EXT_disconnect");
ALC.SOFT_HRTF = !!alcIsExtensionPresent(Device, "ALC_SOFT_HRTF"); ALC.SOFT_HRTF = !!alcIsExtensionPresent(Device, "ALC_SOFT_HRTF");
ALC.SOFT_pause_device = !!alcIsExtensionPresent(Device, "ALC_SOFT_pause_device"); ALC.SOFT_pause_device = !!alcIsExtensionPresent(Device, "ALC_SOFT_pause_device");
ALC.SOFT_pause_device = !!alcIsExtensionPresent(Device, "ALC_SOFT_pause_device");
ALC.SOFT_output_limiter = !!alcIsExtensionPresent(Device, "ALC_SOFT_output_limiter");
const ALCchar *current = NULL; const ALCchar *current = NULL;
if(alcIsExtensionPresent(Device, "ALC_ENUMERATE_ALL_EXT")) if(alcIsExtensionPresent(Device, "ALC_ENUMERATE_ALL_EXT"))
@ -594,11 +592,6 @@ OpenALSoundRenderer::OpenALSoundRenderer()
else else
attribs.Push(ALC_DONT_CARE_SOFT); attribs.Push(ALC_DONT_CARE_SOFT);
} }
if (ALC.SOFT_output_limiter)
{
attribs.Push(ALC_OUTPUT_LIMITER_SOFT);
attribs.Push(ALC_TRUE /* or ALC_FALSE or ALC_DONT_CARE_SOFT */);
}
// Other attribs..? // Other attribs..?
attribs.Push(0); attribs.Push(0);

View file

@ -968,6 +968,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
break; break;
} }
// Intentional fall-through for command(s) added with Ctrl-D // Intentional fall-through for command(s) added with Ctrl-D
[[fallthrough]];
case '\r': case '\r':
{ {
@ -1033,6 +1034,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
{ {
break; break;
} }
[[fallthrough]];
case GK_ESCAPE: case GK_ESCAPE:
// Close console and clear command line. But if we're in the // Close console and clear command line. But if we're in the
// fullscreen console mode, there's nothing to fall back on // fullscreen console mode, there's nothing to fall back on

View file

@ -242,27 +242,6 @@ DEFINE_ACTION_FUNCTION(FFont, BreakLines)
ACTION_RETURN_OBJECT(Create<DBrokenLines>(broken)); ACTION_RETURN_OBJECT(Create<DBrokenLines>(broken));
} }
DEFINE_ACTION_FUNCTION(FFont, BreakLines2)
{
PARAM_SELF_STRUCT_PROLOGUE(FFont);
PARAM_STRING(text);
PARAM_INT(maxwidth);
auto broken = V_BreakLines(self, maxwidth, text, true);
ACTION_RETURN_OBJECT(Create<DBrokenLines>(broken));
}
DEFINE_ACTION_FUNCTION(_Hugohaft, BreakLines)
{
PARAM_SELF_STRUCT_PROLOGUE(FFont);
PARAM_STRING(text);
PARAM_INT(maxwidth);
auto broken = V_BreakLines(self, maxwidth, text, true);
ACTION_RETURN_OBJECT(Create<DBrokenLines>(broken));
}
bool generic_ui; bool generic_ui;
EXTERN_CVAR(String, language) EXTERN_CVAR(String, language)

View file

@ -752,21 +752,13 @@ static void ParseListMenu(FScanner &sc)
//============================================================================= //=============================================================================
// //
// [Player701] Allow extending list menus // [Player701] Common function for figuring out where to insert items
// for AddListMenu and AddOptionMenu
// //
//============================================================================= //=============================================================================
static void ParseAddListMenu(FScanner& sc) static int GetInsertIndex(FScanner& sc, DMenuDescriptor* desc)
{ {
sc.MustGetString();
DMenuDescriptor** pOld = MenuDescriptors.CheckKey(sc.String);
if (pOld == nullptr || *pOld == nullptr || !(*pOld)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor)))
{
sc.ScriptError("%s is not a list menu that can be extended", sc.String);
return;
}
bool before = sc.CheckString("BEFORE"); bool before = sc.CheckString("BEFORE");
bool after = sc.CheckString("AFTER"); bool after = sc.CheckString("AFTER");
@ -777,10 +769,10 @@ static void ParseAddListMenu(FScanner& sc)
// Find an existing menu item to use as insertion point // Find an existing menu item to use as insertion point
sc.MustGetString(); sc.MustGetString();
auto n = (*pOld)->mItems.Size(); int n = desc->mItems.Size();
for (unsigned int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
auto item = (*pOld)->mItems[i]; auto item = desc->mItems[i];
if (item->mAction == sc.String) if (item->mAction == sc.String)
{ {
@ -796,7 +788,26 @@ static void ParseAddListMenu(FScanner& sc)
// to avoid backwards compatibility issues. // to avoid backwards compatibility issues.
} }
ParseListMenuBody(sc, (DListMenuDescriptor*)(*pOld), insertIndex); return insertIndex;
}
//=============================================================================
//
// [Player701] Allow extending list menus
//
//=============================================================================
static void ParseAddListMenu(FScanner& sc)
{
sc.MustGetString();
DMenuDescriptor** pOld = MenuDescriptors.CheckKey(sc.String);
if (pOld == nullptr || *pOld == nullptr || !(*pOld)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor)))
{
sc.ScriptError("%s is not a list menu that can be extended", sc.String);
return;
}
ParseListMenuBody(sc, (DListMenuDescriptor*)(*pOld), GetInsertIndex(sc, *pOld));
} }
//============================================================================= //=============================================================================
@ -915,7 +926,7 @@ static void ParseOptionSettings(FScanner &sc)
// //
//============================================================================= //=============================================================================
static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc) static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc, int insertIndex)
{ {
sc.MustGetStringName("{"); sc.MustGetStringName("{");
while (!sc.CheckString("}")) while (!sc.CheckString("}"))
@ -930,7 +941,7 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
if (!CheckSkipGameBlock(sc)) if (!CheckSkipGameBlock(sc))
{ {
// recursively parse sub-block // recursively parse sub-block
ParseOptionMenuBody(sc, desc); ParseOptionMenuBody(sc, desc, insertIndex);
} }
} }
else if (sc.Compare("ifnotgame")) else if (sc.Compare("ifnotgame"))
@ -938,7 +949,7 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
if (!CheckSkipGameBlock(sc, false)) if (!CheckSkipGameBlock(sc, false))
{ {
// recursively parse sub-block // recursively parse sub-block
ParseOptionMenuBody(sc, desc); ParseOptionMenuBody(sc, desc, insertIndex);
} }
} }
else if (sc.Compare("ifoption")) else if (sc.Compare("ifoption"))
@ -946,7 +957,7 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
if (!CheckSkipOptionBlock(sc)) if (!CheckSkipOptionBlock(sc))
{ {
// recursively parse sub-block // recursively parse sub-block
ParseOptionMenuBody(sc, desc); ParseOptionMenuBody(sc, desc, insertIndex);
} }
} }
else if (sc.Compare("Class")) else if (sc.Compare("Class"))
@ -1084,7 +1095,16 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
DMenuItemBase *item = (DMenuItemBase*)cls->CreateNew(); DMenuItemBase *item = (DMenuItemBase*)cls->CreateNew();
params[0] = item; params[0] = item;
VMCallWithDefaults(func->Variants[0].Implementation, params, nullptr, 0); VMCallWithDefaults(func->Variants[0].Implementation, params, nullptr, 0);
desc->mItems.Push((DMenuItemBase*)item);
if (insertIndex == -1)
{
desc->mItems.Push(item);
}
else
{
desc->mItems.Insert(insertIndex, item);
insertIndex++;
}
success = true; success = true;
} }
@ -1123,7 +1143,7 @@ static void ParseOptionMenu(FScanner &sc)
desc->mDontDim = DefaultOptionMenuSettings->mDontDim; desc->mDontDim = DefaultOptionMenuSettings->mDontDim;
desc->mProtected = sc.CheckString("protected"); desc->mProtected = sc.CheckString("protected");
ParseOptionMenuBody(sc, desc); ParseOptionMenuBody(sc, desc, -1);
ReplaceMenu(sc, desc); ReplaceMenu(sc, desc);
} }
@ -1144,7 +1164,7 @@ static void ParseAddOptionMenu(FScanner &sc)
sc.ScriptError("%s is not an option menu that can be extended", sc.String); sc.ScriptError("%s is not an option menu that can be extended", sc.String);
return; return;
} }
ParseOptionMenuBody(sc, (DOptionMenuDescriptor*)(*pOld)); ParseOptionMenuBody(sc, (DOptionMenuDescriptor*)(*pOld), GetInsertIndex(sc, *pOld));
} }
@ -1424,7 +1444,7 @@ void M_ParseMenuDefs()
} }
else if (sc.Compare("DEFAULTOPTIONMENU")) else if (sc.Compare("DEFAULTOPTIONMENU"))
{ {
ParseOptionMenuBody(sc, DefaultOptionMenuSettings); ParseOptionMenuBody(sc, DefaultOptionMenuSettings, -1);
if (DefaultOptionMenuSettings->mItems.Size() > 0) if (DefaultOptionMenuSettings->mItems.Size() > 0)
{ {
I_FatalError("You cannot add menu items to the menu default settings."); I_FatalError("You cannot add menu items to the menu default settings.");

View file

@ -2967,6 +2967,7 @@ FxExpression *FxMulDiv::Resolve(FCompileContext& ctx)
case '/': case '/':
// For division, the vector must be the first operand. // For division, the vector must be the first operand.
if (right->IsVector()) goto error; if (right->IsVector()) goto error;
[[fallthrough]];
case '*': case '*':
if (left->IsVector() && right->IsNumeric()) if (left->IsVector() && right->IsNumeric())

View file

@ -523,6 +523,7 @@ ZCCCompiler::ZCCCompiler(ZCC_AST &ast, DObject *_outer, PSymbolTable &_symbols,
ProcessStruct(static_cast<ZCC_Struct*>(node), tnode, nullptr); ProcessStruct(static_cast<ZCC_Struct*>(node), tnode, nullptr);
break; break;
} }
goto common;
common: common:
case AST_ConstantDef: case AST_ConstantDef:
@ -2655,6 +2656,7 @@ FxExpression *ZCCCompiler::ConvertNode(ZCC_TreeNode *ast, bool substitute)
} }
} }
// fall through if this isn't an array access node. // fall through if this isn't an array access node.
[[fallthrough]];
default: default:
Error(fcall, "Invalid function identifier"); Error(fcall, "Invalid function identifier");

View file

@ -963,7 +963,7 @@ void JitCompiler::EmitFLOP()
FuncPtr func = nullptr; FuncPtr func = nullptr;
switch (C) switch (C)
{ {
default: I_Error("Unknown OP_FLOP subfunction"); default: I_Error("Unknown OP_FLOP subfunction"); break;
case FLOP_ABS: func = fabs; break; case FLOP_ABS: func = fabs; break;
case FLOP_EXP: func = g_exp; break; case FLOP_EXP: func = g_exp; break;
case FLOP_LOG: func = g_log; break; case FLOP_LOG: func = g_log; break;

View file

@ -90,4 +90,14 @@ struct MD5Context;
void md5Update(FileReader& file, MD5Context& md5, unsigned len); void md5Update(FileReader& file, MD5Context& md5, unsigned len);
void uppercopy(char* to, const char* from); void uppercopy(char* to, const char* from);
inline void fillshort(void* buff, size_t count, uint16_t clear)
{
int16_t* b2 = (int16_t*)buff;
for (size_t i = 0; i < count; ++i)
{
b2[i] = clear;
}
}
#endif #endif

View file

@ -6,48 +6,12 @@
#include "basics.h" #include "basics.h"
// Modern compilers are smart enough to do these multiplications intelligently. __forceinline constexpr int32_t MulScale(int32_t a, int32_t b, int32_t shift) { return (int32_t)(((int64_t)a * b) >> shift); }
__forceinline int32_t MulScale14(int32_t a, int32_t b) { return (int32_t)(((int64_t)a * b) >> 14); } // only used by R_DrawVoxel __forceinline constexpr int32_t DMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d) >> shift); }
__forceinline int32_t MulScale30(int32_t a, int32_t b) { return (int32_t)(((int64_t)a * b) >> 30); } // only used once in the node builder __forceinline constexpr int32_t DivScale(int32_t a, int32_t b, int shift) { return (int32_t)(((int64_t)a << shift) / b); }
__forceinline int32_t MulScale32(int32_t a, int32_t b) { return (int32_t)(((int64_t)a * b) >> 32); } // only used by R_DrawVoxel
__forceinline uint32_t UMulScale16(uint32_t a, uint32_t b) { return (uint32_t)(((uint64_t)a * b) >> 16); } // used for sky drawing
__forceinline int32_t DMulScale3(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 3); } // used for setting up slopes for Build maps
__forceinline int32_t DMulScale6(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 6); } // only used by R_DrawVoxel
__forceinline int32_t DMulScale10(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 10); } // only used by R_DrawVoxel
__forceinline int32_t DMulScale18(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 18); } // only used by R_DrawVoxel
__forceinline int32_t DMulScale32(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 32); } // used by R_PointOnSide.
// Sadly, for divisions this is not true but these are so infrequently used that the C versions are just fine, despite not being fully optimal.
__forceinline int32_t DivScale6(int32_t a, int32_t b) { return (int32_t)(((int64_t)a << 6) / b); } // only used by R_DrawVoxel
__forceinline int32_t DivScale21(int32_t a, int32_t b) { return (int32_t)(((int64_t)a << 21) / b); } // only used by R_DrawVoxel
__forceinline int32_t DivScale30(int32_t a, int32_t b) { return (int32_t)(((int64_t)a << 30) / b); } // only used once in the node builder
__forceinline void fillshort(void *buff, unsigned int count, uint16_t clear)
{
int16_t *b2 = (int16_t *)buff;
for (unsigned int i = 0; i != count; ++i)
{
b2[i] = clear;
}
}
#include "xs_Float.h" #include "xs_Float.h"
inline int32_t FixedDiv (int32_t a, int32_t b)
{
if ((uint32_t)abs(a) >> (31-16) >= (uint32_t)abs (b))
return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
return (int32_t)(((int64_t)a << 16) / b);
}
__forceinline constexpr int32_t FixedMul(int32_t a, int32_t b)
{
return (int32_t)(((int64_t)a * b) >> 16);
}
inline fixed_t FloatToFixed(double f) inline fixed_t FloatToFixed(double f)
{ {
return xs_Fix<16>::ToFix(f); return xs_Fix<16>::ToFix(f);

View file

@ -49,4 +49,6 @@ DEFINE_GLOBAL(gameinfo)
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, gametype) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, gametype)
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mBackButton) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mBackButton)
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mSliderColor) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mSliderColor)
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mSliderBackColor)

View file

@ -44,6 +44,7 @@ struct gameinfo_t
{ {
int gametype; int gametype;
FName mSliderColor; FName mSliderColor;
FName mSliderBackColor;
FString mBackButton; FString mBackButton;
FString TitlePage; FString TitlePage;
}; };

View file

@ -562,6 +562,7 @@ void SetDefaultMenuColors()
OptionSettings.mFontColorHighlight = CR_YELLOW; OptionSettings.mFontColorHighlight = CR_YELLOW;
OptionSettings.mFontColorSelection = CR_BRICK; OptionSettings.mFontColorSelection = CR_BRICK;
gameinfo.mSliderColor = "Orange"; gameinfo.mSliderColor = "Orange";
gameinfo.mSliderBackColor = "White";
if (g_gameType & GAMEFLAG_BLOOD) if (g_gameType & GAMEFLAG_BLOOD)
{ {

View file

@ -531,6 +531,7 @@ struct GameInfoStruct native
native int gametype; native int gametype;
native String mBackButton; native String mBackButton;
native Name mSliderColor; native Name mSliderColor;
native Name mSliderBackColor;
} }
struct SystemTime struct SystemTime

View file

@ -110,7 +110,7 @@ class ImageScrollerPageTextItem : ImageScrollerPage
virtWidth = desc.virtWidth; virtWidth = desc.virtWidth;
virtHeight = desc.virtHeight; virtHeight = desc.virtHeight;
mText = mFont.BreakLines(Stringtable.Localize(txt.Filter()), virtWidth / mTextScale); mText = mFont.BreakLines(Stringtable.Localize(txt.Filter()), int(virtWidth / mTextScale));
mYpos = y >= 0? y : virtHeight / 2 - mText.Count() * mFont.GetHeight() * mTextScale / 2; mYpos = y >= 0? y : virtHeight / 2 - mText.Count() * mFont.GetHeight() * mTextScale / 2;
} }
@ -119,7 +119,7 @@ class ImageScrollerPageTextItem : ImageScrollerPage
{ {
Screen.DrawTexture(mTexture, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, DTA_Color, mBrightness); Screen.DrawTexture(mTexture, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, DTA_Color, mBrightness);
int fontheight = mFont.GetHeight() * mTextScale; let fontheight = mFont.GetHeight() * mTextScale;
let y = mYpos; let y = mYpos;
let c = mText.Count(); let c = mText.Count();
for (int i = 0; i < c; i++) for (int i = 0; i < c; i++)

View file

@ -766,13 +766,13 @@ class OptionMenuSliderBase : OptionMenuItem
if (!mSliderShort) if (!mSliderShort)
{ {
DrawSliderElement(Font.CR_WHITE, x, cy, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12", grayed); DrawSliderElement(Font.FindFontColor(gameinfo.mSliderBackColor), x, cy, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12", grayed);
DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 78) / range)) * 2 * CleanXfac_1), cy, "\x13", grayed); DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 78) / range)) * 2 * CleanXfac_1), cy, "\x13", grayed);
} }
else else
{ {
// On 320x200 we need a shorter slider // On 320x200 we need a shorter slider
DrawSliderElement(Font.CR_WHITE, x, cy, "\x10\x11\x11\x11\x11\x11\x12", grayed); DrawSliderElement(Font.FindFontColor(gameinfo.mSliderBackColor), x, cy, "\x10\x11\x11\x11\x11\x11\x12", grayed);
DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 38) / range)) * 2 * CleanXfac_1), cy, "\x13", grayed); DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 38) / range)) * 2 * CleanXfac_1), cy, "\x13", grayed);
right -= 5*8*CleanXfac; right -= 5*8*CleanXfac;
} }