From 1f9b62ee8e560ea06a7cdc102d6509707c498287 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Oct 2016 19:54:11 -0400 Subject: TITANIC: Implement blitRect to closer match the original --- engines/titanic/support/video_surface.cpp | 33 ++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp index f596689f19..f88f05327f 100644 --- a/engines/titanic/support/video_surface.cpp +++ b/engines/titanic/support/video_surface.cpp @@ -161,12 +161,35 @@ void CVideoSurface::blitRect(const Rect &srcRect, const Rect &destRect, CVideoSu _rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top)); } else if (src->getTransparencySurface()) { transBlitRect(srcRect, destRect, src, false); - } else { - _rawSurface->transBlitFrom(*src->_rawSurface, srcRect, destRect, src->getTransparencyColor(), 1); - } + } else if (lock()) { + if (src->lock()) { + const Graphics::ManagedSurface *srcSurface = src->_rawSurface; + Graphics::ManagedSurface *destSurface = _rawSurface; + Graphics::Surface destArea = destSurface->getSubArea(destRect); + const uint transColor = src->getTransparencyColor(); - src->unlock(); - unlock(); + const uint16 *srcPtr = (const uint16 *)srcSurface->getBasePtr( + srcRect.left, srcRect.top); + uint16 *destPtr = (uint16 *)destArea.getBasePtr(0, 0); + + for (int yCtr = 0; yCtr < srcRect.height(); ++yCtr, + srcPtr += src->getPitch() / 2, + destPtr += destArea.pitch / 2) { + // Prepare for copying the line + const uint16 *lineSrcP = srcPtr; + uint16 *lineDestP = destPtr; + + for (int srcX = srcRect.left; srcX < srcRect.right; ++srcX, ++lineSrcP, ++lineDestP) { + if (*lineSrcP != transColor) + *lineDestP = *lineSrcP; + } + } + + src->unlock(); + } + + unlock(); + } } void CVideoSurface::flippedBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) { -- cgit v1.2.3