diff --git a/DDrawCompat/Config/Config.cpp b/DDrawCompat/Config/Config.cpp index 2f488be..1c7d0fd 100644 --- a/DDrawCompat/Config/Config.cpp +++ b/DDrawCompat/Config/Config.cpp @@ -12,6 +12,7 @@ namespace Config Settings::DisplayResolution displayResolution; Settings::RenderColorDepth renderColorDepth; Settings::ResolutionScale resolutionScale; + Settings::SpriteDetection spriteDetection; Settings::SpriteFilter spriteFilter; Settings::SpriteTexCoord spriteTexCoord; Settings::SupportedResolutions supportedResolutions; diff --git a/DDrawCompat/Config/Config.h b/DDrawCompat/Config/Config.h index 8c258e2..2495d2c 100644 --- a/DDrawCompat/Config/Config.h +++ b/DDrawCompat/Config/Config.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ namespace Config extern Settings::DisplayResolution displayResolution; extern Settings::RenderColorDepth renderColorDepth; extern Settings::ResolutionScale resolutionScale; + extern Settings::SpriteDetection spriteDetection; extern Settings::SpriteFilter spriteFilter; extern Settings::SpriteTexCoord spriteTexCoord; extern Settings::SupportedResolutions supportedResolutions; diff --git a/DDrawCompat/Config/Settings/SpriteDetection.cpp b/DDrawCompat/Config/Settings/SpriteDetection.cpp new file mode 100644 index 0000000..9d091fc --- /dev/null +++ b/DDrawCompat/Config/Settings/SpriteDetection.cpp @@ -0,0 +1,26 @@ +#include + +namespace Config +{ + namespace Settings + { + SpriteDetection::SpriteDetection() + : MappedSetting("SpriteDetection", "off", { + {"off", OFF}, + {"zconst", ZCONST}, + {"zmax", ZMAX}, + {"point", POINT} + }) + { + } + + Setting::ParamInfo SpriteDetection::getParamInfo() const + { + if (ZMAX == m_value) + { + return { "ZMax", 0, 100, 0, m_param }; + } + return {}; + } + } +} diff --git a/DDrawCompat/Config/Settings/SpriteDetection.h b/DDrawCompat/Config/Settings/SpriteDetection.h new file mode 100644 index 0000000..5cb49ee --- /dev/null +++ b/DDrawCompat/Config/Settings/SpriteDetection.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +namespace Config +{ + namespace Settings + { + class SpriteDetection : public MappedSetting + { + public: + static const UINT OFF = 0; + static const UINT ZCONST = 1; + static const UINT ZMAX = 2; + static const UINT POINT = 3; + + SpriteDetection(); + + virtual ParamInfo getParamInfo() const override; + }; + } +} diff --git a/DDrawCompat/D3dDdi/DrawPrimitive.cpp b/DDrawCompat/D3dDdi/DrawPrimitive.cpp index 7c14c3e..f7e68d6 100644 --- a/DDrawCompat/D3dDdi/DrawPrimitive.cpp +++ b/DDrawCompat/D3dDdi/DrawPrimitive.cpp @@ -651,8 +651,23 @@ namespace D3dDdi bool DrawPrimitive::isSprite(INT baseVertexIndex, UINT16 index0, UINT16 index1, UINT16 index2) { + auto spriteDetection = Config::spriteDetection.get(); + if (Config::Settings::SpriteDetection::OFF == spriteDetection || + Config::Settings::SpriteDetection::POINT == spriteDetection && ( + D3DTEXF_POINT != m_device.getState().getAppState().textureStageState[0][D3DDDITSS_MAGFILTER] || + D3DTEXF_POINT != m_device.getState().getAppState().textureStageState[0][D3DDDITSS_MINFILTER])) + { + return false; + } + auto v = m_streamSource.vertices + baseVertexIndex * m_streamSource.stride; auto v0 = reinterpret_cast(v + index0 * m_streamSource.stride); + if (Config::Settings::SpriteDetection::ZMAX == spriteDetection && + v0->sz > static_cast(Config::spriteDetection.getParam()) / 100) + { + return false; + } + auto v1 = reinterpret_cast(v + index1 * m_streamSource.stride); auto v2 = reinterpret_cast(v + index2 * m_streamSource.stride); return v0->sz == v1->sz && v0->sz == v2->sz; diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index c8c5055..802775b 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -227,6 +227,7 @@ + @@ -353,6 +354,7 @@ + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index 34c701e..1bed1a4 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -534,6 +534,9 @@ Header Files\Config\Settings + + Header Files\Config\Settings + @@ -845,6 +848,9 @@ Source Files\Config\Settings + + Source Files\Config\Settings + diff --git a/DDrawCompat/Overlay/ConfigWindow.cpp b/DDrawCompat/Overlay/ConfigWindow.cpp index 6479af4..017ba5f 100644 --- a/DDrawCompat/Overlay/ConfigWindow.cpp +++ b/DDrawCompat/Overlay/ConfigWindow.cpp @@ -16,6 +16,7 @@ namespace Overlay addControl(Config::displayFilter); addControl(Config::renderColorDepth); addControl(Config::resolutionScale); + addControl(Config::spriteDetection); addControl(Config::spriteFilter); addControl(Config::spriteTexCoord); addControl(Config::textureFilter);