From ea5ccd43c5d0efcd6f83c72f3f977cd410b00d97 Mon Sep 17 00:00:00 2001 From: Elisha Riedlinger Date: Sun, 11 Mar 2018 17:17:27 -0700 Subject: [PATCH] Set video memory size Limit the video memory size as some games like The Settlers IV GOLD won't work with large video memory sizes. --- DDrawCompat/DDrawLog.cpp | 45 ++++++++++++++++++++++++++++++++++++++ DDrawCompat/DDrawLog.h | 1 + Dllmain/BuildNo.rc | 2 +- ddraw/IDirectDrawTypes.cpp | 8 +++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/DDrawCompat/DDrawLog.cpp b/DDrawCompat/DDrawLog.cpp index ffb3f0a0..4ff95c85 100644 --- a/DDrawCompat/DDrawLog.cpp +++ b/DDrawCompat/DDrawLog.cpp @@ -88,6 +88,51 @@ std::ostream& operator<<(std::ostream& os, HWND__& hwnd) return os << "WND(" << static_cast(&hwnd) << ',' << name << ',' << rect << ')'; } +std::ostream& operator<<(std::ostream& os, const DDCAPS& caps) +{ + return Compat::LogStruct(os) + << caps.dwSize + << Compat::hex(caps.dwCaps) + << Compat::hex(caps.dwCaps2) + << Compat::hex(caps.dwCKeyCaps) + << Compat::hex(caps.dwFXCaps) + << Compat::hex(caps.dwFXAlphaCaps) + << Compat::hex(caps.dwPalCaps) + << Compat::hex(caps.dwSVCaps) + << Compat::hex(caps.dwAlphaBltConstBitDepths) + << Compat::hex(caps.dwAlphaBltPixelBitDepths) + << Compat::hex(caps.dwAlphaBltSurfaceBitDepths) + << Compat::hex(caps.dwAlphaOverlayConstBitDepths) + << Compat::hex(caps.dwAlphaOverlayPixelBitDepths) + << Compat::hex(caps.dwAlphaOverlaySurfaceBitDepths) + << Compat::hex(caps.dwZBufferBitDepths) + << Compat::hex(caps.dwVidMemTotal) + << Compat::hex(caps.dwVidMemFree) + << Compat::hex(caps.dwMaxVisibleOverlays) + << Compat::hex(caps.dwCurrVisibleOverlays) + << Compat::hex(caps.dwNumFourCCCodes) + << Compat::hex(caps.dwAlignBoundarySrc) + << Compat::hex(caps.dwAlignSizeSrc) + << Compat::hex(caps.dwAlignBoundaryDest) + << Compat::hex(caps.dwAlignSizeDest) + << Compat::hex(caps.dwAlignStrideAlign) + << "{" << caps.dwRops[0] + << caps.dwRops[1] + << caps.dwRops[2] + << caps.dwRops[3] + << caps.dwRops[4] + << caps.dwRops[5] + << caps.dwRops[6] + << caps.dwRops[7] << "}" + << caps.ddsOldCaps + << Compat::hex(caps.dwMinOverlayStretch) + << Compat::hex(caps.dwMaxOverlayStretch) + << Compat::hex(caps.dwMinLiveVideoStretch) + << Compat::hex(caps.dwMaxLiveVideoStretch) + << Compat::hex(caps.dwMinHwCodecStretch) + << Compat::hex(caps.dwMaxHwCodecStretch); +} + std::ostream& operator<<(std::ostream& os, const DDSCAPS& caps) { return Compat::LogStruct(os) diff --git a/DDrawCompat/DDrawLog.h b/DDrawCompat/DDrawLog.h index e6520151..4df04748 100644 --- a/DDrawCompat/DDrawLog.h +++ b/DDrawCompat/DDrawLog.h @@ -30,6 +30,7 @@ std::ostream& operator<<(std::ostream& os, const DEVMODEW& dm); std::ostream& operator<<(std::ostream& os, const RECT& rect); std::ostream& operator<<(std::ostream& os, HDC__& dc); std::ostream& operator<<(std::ostream& os, HWND__& hwnd); +std::ostream& operator<<(std::ostream& os, const DDCAPS& caps); std::ostream& operator<<(std::ostream& os, const DDSCAPS& caps); std::ostream& operator<<(std::ostream& os, const DDSCAPS2& caps); std::ostream& operator<<(std::ostream& os, const DDPIXELFORMAT& pf); diff --git a/Dllmain/BuildNo.rc b/Dllmain/BuildNo.rc index df834a16..84e75f52 100644 --- a/Dllmain/BuildNo.rc +++ b/Dllmain/BuildNo.rc @@ -1 +1 @@ -#define BUILD_NUMBER 3523 +#define BUILD_NUMBER 3549 diff --git a/ddraw/IDirectDrawTypes.cpp b/ddraw/IDirectDrawTypes.cpp index b02441da..c9e76f28 100644 --- a/ddraw/IDirectDrawTypes.cpp +++ b/ddraw/IDirectDrawTypes.cpp @@ -131,6 +131,14 @@ void ConvertCaps(DDSCAPS2 &Caps2, DDSCAPS &Caps) bool ConvertCaps(DDCAPS_DX7 &Caps, DDCAPS_DX7 &Caps7) { + // Set available memory, some games have issues if this is set to high + if (Config.ConvertToDirectDraw7 && Caps7.dwVidMemTotal > 0x8000000) + { + Caps7.dwVidMemFree = 0x8000000 - (Caps7.dwVidMemTotal - Caps7.dwVidMemFree); + Caps7.dwVidMemTotal = 0x8000000; + } + + // Convert caps switch (Caps.dwSize) { case sizeof(DDCAPS_DX1) :