mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Added SurfacePatches setting
This commit is contained in:
parent
5b35b3b261
commit
ea4097d810
@ -43,6 +43,7 @@
|
|||||||
#include <Config/Settings/SupportedResolutions.h>
|
#include <Config/Settings/SupportedResolutions.h>
|
||||||
#include <Config/Settings/SupportedDepthFormats.h>
|
#include <Config/Settings/SupportedDepthFormats.h>
|
||||||
#include <Config/Settings/SupportedTextureFormats.h>
|
#include <Config/Settings/SupportedTextureFormats.h>
|
||||||
|
#include <Config/Settings/SurfacePatches.h>
|
||||||
#include <Config/Settings/TerminateHotKey.h>
|
#include <Config/Settings/TerminateHotKey.h>
|
||||||
#include <Config/Settings/TextureFilter.h>
|
#include <Config/Settings/TextureFilter.h>
|
||||||
#include <Config/Settings/ThreadPriorityBoost.h>
|
#include <Config/Settings/ThreadPriorityBoost.h>
|
||||||
@ -97,6 +98,7 @@ namespace Config
|
|||||||
Settings::SupportedResolutions supportedResolutions;
|
Settings::SupportedResolutions supportedResolutions;
|
||||||
Settings::SupportedDepthFormats supportedDepthFormats;
|
Settings::SupportedDepthFormats supportedDepthFormats;
|
||||||
Settings::SupportedTextureFormats supportedTextureFormats;
|
Settings::SupportedTextureFormats supportedTextureFormats;
|
||||||
|
Settings::SurfacePatches surfacePatches;
|
||||||
Settings::TerminateHotKey terminateHotKey;
|
Settings::TerminateHotKey terminateHotKey;
|
||||||
Settings::TextureFilter textureFilter;
|
Settings::TextureFilter textureFilter;
|
||||||
Settings::ThreadPriorityBoost threadPriorityBoost;
|
Settings::ThreadPriorityBoost threadPriorityBoost;
|
||||||
|
@ -8,6 +8,15 @@ namespace Config
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListSetting::appendToList(std::string& list, const std::string& value)
|
||||||
|
{
|
||||||
|
if (!list.empty())
|
||||||
|
{
|
||||||
|
list += ", ";
|
||||||
|
}
|
||||||
|
list += value;
|
||||||
|
}
|
||||||
|
|
||||||
void ListSetting::setValue(const std::string& value)
|
void ListSetting::setValue(const std::string& value)
|
||||||
{
|
{
|
||||||
std::vector<std::string> values;
|
std::vector<std::string> values;
|
||||||
|
@ -13,5 +13,7 @@ namespace Config
|
|||||||
|
|
||||||
virtual void setValue(const std::string& value) override;
|
virtual void setValue(const std::string& value) override;
|
||||||
virtual void setValues(const std::vector<std::string>& values) = 0;
|
virtual void setValues(const std::vector<std::string>& values) = 0;
|
||||||
|
|
||||||
|
static void appendToList(std::string& list, const std::string& value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
78
DDrawCompat/Config/Settings/SurfacePatches.cpp
Normal file
78
DDrawCompat/Config/Settings/SurfacePatches.cpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#include <Common/Comparison.h>
|
||||||
|
#include <Config/Parser.h>
|
||||||
|
#include <Config/Settings/SurfacePatches.h>
|
||||||
|
|
||||||
|
namespace Config
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
SurfacePatches::SurfacePatches()
|
||||||
|
: ListSetting("SurfacePatches", "none")
|
||||||
|
, m_top(0)
|
||||||
|
, m_bottom(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SurfacePatches::getValueStr() const
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
if (0 != m_top)
|
||||||
|
{
|
||||||
|
appendToList(result, "top:" + std::to_string(m_top));
|
||||||
|
}
|
||||||
|
if (0 != m_bottom)
|
||||||
|
{
|
||||||
|
appendToList(result, "bottom:" + std::to_string(m_bottom));
|
||||||
|
}
|
||||||
|
if (result.empty())
|
||||||
|
{
|
||||||
|
result = "none";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SurfacePatches::setValues(const std::vector<std::string>& values)
|
||||||
|
{
|
||||||
|
unsigned top = 0;
|
||||||
|
unsigned bottom = 0;
|
||||||
|
|
||||||
|
for (const auto& v : values)
|
||||||
|
{
|
||||||
|
if ("none" == v)
|
||||||
|
{
|
||||||
|
if (1 != values.size())
|
||||||
|
{
|
||||||
|
throw ParsingError("'none' cannot be combined with other values");
|
||||||
|
}
|
||||||
|
m_top = 0;
|
||||||
|
m_bottom = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto separator = v.find(':');
|
||||||
|
if (std::string::npos == separator || 0 == separator || v.size() - 1 == separator)
|
||||||
|
{
|
||||||
|
throw ParsingError("invalid value: '" + v + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto specifier = v.substr(0, separator);
|
||||||
|
auto rows = Parser::parseInt(v.substr(separator + 1), 1, 1000);
|
||||||
|
if ("top" == specifier)
|
||||||
|
{
|
||||||
|
top = rows;
|
||||||
|
}
|
||||||
|
else if ("bottom" == specifier)
|
||||||
|
{
|
||||||
|
bottom = rows;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw ParsingError("invalid specifier: '" + specifier + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_top = top;
|
||||||
|
m_bottom = bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
DDrawCompat/Config/Settings/SurfacePatches.h
Normal file
28
DDrawCompat/Config/Settings/SurfacePatches.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Config/ListSetting.h>
|
||||||
|
|
||||||
|
namespace Config
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
class SurfacePatches : public ListSetting
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SurfacePatches();
|
||||||
|
|
||||||
|
virtual std::string getValueStr() const override;
|
||||||
|
|
||||||
|
unsigned getTop() const { return m_top; }
|
||||||
|
unsigned getBottom() const { return m_bottom; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setValues(const std::vector<std::string>& values) override;
|
||||||
|
|
||||||
|
unsigned m_top;
|
||||||
|
unsigned m_bottom;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
extern Settings::SurfacePatches surfacePatches;
|
||||||
|
}
|
@ -9,6 +9,7 @@
|
|||||||
#include <Config/Settings/ColorKeyMethod.h>
|
#include <Config/Settings/ColorKeyMethod.h>
|
||||||
#include <Config/Settings/DepthFormat.h>
|
#include <Config/Settings/DepthFormat.h>
|
||||||
#include <Config/Settings/ResolutionScaleFilter.h>
|
#include <Config/Settings/ResolutionScaleFilter.h>
|
||||||
|
#include <Config/Settings/SurfacePatches.h>
|
||||||
#include <D3dDdi/Adapter.h>
|
#include <D3dDdi/Adapter.h>
|
||||||
#include <D3dDdi/Device.h>
|
#include <D3dDdi/Device.h>
|
||||||
#include <D3dDdi/KernelModeThunks.h>
|
#include <D3dDdi/KernelModeThunks.h>
|
||||||
@ -620,11 +621,20 @@ namespace D3dDdi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned topExtraRows = 0;
|
||||||
|
unsigned totalExtraRows = 0;
|
||||||
|
if (1 == m_fixedData.SurfCount && !m_origData.Flags.Texture)
|
||||||
|
{
|
||||||
|
topExtraRows = Config::surfacePatches.getTop();
|
||||||
|
totalExtraRows = topExtraRows + Config::surfacePatches.getBottom();
|
||||||
|
}
|
||||||
|
|
||||||
std::uintptr_t bufferSize = reinterpret_cast<std::uintptr_t>(surfaceInfo.back().pSysMem) +
|
std::uintptr_t bufferSize = reinterpret_cast<std::uintptr_t>(surfaceInfo.back().pSysMem) +
|
||||||
surfaceInfo.back().SysMemPitch * surfaceInfo.back().Height + ALIGNMENT;
|
surfaceInfo.back().SysMemPitch * (surfaceInfo.back().Height + totalExtraRows) + ALIGNMENT;
|
||||||
m_lockBuffer.reset(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufferSize));
|
m_lockBuffer.reset(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufferSize));
|
||||||
|
|
||||||
BYTE* bufferStart = static_cast<BYTE*>(DDraw::Surface::alignBuffer(m_lockBuffer.get()));
|
BYTE* bufferStart = static_cast<BYTE*>(DDraw::Surface::alignBuffer(
|
||||||
|
static_cast<BYTE*>(m_lockBuffer.get()) + topExtraRows * surfaceInfo.back().SysMemPitch));
|
||||||
for (UINT i = 0; i < m_fixedData.SurfCount; ++i)
|
for (UINT i = 0; i < m_fixedData.SurfCount; ++i)
|
||||||
{
|
{
|
||||||
surfaceInfo[i].pSysMem = bufferStart + reinterpret_cast<uintptr_t>(surfaceInfo[i].pSysMem);
|
surfaceInfo[i].pSysMem = bufferStart + reinterpret_cast<uintptr_t>(surfaceInfo[i].pSysMem);
|
||||||
|
@ -208,6 +208,7 @@
|
|||||||
<ClInclude Include="Config\Settings\SupportedDepthFormats.h" />
|
<ClInclude Include="Config\Settings\SupportedDepthFormats.h" />
|
||||||
<ClInclude Include="Config\Settings\SupportedResolutions.h" />
|
<ClInclude Include="Config\Settings\SupportedResolutions.h" />
|
||||||
<ClInclude Include="Config\Settings\SupportedTextureFormats.h" />
|
<ClInclude Include="Config\Settings\SupportedTextureFormats.h" />
|
||||||
|
<ClInclude Include="Config\Settings\SurfacePatches.h" />
|
||||||
<ClInclude Include="Config\Settings\TerminateHotKey.h" />
|
<ClInclude Include="Config\Settings\TerminateHotKey.h" />
|
||||||
<ClInclude Include="Config\Settings\TextureFilter.h" />
|
<ClInclude Include="Config\Settings\TextureFilter.h" />
|
||||||
<ClInclude Include="Config\Settings\ThreadPriorityBoost.h" />
|
<ClInclude Include="Config\Settings\ThreadPriorityBoost.h" />
|
||||||
@ -366,6 +367,7 @@
|
|||||||
<ClCompile Include="Config\Settings\SupportedDepthFormats.cpp" />
|
<ClCompile Include="Config\Settings\SupportedDepthFormats.cpp" />
|
||||||
<ClCompile Include="Config\Settings\SupportedResolutions.cpp" />
|
<ClCompile Include="Config\Settings\SupportedResolutions.cpp" />
|
||||||
<ClCompile Include="Config\Settings\SupportedTextureFormats.cpp" />
|
<ClCompile Include="Config\Settings\SupportedTextureFormats.cpp" />
|
||||||
|
<ClCompile Include="Config\Settings\SurfacePatches.cpp" />
|
||||||
<ClCompile Include="Config\Settings\TextureFilter.cpp" />
|
<ClCompile Include="Config\Settings\TextureFilter.cpp" />
|
||||||
<ClCompile Include="Config\Settings\VSync.cpp" />
|
<ClCompile Include="Config\Settings\VSync.cpp" />
|
||||||
<ClCompile Include="Config\Settings\WinVersionLie.cpp" />
|
<ClCompile Include="Config\Settings\WinVersionLie.cpp" />
|
||||||
|
@ -711,6 +711,9 @@
|
|||||||
<ClInclude Include="Overlay\Steam.h">
|
<ClInclude Include="Overlay\Steam.h">
|
||||||
<Filter>Header Files\Overlay</Filter>
|
<Filter>Header Files\Overlay</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Config\Settings\SurfacePatches.h">
|
||||||
|
<Filter>Header Files\Config\Settings</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Gdi\Gdi.cpp">
|
<ClCompile Include="Gdi\Gdi.cpp">
|
||||||
@ -1112,6 +1115,9 @@
|
|||||||
<ClCompile Include="Overlay\Steam.cpp">
|
<ClCompile Include="Overlay\Steam.cpp">
|
||||||
<Filter>Source Files\Overlay</Filter>
|
<Filter>Source Files\Overlay</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Config\Settings\SurfacePatches.cpp">
|
||||||
|
<Filter>Source Files\Config\Settings</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="DDrawCompat.rc">
|
<ResourceCompile Include="DDrawCompat.rc">
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <Config/Settings/AlignSysMemSurfaces.h>
|
|
||||||
#include <Common/ScopedCriticalSection.h>
|
#include <Common/ScopedCriticalSection.h>
|
||||||
|
#include <Config/Settings/AlignSysMemSurfaces.h>
|
||||||
|
#include <Config/Settings/SurfacePatches.h>
|
||||||
#include <D3dDdi/Device.h>
|
#include <D3dDdi/Device.h>
|
||||||
#include <D3dDdi/Resource.h>
|
#include <D3dDdi/Resource.h>
|
||||||
#include <D3dDdi/ScopedCriticalSection.h>
|
#include <D3dDdi/ScopedCriticalSection.h>
|
||||||
@ -29,6 +30,7 @@ namespace
|
|||||||
LONG g_width = 0;
|
LONG g_width = 0;
|
||||||
LONG g_height = 0;
|
LONG g_height = 0;
|
||||||
DWORD g_pitch = 0;
|
DWORD g_pitch = 0;
|
||||||
|
DWORD g_startOffset = 0;
|
||||||
HANDLE g_surfaceFileMapping = nullptr;
|
HANDLE g_surfaceFileMapping = nullptr;
|
||||||
void* g_surfaceView = nullptr;
|
void* g_surfaceView = nullptr;
|
||||||
bool g_isFullscreen = false;
|
bool g_isFullscreen = false;
|
||||||
@ -82,7 +84,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* bits = nullptr;
|
void* bits = nullptr;
|
||||||
return CreateDIBSection(nullptr, &bmi, DIB_RGB_COLORS, &bits, section, Config::alignSysMemSurfaces.get());
|
return CreateDIBSection(nullptr, &bmi, DIB_RGB_COLORS, &bits, section, g_startOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +208,7 @@ namespace Gdi
|
|||||||
desc.ddpfPixelFormat = DDraw::DirectDraw::getRgbPixelFormat(g_bpp);
|
desc.ddpfPixelFormat = DDraw::DirectDraw::getRgbPixelFormat(g_bpp);
|
||||||
desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
||||||
desc.lPitch = g_pitch;
|
desc.lPitch = g_pitch;
|
||||||
desc.lpSurface = static_cast<unsigned char*>(g_surfaceView) + Config::alignSysMemSurfaces.get() +
|
desc.lpSurface = static_cast<unsigned char*>(g_surfaceView) + g_startOffset +
|
||||||
(rect.top - g_bounds.top) * g_pitch +
|
(rect.top - g_bounds.top) * g_pitch +
|
||||||
(rect.left - g_bounds.left) * g_bpp / 8;
|
(rect.left - g_bounds.left) * g_bpp / 8;
|
||||||
return desc;
|
return desc;
|
||||||
@ -287,10 +289,16 @@ namespace Gdi
|
|||||||
CloseHandle(g_surfaceFileMapping);
|
CloseHandle(g_surfaceFileMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto totalExtraRows = Config::surfacePatches.getTop() + Config::surfacePatches.getBottom();
|
||||||
g_surfaceFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0,
|
g_surfaceFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0,
|
||||||
g_pitch * g_height + 8, nullptr);
|
(g_height + totalExtraRows) * g_pitch + DDraw::Surface::ALIGNMENT, nullptr);
|
||||||
g_surfaceView = MapViewOfFile(g_surfaceFileMapping, FILE_MAP_WRITE, 0, 0, 0);
|
g_surfaceView = MapViewOfFile(g_surfaceFileMapping, FILE_MAP_WRITE, 0, 0, 0);
|
||||||
|
|
||||||
|
auto start = static_cast<BYTE*>(g_surfaceView);
|
||||||
|
start += Config::surfacePatches.getTop() * g_pitch;
|
||||||
|
start = static_cast<BYTE*>(DDraw::Surface::alignBuffer(start));
|
||||||
|
g_startOffset = start - static_cast<BYTE*>(g_surfaceView);
|
||||||
|
|
||||||
for (auto& dc : g_dcs)
|
for (auto& dc : g_dcs)
|
||||||
{
|
{
|
||||||
SelectObject(dc.first, createDib(dc.second.useDefaultPalette));
|
SelectObject(dc.first, createDib(dc.second.useDefaultPalette));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user