From 0df4d0aed1678f81cb75bb56cb2a1fc19603312c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 12 Mar 2014 23:45:57 -0400 Subject: MADS: Fixed loading of scene depth surface for Rex Nebular --- engines/mads/scene_data.cpp | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) (limited to 'engines/mads/scene_data.cpp') diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index d2071e3ba5..0cb273a0f4 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -383,7 +383,7 @@ SceneInfo *SceneInfo::init(MADSEngine *vm) { if (vm->getGameID() == GType_RexNebular) { return new Nebular::SceneInfoNebular(vm); } else { - return new SceneInfo(vm); + error("Unknown game"); } } @@ -453,9 +453,7 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName, if (i < spriteInfoCount) spriteInfo.push_back(info); } - delete infoStream; - infoFile.close(); int width = _width; int height = _height; @@ -471,7 +469,11 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName, } // Load the depth surface with the scene codes - loadCodes(depthSurface); + Common::SeekableReadStream *depthStream = infoPack.getItemStream(1); + loadCodes(depthSurface, depthStream); + delete depthStream; + + infoFile.close(); // Get the ART resource if (sceneFlag) { @@ -554,35 +556,6 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName, } } -void SceneInfo::loadCodes(MSurface &depthSurface) { - File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT")); - MadsPack codesPack(&f); - Common::SeekableReadStream *stream = codesPack.getItemStream(0); - - uint16 width = _width; - uint16 height = _height; - byte *walkMap = new byte[stream->size()]; - - depthSurface.setSize(width, height); - stream->read(walkMap, f.size()); - delete stream; - f.close(); - - byte *ptr = (byte *)depthSurface.getPixels(); - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - int ofs = x + (y * width); - if ((walkMap[ofs / 8] << (ofs % 8)) & 0x80) - *ptr++ = 1; // walkable - else - *ptr++ = 0; - } - } - - delete[] walkMap; -} - /*------------------------------------------------------------------------*/ SceneLogic::SceneLogic(MADSEngine *vm) : _vm(vm) { -- cgit v1.2.3