aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage
diff options
context:
space:
mode:
authorPaul Gilbert2013-09-15 15:54:21 -0400
committerPaul Gilbert2013-09-15 15:54:21 -0400
commit546a8882dff8bde4fd90a8db8659e137cbc0e7e3 (patch)
treee161600717ca8d7fa5029b64c66fbac21af78d07 /engines/tsage
parent2196916b62777e9c2b3ad87d1e542ec11a8c3d4b (diff)
downloadscummvm-rg350-546a8882dff8bde4fd90a8db8659e137cbc0e7e3.tar.gz
scummvm-rg350-546a8882dff8bde4fd90a8db8659e137cbc0e7e3.tar.bz2
scummvm-rg350-546a8882dff8bde4fd90a8db8659e137cbc0e7e3.zip
TSAGE: Modifications to show R2R balloon cutscene map correctly initially
Diffstat (limited to 'engines/tsage')
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes2.cpp65
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes2.h10
2 files changed, 46 insertions, 29 deletions
diff --git a/engines/tsage/ringworld2/ringworld2_scenes2.cpp b/engines/tsage/ringworld2/ringworld2_scenes2.cpp
index b6aacd7b0b..5570e3e975 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes2.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes2.cpp
@@ -4712,7 +4712,7 @@ Scene2900::Map::Map() {
_fieldA = 0;
_resNum = 0;
_xV = _yV = 0;
- _rect = Rect(40, 0, 280, 150);
+ _bounds = Rect(40, 0, 280, 150);
}
void Scene2900::Map::load(int resNum) {
@@ -4726,58 +4726,67 @@ void Scene2900::Map::load(int resNum) {
DEALLOCATE(data);
}
-Common::Point Scene2900::Map::setPosition(const Common::Point &pos, int v3) {
- Rect rect2;
- Rect blockRect(0, 0, 160, 100);
- int xHalfCount = _mapWidth / 160;
- int yHalfCount = _mapHeight / 100;
+Common::Point Scene2900::Map::setPosition(const Common::Point &pos, bool initialFlag) {
Common::Point p = pos;
+ Rect updateRect;
if (p.x >= 0) {
- int xRight = p.x + _rect.width();
+ int xRight = p.x + _bounds.width();
if (xRight > _mapWidth) {
- p.x = _mapWidth - _rect.width();
+ p.x = _mapWidth - _bounds.width();
}
} else {
p.x = 0;
}
if (p.y >= 0) {
- int yBottom = p.y + _rect.height();
+ int yBottom = p.y + _bounds.height();
if (yBottom > _mapHeight) {
- p.y = _mapHeight - _rect.height();
+ p.y = _mapHeight - _bounds.height();
}
} else {
p.y = 0;
}
- if ((p.x != 0 || p.y != 0) && !v3) {
- rect2 = _rect;
- moveArea(rect2, _xV - p.x, _yV - p.y);
+ if ((p.x != 0 || p.y != 0) && !initialFlag) {
+ moveArea(updateRect, _xV - p.x, _yV - p.y);
+ redraw(&updateRect);
+ } else {
+ redraw();
}
_xV = p.x;
_yV = p.y;
- Rect screenRect = _rect;
- screenRect.translate(_xV - _rect.left, _yV - _rect.top);
+ return Common::Point(_xV, _yV);
+}
+
+void Scene2900::Map::redraw(Rect *updateRect) {
+ int xHalfCount = _mapWidth / 160;
+ int yHalfCount = _mapHeight / 100;
int rlbNum = 0;
+ Rect blockRect(0, 0, 160, 100);
+ Rect screenRect = _bounds;
+ screenRect.translate(_xV - _bounds.left, _yV - _bounds.top);
+
+ Rect modifyRect;
+ if (updateRect)
+ modifyRect = *updateRect;
+
for (int xCtr = 0; xCtr < xHalfCount; ++xCtr) {
for (int yCtr = 0; yCtr < yHalfCount; ++yCtr, ++rlbNum) {
blockRect.moveTo(160 * xCtr, 100 * yCtr);
if (blockRect.intersects(screenRect)) {
// The block of the map is at least partially on-screen, so needs drawing
- blockRect.translate(_rect.left - _xV, _rect.top - _yV);
+ blockRect.translate(_bounds.left - _xV, _bounds.top - _yV);
byte *data = g_resourceManager->getResource(RES_BITMAP, _resNum, rlbNum);
- drawBlock(data, blockRect.left, blockRect.top, _rect, rect2);
+ drawBlock(data, blockRect.left, blockRect.top, _bounds, modifyRect);
DEALLOCATE(data);
}
}
}
-
- return Common::Point(_xV, _yV);
}
void Scene2900::Map::synchronize(Serializer &s) {
@@ -4785,7 +4794,7 @@ void Scene2900::Map::synchronize(Serializer &s) {
s.syncAsUint16LE(_mapHeight);
s.syncAsSint16LE(_xV);
s.syncAsSint16LE(_yV);
- _rect.synchronize(s);
+ _bounds.synchronize(s);
}
int Scene2900::Map::adjustRect(Common::Rect &r1, const Common::Rect &r2) {
@@ -4820,15 +4829,15 @@ int Scene2900::Map::adjustRect(Common::Rect &r1, const Common::Rect &r2) {
return -1;
}
-void Scene2900::Map::drawBlock(const byte *data, int xp, int yp, const Rect &r1, const Rect &r2) {
- Scene2900 *scene = (Scene2900 *)R2_GLOBALS._sceneManager._scene;
+void Scene2900::Map::drawBlock(const byte *data, int xp, int yp,
+ const Rect &bounds, const Rect &updateRect) {
Rect blockRect(xp, yp, xp + 160, yp + 100);
const byte *src = data;
- if (blockRect.intersects(r1)) {
- blockRect.clip(r1);
+ if (blockRect.intersects(bounds)) {
+ blockRect.clip(bounds);
- if (adjustRect(blockRect, r2) != 0) {
+ if (adjustRect(blockRect, updateRect) != 0) {
int width = blockRect.width();
int height = blockRect.height();
src += (blockRect.top - yp) * 160 + blockRect.left - xp;
@@ -5165,5 +5174,11 @@ void Scene2900::dispatch() {
Scene::dispatch();
}
+void Scene2900::refreshBackground(int xAmount, int yAmount) {
+ SceneExt::refreshBackground(xAmount, yAmount);
+
+ _map.redraw();
+}
+
} // End of namespace Ringworld2
} // End of namespace TsAGE
diff --git a/engines/tsage/ringworld2/ringworld2_scenes2.h b/engines/tsage/ringworld2/ringworld2_scenes2.h
index b09e4495eb..a4d309960c 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes2.h
+++ b/engines/tsage/ringworld2/ringworld2_scenes2.h
@@ -701,6 +701,8 @@ class Scene2900 : public SceneExt {
private:
void moveArea(Rect &r, int xAmt, int yAmt);
void moveLine(int xpSrc, int ypSrc, int xpDest, int ypDest, int width);
+ int adjustRect(Common::Rect &r1, const Common::Rect &r2);
+ void drawBlock(const byte *data, int xp, int yp, const Rect &r1, const Rect &r2);
public:
int _mapWidth, _mapHeight;
int _field4;
@@ -709,14 +711,13 @@ class Scene2900 : public SceneExt {
int _fieldA;
int _resNum;
int _xV, _yV;
- Rect _rect;
+ Rect _bounds;
Map();
void load(int resNum);
- Common::Point setPosition(const Common::Point &pos, int v3 = 0);
+ Common::Point setPosition(const Common::Point &pos, bool initialFlag = false);
void synchronize(Serializer &s);
- int adjustRect(Common::Rect &r1, const Common::Rect &r2);
- void drawBlock(const byte *data, int xp, int yp, const Rect &r1, const Rect &r2);
+ void redraw(Rect *updateRect = NULL);
};
public:
SceneObject _leftEdge;
@@ -752,6 +753,7 @@ public:
virtual void remove();
virtual void signal();
virtual void dispatch();
+ virtual void refreshBackground(int xAmount, int yAmount);
};
} // End of namespace Ringworld2