aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/tsage/globals.cpp4
-rw-r--r--engines/tsage/globals.h2
-rw-r--r--engines/tsage/graphics.cpp4
-rw-r--r--engines/tsage/scenes.cpp50
-rw-r--r--engines/tsage/scenes.h1
5 files changed, 31 insertions, 30 deletions
diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp
index 11e8af1ffc..2bf47a3ed7 100644
--- a/engines/tsage/globals.cpp
+++ b/engines/tsage/globals.cpp
@@ -63,7 +63,7 @@ Globals::Globals():
_sceneObjects = &_sceneObjectsInstance;
_sceneObjects_queue.push_front(_sceneObjects);
- _stru_4642E = Common::Point(-1, -1);
+ _prevSceneOffset = Common::Point(-1, -1);
_sceneListeners.push_back(&_soundHandler);
_sceneListeners.push_back(&_sequenceManager._soundHandler);
}
@@ -95,7 +95,7 @@ void Globals::synchronise(Serialiser &s) {
s.syncAsByte(_flags[i]);
s.syncAsSint16LE(_sceneOffset.x); s.syncAsSint16LE(_sceneOffset.y);
- s.syncAsSint16LE(_stru_4642E.x); s.syncAsSint16LE(_stru_4642E.y);
+ s.syncAsSint16LE(_prevSceneOffset.x); s.syncAsSint16LE(_prevSceneOffset.y);
SYNC_POINTER(_scrollFollower);
s.syncAsSint32LE(_stripNum);
}
diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h
index 243fb1eae9..c06c073691 100644
--- a/engines/tsage/globals.h
+++ b/engines/tsage/globals.h
@@ -65,7 +65,7 @@ public:
Region _paneRegions[2];
int _paneRefreshFlag[2];
Common::Point _sceneOffset;
- Common::Point _stru_4642E;
+ Common::Point _prevSceneOffset;
SceneObject *_scrollFollower;
SequenceManager _sequenceManager;
Common::RandomSource _randomSource;
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index 93bb7ea63f..93ac9f07d7 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -405,8 +405,8 @@ void GfxSurface::loadScreenSection(Graphics::Surface &dest, int xHalf, int yHalf
int screenNum = _globals->_sceneManager._scene->_activeScreenNumber;
Rect updateRect(0, 0, 160, 100);
updateRect.translate(xHalf * 160, yHalf * 100);
- int xHalfCount = (dest.w + 159) / 160;
- int yHalfCount = (dest.h + 99) / 100;
+ int xHalfCount = (_globals->_sceneManager._scene->_backgroundBounds.right + 159) / 160;
+ int yHalfCount = (_globals->_sceneManager._scene->_backgroundBounds.bottom + 99) / 100;
if (xSection < xHalfCount && ySection < yHalfCount) {
int rlbNum = xSection * yHalfCount + ySection;
diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp
index cc5ccb333a..fab5afff71 100644
--- a/engines/tsage/scenes.cpp
+++ b/engines/tsage/scenes.cpp
@@ -167,8 +167,8 @@ void SceneManager::setBackSurface() {
_globals->_sceneManager._scene->_backSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT);
_globals->_sceneManager._scrollerRect = Rect(0, 30, SCREEN_WIDTH, SCREEN_HEIGHT - 30);
} else {
- // Double-size size creation
- _globals->_sceneManager._scene->_backSurface.create(SCREEN_WIDTH * 2, SCREEN_HEIGHT);
+ // Wide screen needs extra space to allow for scrolling
+ _globals->_sceneManager._scene->_backSurface.create(SCREEN_WIDTH * 3 / 2, SCREEN_HEIGHT);
_globals->_sceneManager._scrollerRect = Rect(80, 0, SCREEN_WIDTH - 80, SCREEN_HEIGHT);
}
} else {
@@ -235,7 +235,7 @@ void Scene::synchronise(Serialiser &s) {
_oldSceneBounds.synchronise(s);
for (int i = 0; i < 256; ++i)
- s.syncAsSint16LE(_enabledSections[i]);
+ s.syncAsUint16LE(_enabledSections[i]);
for (int i = 0; i < 256; ++i)
s.syncAsSint16LE(_zoomPercents[i]);
}
@@ -325,10 +325,10 @@ void Scene::loadBackground(int xAmount, int yAmount) {
if ((_backgroundBounds.height() / 100) == 3)
_globals->_sceneOffset.y = 0;
- if ((_globals->_sceneOffset.x != _globals->_stru_4642E.y) ||
- (_globals->_sceneOffset.y != _globals->_stru_4642E.y)) {
+ if ((_globals->_sceneOffset.x != _globals->_prevSceneOffset.x) ||
+ (_globals->_sceneOffset.y != _globals->_prevSceneOffset.y)) {
// Change has happend, so refresh background
- _globals->_stru_4642E = _globals->_sceneOffset;
+ _globals->_prevSceneOffset = _globals->_sceneOffset;
refreshBackground(xAmount, yAmount);
}
}
@@ -345,35 +345,43 @@ void Scene::refreshBackground(int xAmount, int yAmount) {
// Set the limits and increment amounts
int xInc = (xAmount < 0) ? -1 : 1;
- int xSection = (xAmount < 0) ? 15 : 0;
+ int xSectionStart = (xAmount < 0) ? 15 : 0;
int xSectionEnd = (xAmount < 0) ? -1 : 16;
int yInc = (yAmount < 0) ? -1 : 1;
- int ySection = (yAmount < 0) ? 15 : 0;
+ int ySectionStart = (yAmount < 0) ? 15 : 0;
int ySectionEnd = (yAmount < 0) ? -1 : 16;
bool changedFlag = false;
- for (int yp = ySection; yp < ySectionEnd; yp += yInc) {
- for (int xp = xSection; xp < xSectionEnd; xp += xInc) {
+ for (int yp = ySectionStart; yp != ySectionEnd; yp += yInc) {
+ for (int xp = xSectionStart; xp != xSectionEnd; xp += xInc) {
if ((yp < yHalfOffset) || (yp >= (yHalfOffset + yHalfCount)) ||
(xp < xHalfOffset) || (xp >= (xHalfOffset + xHalfCount))) {
// Flag section as enabled
_enabledSections[xp * 16 + yp] = 0xffff;
} else {
- // Check if the section is enabled
- if (_enabledSections[xp * 16 + yp] || ((xAmount == 0) && (yAmount == 0))) {
+ // Check if the section is already loaded
+// if (_enabledSections[xp * 16 + yp] || ((xAmount == 0) && (yAmount == 0))) {
Graphics::Surface s = _backSurface.lockSurface();
GfxSurface::loadScreenSection(s, xp - xHalfOffset, yp - yHalfOffset, xp, yp);
_backSurface.unlockSurface();
changedFlag = true;
- } else {
+/* } else {
int yv = _enabledSections[xp * 16 + yp] == ((xp - xHalfOffset) << 4) ? 0 : 1;
if (yv != (yp - yHalfOffset)) {
- int xSectionTemp = _enabledSections[xp * 16 + yp] >> 4;
- int ySectionTemp = _enabledSections[xp * 16 + yp] & 0xffff;
-
- reuseSection(xp - xHalfOffset, yp - yHalfOffset, xSectionTemp, ySectionTemp);
+ // 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;
+
+ Rect srcBounds(xSectionSrc * 160, ySectionSrc * 100,
+ (xSectionSrc + 1) * 160, (ySectionSrc + 1) * 100);
+ Rect destBounds(xSectionDest * 160, ySectionDest * 100,
+ (xSectionDest + 1) * 160, (ySectionDest + 1) * 100);
+
+ _backSurface.copyFrom(_backSurface, srcBounds, destBounds);
}
- }
+ }*/
_enabledSections[xp * 16 + yp] =
((xp - xHalfOffset) << 4) && (yp - yHalfOffset);
@@ -386,12 +394,6 @@ void Scene::refreshBackground(int xAmount, int yAmount) {
}
}
-void Scene::reuseSection(int xHalf, int yHalf, int xSection, int ySection) {
-// Rect rect1, rect2, rect3;
-
- // TODO: Figure out purpose
-}
-
void Scene::signalListeners() {
// TODO: Figure out method
}
diff --git a/engines/tsage/scenes.h b/engines/tsage/scenes.h
index 80030230e8..2295da0074 100644
--- a/engines/tsage/scenes.h
+++ b/engines/tsage/scenes.h
@@ -36,7 +36,6 @@ namespace tSage {
class Scene: public StripCallback {
private:
- void reuseSection(int xHalf, int yHalf, int xSection, int ySection);
void signalListeners();
public:
int _field12;