diff options
Diffstat (limited to 'engines/mads/scene_data.cpp')
-rw-r--r-- | engines/mads/scene_data.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index e874468345..b0a5aa35c6 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -217,7 +217,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, int width = _width; int height = _height; - if (!bgSurface.getPixels()) { + if (!bgSurface.getPixels() || (bgSurface.w != width) || (bgSurface.h != height)) { bgSurface.setSize(width, height); } @@ -232,11 +232,11 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, infoFile.close(); if (_vm->getGameID() == GType_RexNebular) { - loadMadsV1Background(sceneId, resName, flags, bgSurface); - loadPalette(sceneId, _artFileNum, resName, flags, bgSurface); + loadMadsV1Background(_artFileNum, resName, flags, bgSurface); + loadPalette(_sceneId, _artFileNum, resName, flags, bgSurface); } else { - loadMadsV2Background(sceneId, resName, flags, bgSurface); - loadPalette(sceneId, sceneId, resName, flags, bgSurface); + loadMadsV2Background(_sceneId, resName, flags, bgSurface); + loadPalette(_sceneId, _sceneId, resName, flags, bgSurface); } Common::Array<SpriteAsset *> spriteSets; @@ -299,6 +299,7 @@ void SceneInfo::loadPalette(int sceneId, int artFileNum, const Common::String &r delete stream; // Copy out the palette animation data + _paletteCycles.clear(); for (uint i = 0; i < artHeader._paletteCycles.size(); ++i) _paletteCycles.push_back(artHeader._paletteCycles[i]); @@ -333,7 +334,7 @@ void SceneInfo::loadMadsV1Background(int sceneId, const Common::String &resName, // Get the ART resource if (sceneFlag) { - resourceName = Resources::formatName(RESPREFIX_RM, _artFileNum, ".ART"); + resourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".ART"); } else { resourceName = "*" + Resources::formatResource(resName, resName); } @@ -342,13 +343,33 @@ void SceneInfo::loadMadsV1Background(int sceneId, const Common::String &resName, File artFile(resourceName); MadsPack artResource(&artFile); - // Read in the background surface data - assert(_width == bgSurface.w && _height == bgSurface.h); + // Read inhh the background surface data + assert(_width && _height == bgSurface.h); stream = artResource.getItemStream(1); stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h); + delete stream; + + if (flags & SCENEFLAG_TRANSLATE) { + // Load in the palette and translate it + Common::SeekableReadStream *palStream = artResource.getItemStream(0); + Common::Array<RGB6> palette; + + _width = palStream->readUint16LE(); + _height = palStream->readUint16LE(); + + int numColors = palStream->readUint16LE(); + assert(numColors <= 252); + palette.resize(numColors); + for (int i = 0; i < numColors; ++i) + palette[i].load(palStream); + delete palStream; + + // Translate the surface + _vm->_palette->_paletteUsage.process(palette, 0); + bgSurface.translate(palette); + } // Close the ART file - delete stream; artFile.close(); } |