From 171cf4cc9289633e60e831b43424a7eb8bca6607 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Oct 2016 19:45:02 -0400 Subject: TITANIC: Implement flippedBlitRect to closer match the original --- engines/titanic/support/video_surface.cpp | 32 +++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp index 7b5a96fb9f..f596689f19 100644 --- a/engines/titanic/support/video_surface.cpp +++ b/engines/titanic/support/video_surface.cpp @@ -172,13 +172,33 @@ void CVideoSurface::blitRect(const Rect &srcRect, const Rect &destRect, CVideoSu void CVideoSurface::flippedBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) { if (src->getTransparencySurface()) { transBlitRect(srcRect, destRect, src, true); - } else { - src->lock(); - lock(); + } 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(); - _rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top)); + const uint16 *srcPtr = (const uint16 *)srcSurface->getBasePtr( + srcRect.left, srcRect.top); + uint16 *destPtr = (uint16 *)destArea.getBasePtr(0, destArea.h - 1); + + 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(); + } - src->unlock(); unlock(); } } @@ -194,7 +214,7 @@ void CVideoSurface::transBlitRect(const Rect &srcRect, const Rect &destRect, CVi const uint16 *srcPtr = (const uint16 *)srcSurface->getBasePtr( srcRect.left, flipFlag ? srcRect.top : srcRect.bottom - 1); - uint16 *destPtr = (uint16 *)destSurface->getBasePtr(0, destArea.h - 1); + uint16 *destPtr = (uint16 *)destArea.getBasePtr(0, destArea.h - 1); bool is16Bit = src->getPixelDepth() == 2; bool isAlpha = src->_transparencyMode == TRANS_ALPHA0 || src->_transparencyMode == TRANS_ALPHA255; -- cgit v1.2.3