diff options
author | Paul Gilbert | 2013-09-14 16:54:41 -0400 |
---|---|---|
committer | Paul Gilbert | 2013-09-14 16:54:41 -0400 |
commit | dfe38b69760e3dc87ceef9a852a97ef4d76ccb9e (patch) | |
tree | 010a5be2efca103dae4302b953a902a937bb8704 | |
parent | 1f7780bef53b11ebd1d59e8a5e4ea53d59cad948 (diff) | |
download | scummvm-rg350-dfe38b69760e3dc87ceef9a852a97ef4d76ccb9e.tar.gz scummvm-rg350-dfe38b69760e3dc87ceef9a852a97ef4d76ccb9e.tar.bz2 scummvm-rg350-dfe38b69760e3dc87ceef9a852a97ef4d76ccb9e.zip |
TSAGE: Initial bugfixes and renaming for R2R balloon scene
-rw-r--r-- | engines/tsage/core.cpp | 22 | ||||
-rw-r--r-- | engines/tsage/core.h | 4 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.cpp | 2 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes2.cpp | 71 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes2.h | 14 |
5 files changed, 68 insertions, 45 deletions
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 055005808c..065d4eba65 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -2757,13 +2757,29 @@ void BackgroundSceneObject::draw() { g_globals->_sceneManager._scene->_backSurface.copyFrom(frame, destRect, priorityRegion); } -void BackgroundSceneObject::setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY, int priority, int32 arg10) { - warning("TODO: Implement properly BackgroundSceneObject::setup2()"); +SceneObject *BackgroundSceneObject::clone() const { + BackgroundSceneObject *obj = new BackgroundSceneObject(*this); + return obj; +} + +void BackgroundSceneObject::setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY, int priority, int effect) { + // Check if the given object is already in the background object list + if (R2_GLOBALS._sceneManager._scene->_bgSceneObjects.contains(this)) { + _flags |= OBJFLAG_REMOVE; + + // Clone the item + SceneObject *obj = clone(); + obj->_flags |= OBJFLAG_CLONED; + R2_GLOBALS._sceneManager._scene->_bgSceneObjects.push_back(obj); + + _flags |= ~OBJFLAG_REMOVE; + } + postInit(); setVisage(visage); setStrip(stripFrameNum); setFrame(frameNum); - setPosition(Common::Point(posX, posY), 0); + setPosition(Common::Point(posX, posY)); fixPriority(priority); } diff --git a/engines/tsage/core.h b/engines/tsage/core.h index f7a5a43b16..c4582ff721 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -575,7 +575,6 @@ public: int getRegionIndex(); int checkRegion(const Common::Point &pt); void animate(AnimateMode animMode, ...); - SceneObject *clone() const; void checkAngle(const SceneObject *obj); void checkAngle(const Common::Point &pt); void hide(); @@ -602,6 +601,7 @@ public: virtual void changeAngle(int angle); // New methods introduced by Ringworld 2 virtual void copy(SceneObject *src); + virtual SceneObject *clone() const; void setup(int visage, int stripFrameNum, int frameNum, int posX, int posY, int priority); void setup(int visage, int stripFrameNum, int frameNum); @@ -612,6 +612,8 @@ public: virtual Common::String getClassName() { return "BackgroundSceneObject"; } virtual void postInit(SceneObjectList *OwnerList = NULL); virtual void draw(); + virtual SceneObject *clone() const; + void setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY, int priority, int32 arg10); static void copySceneToBackground(); }; diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index b7faf7bd4a..ae83c08966 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -225,6 +225,8 @@ Scene *Ringworld2Game::createScene(int sceneNumber) { return new Scene2800(); case 2900: // Balloon Cutscene + return new Scene2900(); + /* Scene group #3 */ // ARM Base Hanager case 3100: diff --git a/engines/tsage/ringworld2/ringworld2_scenes2.cpp b/engines/tsage/ringworld2/ringworld2_scenes2.cpp index ea75fb8f2a..08d41ec4d2 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes2.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes2.cpp @@ -4696,8 +4696,8 @@ void Scene2900::Action1::signal() { /*------------------------------------------------------------------------*/ -Scene2900::Obj1::Obj1() { - _width = _height = 0; +Scene2900::Map::Map() { + _mapWidth = _mapHeight = 0; _field4 = 0; _field6 = 0; _field8 = 0; @@ -4707,28 +4707,28 @@ Scene2900::Obj1::Obj1() { _rect = Rect(40, 0, 280, 150); } -void Scene2900::Obj1::load(int resNum) { +void Scene2900::Map::load(int resNum) { byte *data = g_resourceManager->getResource(RES_BITMAP, resNum, 9999); _resNum = resNum; _xV = _yV = 0; - _width = READ_LE_UINT16(data); - _height = READ_LE_UINT16(data + 2); + _mapWidth = READ_LE_UINT16(data); + _mapHeight = READ_LE_UINT16(data + 2); DEALLOCATE(data); } -Common::Point Scene2900::Obj1::setPosition(const Common::Point &pos, int v3) { +Common::Point Scene2900::Map::setPosition(const Common::Point &pos, int v3) { Rect rect2; Rect blockRect(0, 0, 160, 100); - int xHalfCount = _width / 160; - int yHalfCount = _height / 100; + int xHalfCount = _mapWidth / 160; + int yHalfCount = _mapHeight / 100; Common::Point p = pos; if (p.x >= 0) { int xRight = p.x + _rect.width(); - if (xRight > _width) { - p.x = _width - _rect.width(); + if (xRight > _mapWidth) { + p.x = _mapWidth - _rect.width(); } } else { p.x = 0; @@ -4736,8 +4736,8 @@ Common::Point Scene2900::Obj1::setPosition(const Common::Point &pos, int v3) { if (p.y >= 0) { int yBottom = p.y + _rect.height(); - if (yBottom > _height) { - p.y = _height - _rect.height(); + if (yBottom > _mapHeight) { + p.y = _mapHeight - _rect.height(); } } else { p.y = 0; @@ -4750,18 +4750,19 @@ Common::Point Scene2900::Obj1::setPosition(const Common::Point &pos, int v3) { _xV = p.x; _yV = p.y; - Rect rect3 = _rect; - rect3.translate(_xV - _rect.left, _yV - _rect.top); + Rect screenRect = _rect; + screenRect.translate(_xV - _rect.left, _yV - _rect.top); int rlbNum = 0; for (int xCtr = 0; xCtr < xHalfCount; ++xCtr) { - for (int yCtr = 0; yCtr < yHalfCount; ++yCtr) { + for (int yCtr = 0; yCtr < yHalfCount; ++yCtr, ++rlbNum) { blockRect.moveTo(160 * xCtr, 100 * yCtr); - if (blockRect.intersects(rect3)) { + 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); byte *data = g_resourceManager->getResource(RES_BITMAP, _resNum, rlbNum); - draw(data, blockRect.left, blockRect.top, _rect, rect2); + drawBlock(data, blockRect.left, blockRect.top, _rect, rect2); DEALLOCATE(data); } @@ -4771,15 +4772,15 @@ Common::Point Scene2900::Obj1::setPosition(const Common::Point &pos, int v3) { return Common::Point(_xV, _yV); } -void Scene2900::Obj1::synchronize(Serializer &s) { - s.syncAsUint16LE(_width); - s.syncAsUint16LE(_height); +void Scene2900::Map::synchronize(Serializer &s) { + s.syncAsUint16LE(_mapWidth); + s.syncAsUint16LE(_mapHeight); s.syncAsSint16LE(_xV); s.syncAsSint16LE(_yV); _rect.synchronize(s); } -int Scene2900::Obj1::adjustRect(Common::Rect &r1, const Common::Rect &r2) { +int Scene2900::Map::adjustRect(Common::Rect &r1, const Common::Rect &r2) { if (r2.contains(r1)) return 0; if (!r2.intersects(r1)) @@ -4811,7 +4812,7 @@ int Scene2900::Obj1::adjustRect(Common::Rect &r1, const Common::Rect &r2) { return -1; } -void Scene2900::Obj1::draw(const byte *data, int xp, int yp, const Rect &r1, const Rect &r2) { +void Scene2900::Map::drawBlock(const byte *data, int xp, int yp, const Rect &r1, const Rect &r2) { Rect blockRect(xp, yp, xp + 160, yp + 100); const byte *src = data; @@ -4821,6 +4822,7 @@ void Scene2900::Obj1::draw(const byte *data, int xp, int yp, const Rect &r1, con if (adjustRect(blockRect, r2) != 0) { int width = blockRect.width(); int height = blockRect.height(); + src += (blockRect.top - yp) * 160 + blockRect.left - xp; GfxSurface &surface = R2_GLOBALS.gfxManager().getSurface(); Graphics::Surface s = surface.lockSurface(); @@ -4836,7 +4838,7 @@ void Scene2900::Obj1::draw(const byte *data, int xp, int yp, const Rect &r1, con } } -void Scene2900::Obj1::moveArea(Rect &r, int xAmt, int yAmt) { +void Scene2900::Map::moveArea(Rect &r, int xAmt, int yAmt) { Rect tempRect = r; tempRect.translate(xAmt, yAmt); int xpSrc, xpDest, width; @@ -4875,7 +4877,7 @@ void Scene2900::Obj1::moveArea(Rect &r, int xAmt, int yAmt) { } } -void Scene2900::Obj1::moveLine(int xpSrc, int ypSrc, int xpDest, int ypDest, int width) { +void Scene2900::Map::moveLine(int xpSrc, int ypSrc, int xpDest, int ypDest, int width) { byte buffer[SCREEN_WIDTH]; assert(width <= SCREEN_WIDTH); @@ -4924,22 +4926,23 @@ void Scene2900::synchronize(Serializer &s) { s.syncAsSint16LE(_field427); s.syncAsSint16LE(_field8F8); - _obj1.synchronize(s); + _map.synchronize(s); } void Scene2900::postInit(SceneObjectList *OwnerList) { R2_GLOBALS._uiElements._active = false; // TODO: Determine correct colours - R2_GLOBALS._gfxColors.foreground = 220; + R2_GLOBALS._gfxColors.foreground = 228; R2_GLOBALS._fontColors.background = 12; R2_GLOBALS._fontColors.foreground = 22; - _obj1.load(2950); + + _map.load(2950); loadScene(2900); SceneExt::postInit(); - _object1.setup2(2900, 6, 1, 22, 0, 25, 0); - _object2.setup2(2900, 6, 1, 280, 0, 25, 0); + _leftEdge.setup2(2900, 6, 1, 22, 0, 25, 0); + _rightEdge.setup2(2900, 6, 1, 280, 0, 25, 0); _object3.setup2(2900, 1, 3, 228, 199, 25, 0); _object4.postInit(); @@ -4980,8 +4983,7 @@ void Scene2900::postInit(SceneObjectList *OwnerList) { if (R2_GLOBALS._sceneManager._previousScene == 2350 && R2_GLOBALS._balloonPosition.x == 0 && R2_GLOBALS._balloonPosition.y == 0) { R2_GLOBALS._v56A99 = 5; - _obj1.setPosition(Common::Point(R2_GLOBALS._balloonPosition.x - 120, - R2_GLOBALS._balloonPosition.y - 100)); + _map.setPosition(Common::Point(_offsetPos.x - 120, _offsetPos.y - 100)); _sceneMode = 10; R2_GLOBALS._player.changeZoom(100); @@ -5009,7 +5011,7 @@ void Scene2900::postInit(SceneObjectList *OwnerList) { _pos.y = _offsetPos.y; _field425 = _field426 = 100 - (R2_GLOBALS._v56A99 / 48) * 25; - _obj1.setPosition(Common::Point(_offsetPos.x - 120, _offsetPos.y - 100)); + _map.setPosition(Common::Point(_offsetPos.x - 120, _offsetPos.y - 100)); _sceneMode = 11; R2_GLOBALS._player.changeZoom(_field425); @@ -5100,8 +5102,9 @@ void Scene2900::dispatch() { } // TODO: Verify param 3 - R2_GLOBALS._balloonPosition = _obj1.setPosition(Common::Point(_offsetPos.x - 120, - _offsetPos.y - 100), _field8F8 + (_field8F8 ? 1 : 0)); + R2_GLOBALS._balloonPosition = _map.setPosition( + Common::Point(_offsetPos.x - 120, _offsetPos.y - 100), + _field8F8 + (_field8F8 ? 1 : 0)); _field8F8 = 1; if (_offsetPos.x <= 120) diff --git a/engines/tsage/ringworld2/ringworld2_scenes2.h b/engines/tsage/ringworld2/ringworld2_scenes2.h index b127c5685c..4ea0a487f0 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes2.h +++ b/engines/tsage/ringworld2/ringworld2_scenes2.h @@ -697,12 +697,12 @@ class Scene2900 : public SceneExt { }; /* Custom classes */ - class Obj1 { + class Map { private: void moveArea(Rect &r, int xAmt, int yAmt); void moveLine(int xpSrc, int ypSrc, int xpDest, int ypDest, int width); public: - int _width, _height; + int _mapWidth, _mapHeight; int _field4; int _field6; int _field8; @@ -711,16 +711,16 @@ class Scene2900 : public SceneExt { int _xV, _yV; Rect _rect; - Obj1(); + Map(); void load(int resNum); Common::Point setPosition(const Common::Point &pos, int v3 = 0); void synchronize(Serializer &s); int adjustRect(Common::Rect &r1, const Common::Rect &r2); - void draw(const byte *data, int xp, int yp, const Rect &r1, const Rect &r2); + void drawBlock(const byte *data, int xp, int yp, const Rect &r1, const Rect &r2); }; public: - BackgroundSceneObject _object1; - BackgroundSceneObject _object2; + BackgroundSceneObject _leftEdge; + BackgroundSceneObject _rightEdge; BackgroundSceneObject _object3; SceneObject _object4; SceneObject _object5; @@ -731,7 +731,7 @@ public: Item4 _item4; Item5 _item5; Action1 _action1; - Obj1 _obj1; + Map _map; int _field412; int _field414; |