From c1505d6e51d008e2a482f600a960d8fe8e378f75 Mon Sep 17 00:00:00 2001 From: Andrew Kurushin Date: Thu, 21 Oct 2010 20:13:25 +0000 Subject: SAGA: unroll IsoMap::drawTile buffer copy loop; refactor Sprite::drawClip svn-id: r53677 --- engines/saga/isomap.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'engines/saga/isomap.cpp') diff --git a/engines/saga/isomap.cpp b/engines/saga/isomap.cpp index 87c49047c5..197055a45d 100644 --- a/engines/saga/isomap.cpp +++ b/engines/saga/isomap.cpp @@ -831,18 +831,30 @@ void IsoMap::drawTile(uint16 tileIndex, const Point &point, const Location *loca widthCount += fgRunCount; count = 0; - while ((col < _tileClip.left) && (count < fgRunCount)) { - count++; - col++; + int colDiff = _tileClip.left - col; + if (colDiff > 0) { + if (colDiff > fgRunCount) { + colDiff = fgRunCount; + } + count = colDiff; + col += colDiff; } - while ((col < _tileClip.right) && (count < fgRunCount)) { - assert(_vm->_gfx->getBackBufferPixels() <= (byte *)(drawPointer + count)); - assert((_vm->_gfx->getBackBufferPixels() + (_vm->getDisplayInfo().width * - _vm->getDisplayInfo().height)) > (byte *)(drawPointer + count)); - drawPointer[count] = readPointer[count]; - count++; - col++; + + colDiff = _tileClip.right - col; + if (colDiff > 0) { + int countDiff = fgRunCount - count; + if (colDiff > countDiff) { + colDiff = countDiff; + } + if (colDiff > 0) { + byte *dst = (byte *)(drawPointer + count); + assert(_vm->_gfx->getBackBufferPixels() <= dst); + assert((_vm->_gfx->getBackBufferPixels() + (_vm->getDisplayInfo().width * _vm->getDisplayInfo().height)) >= (byte *)(dst + colDiff)); + memcpy(dst, (readPointer + count), colDiff); + col += colDiff; + } } + readPointer += fgRunCount; drawPointer += fgRunCount; } -- cgit v1.2.3