diff options
Diffstat (limited to 'engines/mads/scene_data.cpp')
-rw-r--r-- | engines/mads/scene_data.cpp | 108 |
1 files changed, 73 insertions, 35 deletions
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index e48bcd8c6f..21fd4f9026 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; } @@ -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 @@ -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,22 +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; - infoStream->skip(140); + infoStream->skip(98); + } + + 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 @@ -184,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> 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); @@ -212,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; @@ -219,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); @@ -265,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()); } @@ -276,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); @@ -328,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; @@ -374,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); @@ -422,6 +445,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.create(newWidth, newHeight); + // -------------------------------------------------------------------------------- // Get tile data @@ -442,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]; @@ -468,12 +503,15 @@ 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(); } } tileSet.clear(); tileDataFile.close(); + + delete[] tileMap; } /*------------------------------------------------------------------------*/ |