diff --git a/DDrawCompat/Config/Config.h b/DDrawCompat/Config/Config.h index 3ef60c6..861269a 100644 --- a/DDrawCompat/Config/Config.h +++ b/DDrawCompat/Config/Config.h @@ -4,10 +4,7 @@ typedef unsigned long DWORD; namespace Config { - const int maxUserModeDisplayDrivers = 3; - const int delayedFlipModeTimeout = 200; const int maxPaletteUpdatesPerMs = 5; - const int minExpectedFlipsPerSec = 5; - const int virtualScreenBufferExtraRows = 2; + const int maxUserModeDisplayDrivers = 3; } diff --git a/DDrawCompat/D3dDdi/Resource.cpp b/DDrawCompat/D3dDdi/Resource.cpp index a0df88e..9301d2a 100644 --- a/DDrawCompat/D3dDdi/Resource.cpp +++ b/DDrawCompat/D3dDdi/Resource.cpp @@ -300,6 +300,7 @@ namespace D3dDdi HRESULT Resource::copySubResource(HANDLE dstResource, HANDLE srcResource, UINT subResourceIndex) { + LOG_FUNC("Resource::copySubResource", dstResource, srcResource, subResourceIndex); RECT rect = {}; rect.right = m_fixedData.pSurfList[subResourceIndex].Width; rect.bottom = m_fixedData.pSurfList[subResourceIndex].Height; @@ -317,7 +318,7 @@ namespace D3dDdi { LOG_ONCE("ERROR: Resource::copySubResource failed: " << Compat::hex(result)); } - return result; + return LOG_RESULT(result); } void Resource::copyToSysMem(UINT subResourceIndex) @@ -358,11 +359,18 @@ namespace D3dDdi auto width = m_fixedData.pSurfList[i].Width; auto height = m_fixedData.pSurfList[i].Height; auto pitch = divCeil(width * m_formatInfo.bytesPerPixel, 8) * 8; - m_lockBuffers[i].resize(pitch * height); + m_lockBuffers[i].resize(pitch * height + 8); surfaceInfo[i].Width = width; surfaceInfo[i].Height = height; - surfaceInfo[i].pSysMem = m_lockBuffers[i].data(); + if (reinterpret_cast(m_lockBuffers[i].data()) % 16 == 0) + { + surfaceInfo[i].pSysMem = m_lockBuffers[i].data() + 8; + } + else + { + surfaceInfo[i].pSysMem = m_lockBuffers[i].data(); + } surfaceInfo[i].SysMemPitch = pitch; } @@ -375,6 +383,7 @@ namespace D3dDdi void Resource::createSysMemResource(const std::vector& surfaceInfo) { + LOG_FUNC("Resource::createSysMemResource", Compat::array(surfaceInfo.data(), surfaceInfo.size())); D3DDDIARG_CREATERESOURCE2 data = {}; data.Format = m_fixedData.Format; data.Pool = D3DDDIPOOL_SYSTEMMEM; @@ -396,6 +405,7 @@ namespace D3dDdi if (FAILED(result)) { + LOG_RESULT(nullptr); return; } @@ -408,6 +418,7 @@ namespace D3dDdi m_lockData[i].isSysMemUpToDate = false; m_lockData[i].isVidMemUpToDate = true; } + LOG_RESULT(m_lockResource); } void Resource::copyToVidMem(UINT subResourceIndex) diff --git a/DDrawCompat/Gdi/VirtualScreen.cpp b/DDrawCompat/Gdi/VirtualScreen.cpp index 8a2cfbb..6ad05c2 100644 --- a/DDrawCompat/Gdi/VirtualScreen.cpp +++ b/DDrawCompat/Gdi/VirtualScreen.cpp @@ -66,7 +66,7 @@ namespace } void* bits = nullptr; - return CreateDIBSection(nullptr, &bmi, DIB_RGB_COLORS, &bits, section, 0); + return CreateDIBSection(nullptr, &bmi, DIB_RGB_COLORS, &bits, section, 8); } } @@ -181,7 +181,7 @@ namespace Gdi desc.ddpfPixelFormat = DDraw::getRgbPixelFormat(g_bpp); desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; desc.lPitch = g_pitch; - desc.lpSurface = static_cast(g_surfaceView) + + desc.lpSurface = static_cast(g_surfaceView) + 8 + (rect.top - g_bounds.top) * g_pitch + (rect.left - g_bounds.left) * g_bpp / 8; return desc; @@ -231,7 +231,7 @@ namespace Gdi } g_surfaceFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, - g_pitch * (g_height + Config::virtualScreenBufferExtraRows), nullptr); + g_pitch * g_height + 8, nullptr); g_surfaceView = MapViewOfFile(g_surfaceFileMapping, FILE_MAP_WRITE, 0, 0, 0); for (HDC dc : g_dcs)