From 8246758e7eb8b43c13173f2ec1714a3ed622cb0c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 Mar 2011 14:20:15 +1100 Subject: TSAGE: Implement original engine scene scrolling optimisations Wide screens are broken into 160x100 chunks. When scrolling, sections of the scene which have already been previously decoded for display can be reused, rather than re-decoding them from scratch --- engines/tsage/scenes.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index fab5afff71..a1dfe0b2ce 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -360,19 +360,20 @@ void Scene::refreshBackground(int xAmount, int yAmount) { _enabledSections[xp * 16 + yp] = 0xffff; } else { // Check if the section is already loaded -// if (_enabledSections[xp * 16 + yp] || ((xAmount == 0) && (yAmount == 0))) { + if ((_enabledSections[xp * 16 + yp] == 0xffff) || ((xAmount == 0) && (yAmount == 0))) { + // Chunk isn't loaded, so load it in Graphics::Surface s = _backSurface.lockSurface(); GfxSurface::loadScreenSection(s, xp - xHalfOffset, yp - yHalfOffset, xp, yp); _backSurface.unlockSurface(); changedFlag = true; -/* } else { - int yv = _enabledSections[xp * 16 + yp] == ((xp - xHalfOffset) << 4) ? 0 : 1; - if (yv != (yp - yHalfOffset)) { + } else { + int yv = (_enabledSections[xp * 16 + yp] == ((xp - xHalfOffset) << 4)) ? 0 : 1; + if (yv | (yp - yHalfOffset)) { // Copy an existing 160x100 screen section previously loaded - int xSectionSrc = xp - xHalfOffset; - int ySectionSrc = yp - yHalfOffset; - int xSectionDest = _enabledSections[xp * 16 + yp] >> 4; - int ySectionDest = _enabledSections[xp * 16 + yp] & 0xffff; + int xSectionDest = xp - xHalfOffset; + int ySectionDest = yp - yHalfOffset; + int xSectionSrc = _enabledSections[xp * 16 + yp] >> 4; + int ySectionSrc = _enabledSections[xp * 16 + yp] & 0xf; Rect srcBounds(xSectionSrc * 160, ySectionSrc * 100, (xSectionSrc + 1) * 160, (ySectionSrc + 1) * 100); @@ -381,10 +382,10 @@ void Scene::refreshBackground(int xAmount, int yAmount) { _backSurface.copyFrom(_backSurface, srcBounds, destBounds); } - }*/ + } _enabledSections[xp * 16 + yp] = - ((xp - xHalfOffset) << 4) && (yp - yHalfOffset); + ((xp - xHalfOffset) << 4) | (yp - yHalfOffset); } } } -- cgit v1.2.3