From 4ca4e5d6cae11418bb4ef26a382d2a649ebd46f6 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 21 Jun 2020 13:42:49 +0200 Subject: [PATCH] Fixed overlap detection in Blitter Fixes graphics corruption in TalesWeaver (issue #72). --- DDrawCompat/DDraw/Blitter.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/DDrawCompat/DDraw/Blitter.cpp b/DDrawCompat/DDraw/Blitter.cpp index 16af97f..9db6b05 100644 --- a/DDrawCompat/DDraw/Blitter.cpp +++ b/DDrawCompat/DDraw/Blitter.cpp @@ -516,6 +516,20 @@ namespace srcRect.bottom += srcRect.top; srcRect.right += srcRect.left; + LONG rowError = 0; + if (src < dst) + { + rowError = (dstRect.right - srcRect.left > static_cast(pitch)) ? 1 : 0; + } + else + { + rowError = (srcRect.right - dstRect.left > static_cast(pitch)) ? -1 : 0; + } + srcRect.left += rowError * pitch; + srcRect.right += rowError * pitch; + srcRect.top -= rowError; + srcRect.bottom -= rowError; + RECT r = {}; if (!IntersectRect(&r, &dstRect, &srcRect)) {