From 9bfa51ef300cf95872ca2325b7bd0d64f85372e6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 22 Oct 2015 02:14:41 +0300 Subject: MADS: Phantom: Expand the existing camera adjustment logic for V2 games This fixes all of the scenes that expand over the screen (e.g. 101, 104, 109 in Phantom, as well as the several scenes in the Dragonsphere intro). Also added a new debugger command, "set_camera", which sets the scene camera to specific coordinates --- engines/mads/scene_data.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/mads/scene_data.cpp') diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index e48bcd8c6f..d4610c53d4 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -422,6 +422,18 @@ void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName, assert(screenWidth == _width); assert(screenHeight <= _height); + // Resize the background surface to hold all of the tiles + uint16 newWidth = bgSurface.w; + uint16 newHeight = bgSurface.h; + + if (tileWidth < screenWidth && bgSurface.w != tileCount * tileWidth) + newWidth = tileCount * tileWidth; + if (tileHeight < screenHeight && bgSurface.h != tileCount * tileHeight) + newHeight = tileCount * tileHeight; + + if (bgSurface.w != newWidth || bgSurface.h != newHeight) + bgSurface.setSize(newWidth, newHeight); + // -------------------------------------------------------------------------------- // Get tile data -- cgit v1.2.3 From 178e45f4d9847970f9ee7dcf78902fa160226e7f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 6 Nov 2015 22:26:32 +0200 Subject: MADS: Phantom: Initialize missing scene info so that Raoul is visible --- engines/mads/scene_data.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/mads/scene_data.cpp') diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index d4610c53d4..f6f081a252 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -176,6 +176,12 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, _width = 320; _height = 156; + // TODO: Initialize correctly! + _yBandsEnd = 155; + _yBandsStart = 0; + _maxScale = 100; + _minScale = 100; + infoStream->skip(140); } -- cgit v1.2.3 From f6e38119ec8a8d9d7f1c28185fe68ff16692b07d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 7 Nov 2015 18:17:45 +0200 Subject: MADS: Phantom: More work on V2 scene data --- engines/mads/scene_data.cpp | 79 +++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 31 deletions(-) (limited to 'engines/mads/scene_data.cpp') diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index f6f081a252..2211430267 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -108,7 +108,7 @@ SceneInfo::SceneInfo(MADSEngine *vm) : _vm(vm) { _minScale = 0; _field4A = 0; _usageIndex = 0; - for (int i = 0; i < 15; ++i) + for (int i = 0; i < DEPTH_BANDS_SIZE; ++i) _depthList[i] = 0; } @@ -145,6 +145,15 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, // Read in basic data Common::SeekableReadStream *infoStream = infoPack.getItemStream(0); + + /* + byte *data = new byte[infoStream->size()]; + infoStream->read(data, infoStream->size()); + Common::hexdump(data, infoStream->size()); + infoStream->seek(0); + delete[] data; + */ + if (_vm->getGameID() == GType_RexNebular) { _sceneId = infoStream->readUint16LE(); } else { @@ -161,28 +170,28 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, _height = infoStream->readUint16LE(); infoStream->skip(24); - - nodeCount = infoStream->readUint16LE(); - _yBandsEnd = infoStream->readUint16LE(); - _yBandsStart = infoStream->readUint16LE(); - _maxScale = infoStream->readUint16LE(); - _minScale = infoStream->readUint16LE(); - for (int i = 0; i < DEPTH_BANDS_SIZE; ++i) - _depthList[i] = infoStream->readUint16LE(); - _field4A = infoStream->readUint16LE(); } else { _artFileNum = sceneId; _depthStyle = 0; _width = 320; _height = 156; - // TODO: Initialize correctly! - _yBandsEnd = 155; - _yBandsStart = 0; - _maxScale = 100; - _minScale = 100; + infoStream->skip(98); + } - infoStream->skip(140); + nodeCount = infoStream->readUint16LE(); + _yBandsEnd = infoStream->readUint16LE(); + _yBandsStart = infoStream->readUint16LE(); + _maxScale = infoStream->readUint16LE(); + _minScale = infoStream->readUint16LE(); + for (int i = 0; i < DEPTH_BANDS_SIZE; ++i) + _depthList[i] = infoStream->readUint16LE(); + _field4A = infoStream->readUint16LE(); + + // HACK for V2 games + if (_vm->getGameID() != GType_RexNebular) { + _minScale = _maxScale = 100; + memset(_depthList, 0, DEPTH_BANDS_SIZE * sizeof(int)); } // Load the scene's walk nodes @@ -190,27 +199,29 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, WalkNode node; node.load(infoStream); - if (i < nodeCount) + if (i < nodeCount) { _nodes.push_back(node); + //debug("Node %d: %d,%d", i, node._walkPos.x, node._walkPos.y); + } } - int spriteSetsCount = infoStream->readUint16LE(); - int spriteInfoCount = infoStream->readUint16LE(); - - // Load in sprite sets Common::StringArray setNames; - for (int i = 0; i < 10; ++i) { - char name[64]; - infoStream->read(name, 64); - - if (i < spriteSetsCount) - setNames.push_back(Common::String(name)); - } - - // Load in sprite draw information Common::Array spriteInfo; - // TODO: The following isn't quite right for V2 games + if (_vm->getGameID() == GType_RexNebular) { + int spriteSetsCount = infoStream->readUint16LE(); + int spriteInfoCount = infoStream->readUint16LE(); + + // Load in sprite sets + for (int i = 0; i < 10; ++i) { + char name[64]; + infoStream->read(name, 64); + + if (i < spriteSetsCount) + setNames.push_back(Common::String(name)); + } + + // Load in sprite draw information for (int i = 0; i < 50; ++i) { SpriteInfo info; info.load(infoStream); @@ -218,6 +229,12 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, if (i < spriteInfoCount) spriteInfo.push_back(info); } + } else { + uint16 shadowColors = infoStream->readUint16LE(); + uint16 shadowR = infoStream->readUint16LE(); + uint16 shadowG = infoStream->readUint16LE(); + uint16 shadowB = infoStream->readUint16LE(); + debug("Shadow colors: %d (%d, %d, %d)", shadowColors, shadowR, shadowG, shadowB); } delete infoStream; -- cgit v1.2.3 From 4f330db26afadb8ec71908631d8b6fb79fcdca13 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 24 Nov 2015 19:10:11 +0100 Subject: MADS: Fix memory leak in loadMadsV2Background --- engines/mads/scene_data.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/mads/scene_data.cpp') diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index 2211430267..7b0e64c1fe 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -509,6 +509,8 @@ void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName, } tileSet.clear(); tileDataFile.close(); + + delete[] tileMap; } /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From b4e3d4abc16d9996651874c8952b1ce846dcb6a1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 10 Mar 2016 21:51:23 -0500 Subject: MADS: Changed engine to use Graphics::ManagedSurface --- engines/mads/scene_data.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'engines/mads/scene_data.cpp') diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index 7b0e64c1fe..5323178ec7 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -242,13 +242,13 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, int height = _height; if (!bgSurface.getPixels() || (bgSurface.w != width) || (bgSurface.h != height)) { - bgSurface.setSize(width, height); + bgSurface.create(width, height); } if (_depthStyle == 2) width >>= 2; if (!depthSurface.getPixels()) { - depthSurface.setSize(width, height); + depthSurface.create(width, height); } loadCodes(depthSurface, variant); @@ -288,7 +288,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, assert(asset && _depthStyle != 2); MSprite *spr = asset->getFrame(si._frameNumber); - bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface, + bgSurface.copyFrom(*spr, si._position, si._depth, &depthSurface, si._scale, false, spr->getTransparencyIndex()); } @@ -455,7 +455,7 @@ void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName, newHeight = tileCount * tileHeight; if (bgSurface.w != newWidth || bgSurface.h != newHeight) - bgSurface.setSize(newWidth, newHeight); + bgSurface.create(newWidth, newHeight); // -------------------------------------------------------------------------------- @@ -477,7 +477,7 @@ void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName, //debugCN(kDebugGraphics, "Tile: %i, compressed size: %i\n", i, compressedTileDataSize); - newTile->empty(); + newTile->clear(); byte *compressedTileData = new byte[compressedTileDataSize]; @@ -503,7 +503,8 @@ void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName, TileSetIterator tile = tileSet.begin(); for (int i = 0; i < tileIndex; i++) ++tile; - ((*tile).get())->copyTo(&bgSurface, Common::Point(x * tileWidth, y * tileHeight)); + + bgSurface.blitFrom(*(*tile).get(), Common::Point(x * tileWidth, y * tileHeight)); ((*tile).get())->free(); } } -- cgit v1.2.3 From 78e52365bd1d8cdd56ddce6ae3d52ae04f9abd4c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 26 May 2016 21:37:52 -0400 Subject: MADS: Refactor MSurface and Screen to not use virtual inheritance --- engines/mads/scene_data.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/mads/scene_data.cpp') diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index 5323178ec7..21fd4f9026 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -128,7 +128,7 @@ SceneInfo *SceneInfo::init(MADSEngine *vm) { } void SceneInfo::load(int sceneId, int variant, const Common::String &resName, - int flags, DepthSurface &depthSurface, MSurface &bgSurface) { + int flags, DepthSurface &depthSurface, BaseSurface &bgSurface) { bool sceneFlag = sceneId >= 0; // Figure out the resource to use @@ -299,7 +299,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, } } -void SceneInfo::loadPalette(int sceneId, int artFileNum, const Common::String &resName, int flags, MSurface &bgSurface) { +void SceneInfo::loadPalette(int sceneId, int artFileNum, const Common::String &resName, int flags, BaseSurface &bgSurface) { bool sceneFlag = sceneId >= 0; Common::String resourceName; bool isV2 = (_vm->getGameID() != GType_RexNebular); @@ -351,7 +351,7 @@ void SceneInfo::loadPalette(int sceneId, int artFileNum, const Common::String &r } } -void SceneInfo::loadMadsV1Background(int sceneId, const Common::String &resName, int flags, MSurface &bgSurface) { +void SceneInfo::loadMadsV1Background(int sceneId, const Common::String &resName, int flags, BaseSurface &bgSurface) { bool sceneFlag = sceneId >= 0; Common::String resourceName; Common::SeekableReadStream *stream; @@ -397,7 +397,7 @@ void SceneInfo::loadMadsV1Background(int sceneId, const Common::String &resName, artFile.close(); } -void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName, int flags, MSurface &bgSurface) { +void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName, int flags, BaseSurface &bgSurface) { Common::String tileMapResourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".MM"); File tileMapFile(tileMapResourceName); MadsPack tileMapPack(&tileMapFile); -- cgit v1.2.3