From a9da116ceb318d3223bb515cad46f613dfdc0d36 Mon Sep 17 00:00:00 2001 From: Fabio Battaglia Date: Tue, 17 Mar 2009 08:03:29 +0000 Subject: sword1: optimize drawing routine for screen 54 svn-id: r39477 --- engines/sword1/screen.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/engines/sword1/screen.cpp b/engines/sword1/screen.cpp index 15df92b021..72ce14b427 100644 --- a/engines/sword1/screen.cpp +++ b/engines/sword1/screen.cpp @@ -376,17 +376,28 @@ void Screen::draw(void) { if(SwordEngine::isPsx()) { if (!_psxCache.decodedBackground) _psxCache.decodedBackground = psxShrinkedBackgroundToIndexed(_layerBlocks[0], _scrnSizeX, _scrnSizeY); - src = _psxCache.decodedBackground; - } - + memcpy(_screenBuf, _psxCache.decodedBackground, _scrnSizeX * _scrnSizeY); + } else { +#if 0 for (uint16 cnty = 0; cnty < _scrnSizeY; cnty++) for (uint16 cntx = 0; cntx < _scrnSizeX; cntx++) { - if (*src) + if (*(src + cnty * _scrnSizeX + cntx)) if (!(SwordEngine::isMac()) || *src != 255) // see bug #1701058 - *dest = *src; - dest++; - src++; + *(dest + cnty * _scrnSizeX + cntx) = *(src + cnty * _scrnSizeX + cntx); } +#endif + + uint16 scrnScrlY = MIN((uint32)_oldScrollY, Logic::_scriptVars[SCROLL_OFFSET_Y]); + uint16 scrnHeight = SCREEN_DEPTH + ABS((int32)_oldScrollY - (int32)Logic::_scriptVars[SCROLL_OFFSET_Y]); + + // In this background to create transparency we have to iterate through all pixels, avoid checking those out of screen + for (uint16 cnty = scrnScrlY; (cnty < _scrnSizeY) && (cnty < scrnHeight + scrnScrlY); cnty++) + for (uint16 cntx = 0; cntx < _scrnSizeX; cntx++) { + if (*(src + cnty * _scrnSizeX + cntx)) + if (!(SwordEngine::isMac()) || *src != 255) // see bug #1701058 + *(dest + cnty * _scrnSizeX + cntx) = *(src + cnty * _scrnSizeX + cntx); + } + } } else if (!(SwordEngine::isPsx())) { memcpy(_screenBuf, _layerBlocks[0], _scrnSizeX * _scrnSizeY); -- cgit v1.2.3