diff --git a/DDrawCompat/Config/Config.cpp b/DDrawCompat/Config/Config.cpp index fa98087..049fb3e 100644 --- a/DDrawCompat/Config/Config.cpp +++ b/DDrawCompat/Config/Config.cpp @@ -3,6 +3,7 @@ namespace Config { Settings::CpuAffinity cpuAffinity; + Settings::DesktopColorDepth desktopColorDepth; Settings::DisplayResolution displayResolution; Settings::ThreadPriorityBoost threadPriorityBoost; } diff --git a/DDrawCompat/Config/Config.h b/DDrawCompat/Config/Config.h index ab1d135..89649c6 100644 --- a/DDrawCompat/Config/Config.h +++ b/DDrawCompat/Config/Config.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -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; } diff --git a/DDrawCompat/Config/Settings/DesktopColorDepth.h b/DDrawCompat/Config/Settings/DesktopColorDepth.h new file mode 100644 index 0000000..f03d958 --- /dev/null +++ b/DDrawCompat/Config/Settings/DesktopColorDepth.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +namespace Config +{ + namespace Settings + { + class DesktopColorDepth : public MappedSetting + { + public: + static const UINT INITIAL = 0; + + DesktopColorDepth() + : MappedSetting("DesktopColorDepth", INITIAL, { {"initial", INITIAL}, {"8", 8}, {"16", 16}, {"32", 32} }) + { + } + }; + } +} diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 5a310ee..9f0a31f 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -214,6 +214,7 @@ + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index 80a9088..ce3048c 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -438,6 +438,9 @@ Header Files\Gdi + + Header Files\Config\Settings + diff --git a/DDrawCompat/Dll/DllMain.cpp b/DDrawCompat/Dll/DllMain.cpp index 62d3088..2a40cfb 100644 --- a/DDrawCompat/Dll/DllMain.cpp +++ b/DDrawCompat/Dll/DllMain.cpp @@ -77,17 +77,24 @@ namespace Gdi::VirtualScreen::init(); CompatPtr dd; - CALL_ORIG_PROC(DirectDrawCreate)(nullptr, &dd.getRef(), nullptr); - CompatPtr dd7; - CALL_ORIG_PROC(DirectDrawCreateEx)(nullptr, reinterpret_cast(&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 dd7; + result = CALL_ORIG_PROC(DirectDrawCreateEx)( + nullptr, reinterpret_cast(&dd7.getRef()), IID_IDirectDraw7, nullptr); + if (FAILED(result)) + { + Compat::Log() << "ERROR: Failed to create a DirectDraw object for hooking: " << Compat::hex(result); return; } CompatVtable::s_origVtable = *dd.get()->lpVtbl; - HRESULT result = dd->SetCooperativeLevel(dd, nullptr, DDSCL_NORMAL); + result = dd->SetCooperativeLevel(dd, nullptr, DDSCL_NORMAL); if (SUCCEEDED(result)) { CompatVtable::s_origVtable = *dd7.get()->lpVtbl; diff --git a/DDrawCompat/Win32/DisplayMode.cpp b/DDrawCompat/Win32/DisplayMode.cpp index b22f5ec..d2f2796 100644 --- a/DDrawCompat/Win32/DisplayMode.cpp +++ b/DDrawCompat/Win32/DisplayMode.cpp @@ -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);