1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Added DesktopColorDepth setting

This commit is contained in:
narzoul 2021-06-22 23:56:34 +02:00
parent 7dfb030ae2
commit ee350c7f08
7 changed files with 47 additions and 8 deletions

View File

@ -3,6 +3,7 @@
namespace Config
{
Settings::CpuAffinity cpuAffinity;
Settings::DesktopColorDepth desktopColorDepth;
Settings::DisplayResolution displayResolution;
Settings::ThreadPriorityBoost threadPriorityBoost;
}

View File

@ -1,6 +1,7 @@
#pragma once
#include <Config/Settings/CpuAffinity.h>
#include <Config/Settings/DesktopColorDepth.h>
#include <Config/Settings/DisplayResolution.h>
#include <Config/Settings/ThreadPriorityBoost.h>
@ -11,6 +12,7 @@ namespace Config
const unsigned maxPaletteUpdatesPerMs = 5;
extern Settings::CpuAffinity cpuAffinity;
extern Settings::DesktopColorDepth desktopColorDepth;
extern Settings::DisplayResolution displayResolution;
extern Settings::ThreadPriorityBoost threadPriorityBoost;
}

View File

@ -0,0 +1,20 @@
#pragma once
#include <Config/MappedSetting.h>
namespace Config
{
namespace Settings
{
class DesktopColorDepth : public MappedSetting<UINT>
{
public:
static const UINT INITIAL = 0;
DesktopColorDepth()
: MappedSetting("DesktopColorDepth", INITIAL, { {"initial", INITIAL}, {"8", 8}, {"16", 16}, {"32", 32} })
{
}
};
}
}

View File

@ -214,6 +214,7 @@
<ClInclude Include="Config\Parser.h" />
<ClInclude Include="Config\Setting.h" />
<ClInclude Include="Config\Settings\CpuAffinity.h" />
<ClInclude Include="Config\Settings\DesktopColorDepth.h" />
<ClInclude Include="Config\Settings\DisplayResolution.h" />
<ClInclude Include="Config\Settings\ThreadPriorityBoost.h" />
<ClInclude Include="D3dDdi\Adapter.h" />

View File

@ -438,6 +438,9 @@
<ClInclude Include="Gdi\Cursor.h">
<Filter>Header Files\Gdi</Filter>
</ClInclude>
<ClInclude Include="Config\Settings\DesktopColorDepth.h">
<Filter>Header Files\Config\Settings</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Gdi\Gdi.cpp">

View File

@ -77,17 +77,24 @@ namespace
Gdi::VirtualScreen::init();
CompatPtr<IDirectDraw> dd;
CALL_ORIG_PROC(DirectDrawCreate)(nullptr, &dd.getRef(), nullptr);
CompatPtr<IDirectDraw7> dd7;
CALL_ORIG_PROC(DirectDrawCreateEx)(nullptr, reinterpret_cast<void**>(&dd7.getRef()), IID_IDirectDraw7, nullptr);
if (!dd || !dd7)
HRESULT result = CALL_ORIG_PROC(DirectDrawCreate)(nullptr, &dd.getRef(), nullptr);
if (FAILED(result))
{
Compat::Log() << "ERROR: Failed to create a DirectDraw object for hooking";
Compat::Log() << "ERROR: Failed to create a DirectDraw object for hooking: " << Compat::hex(result);
return;
}
CompatPtr<IDirectDraw7> dd7;
result = CALL_ORIG_PROC(DirectDrawCreateEx)(
nullptr, reinterpret_cast<void**>(&dd7.getRef()), IID_IDirectDraw7, nullptr);
if (FAILED(result))
{
Compat::Log() << "ERROR: Failed to create a DirectDraw object for hooking: " << Compat::hex(result);
return;
}
CompatVtable<IDirectDrawVtbl>::s_origVtable = *dd.get()->lpVtbl;
HRESULT result = dd->SetCooperativeLevel(dd, nullptr, DDSCL_NORMAL);
result = dd->SetCooperativeLevel(dd, nullptr, DDSCL_NORMAL);
if (SUCCEEDED(result))
{
CompatVtable<IDirectDraw7Vtbl>::s_origVtable = *dd7.get()->lpVtbl;

View File

@ -624,8 +624,13 @@ namespace Win32
DEVMODEA dm = {};
dm.dmSize = sizeof(dm);
EnumDisplaySettingsEx(nullptr, ENUM_CURRENT_SETTINGS, &dm, 0);
g_desktopBpp = dm.dmBitsPerPel;
g_emulatedDisplayMode.bpp = dm.dmBitsPerPel;
g_desktopBpp = Config::desktopColorDepth.get();
if (Config::Settings::DesktopColorDepth::INITIAL == g_desktopBpp)
{
g_desktopBpp = dm.dmBitsPerPel;
}
g_emulatedDisplayMode.bpp = g_desktopBpp;
EnumDisplayMonitors(nullptr, nullptr, &initMonitor, 0);