diff options
author | Paul Gilbert | 2014-03-12 23:45:57 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-03-12 23:45:57 -0400 |
commit | 0df4d0aed1678f81cb75bb56cb2a1fc19603312c (patch) | |
tree | 69bf2b7826de6a962a91ab5c719c926af12f7198 /engines/mads | |
parent | 408f5e79df5e8a33367fdf2a9c17b424953edace (diff) | |
download | scummvm-rg350-0df4d0aed1678f81cb75bb56cb2a1fc19603312c.tar.gz scummvm-rg350-0df4d0aed1678f81cb75bb56cb2a1fc19603312c.tar.bz2 scummvm-rg350-0df4d0aed1678f81cb75bb56cb2a1fc19603312c.zip |
MADS: Fixed loading of scene depth surface for Rex Nebular
Diffstat (limited to 'engines/mads')
-rw-r--r-- | engines/mads/nebular/nebular_scenes.cpp | 9 | ||||
-rw-r--r-- | engines/mads/nebular/nebular_scenes.h | 2 | ||||
-rw-r--r-- | engines/mads/palette.cpp | 4 | ||||
-rw-r--r-- | engines/mads/palette.h | 4 | ||||
-rw-r--r-- | engines/mads/scene_data.cpp | 39 | ||||
-rw-r--r-- | engines/mads/scene_data.h | 7 |
6 files changed, 25 insertions, 40 deletions
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp index baee40cc47..3587822f19 100644 --- a/engines/mads/nebular/nebular_scenes.cpp +++ b/engines/mads/nebular/nebular_scenes.cpp @@ -68,6 +68,13 @@ void SceneInfoNebular::loadCodes(MSurface &depthSurface) { MadsPack codesPack(&f); Common::SeekableReadStream *stream = codesPack.getItemStream(0); + loadCodes(depthSurface, stream); + + delete stream; + f.close(); +} + +void SceneInfoNebular::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) { byte *destP = depthSurface.getData(); byte *endP = depthSurface.getBasePtr(0, depthSurface.h); @@ -85,8 +92,6 @@ void SceneInfoNebular::loadCodes(MSurface &depthSurface) { if (destP < endP) Common::fill(destP, endP, 0); - delete stream; - f.close(); } } // End of namespace Nebular diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h index da36c71905..5ac708d398 100644 --- a/engines/mads/nebular/nebular_scenes.h +++ b/engines/mads/nebular/nebular_scenes.h @@ -115,6 +115,8 @@ class SceneInfoNebular : public SceneInfo { protected: virtual void loadCodes(MSurface &depthSurface); + virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream); + /** * Constructor */ diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index 7e0d5bbdb5..b42fa144e7 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -229,7 +229,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) { palette[palIndex]._palIndex = var4; } - _vm->_palette->_rgbList[rgbIndex] = 0xffff; + _vm->_palette->_rgbList[rgbIndex] = -1; delete[] pal1; delete[] pal2; @@ -541,7 +541,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) { } _rgbList.clear(); - _rgbList[0] = _rgbList[1] = 0xffff; + _rgbList[0] = _rgbList[1] = -1; _v1 = 0; _lowRange = lowRange; diff --git a/engines/mads/palette.h b/engines/mads/palette.h index 5f21bd9a21..906f62c3f3 100644 --- a/engines/mads/palette.h +++ b/engines/mads/palette.h @@ -100,7 +100,7 @@ public: class RGBList { private: - uint16 _data[32]; + int16 _data[32]; public: RGBList() { clear(); } @@ -113,7 +113,7 @@ public: */ int scan(); - uint16 &operator[](int idx) { return _data[idx]; } + int16 &operator[](int idx) { return _data[idx]; } }; #define PALETTE_COUNT 256 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) { diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h index b8b2056c12..d5c7281fae 100644 --- a/engines/mads/scene_data.h +++ b/engines/mads/scene_data.h @@ -253,7 +253,12 @@ protected: /** * Loads the given surface with depth information of a given scene */ - virtual void loadCodes(MSurface &depthSurface); + virtual void loadCodes(MSurface &depthSurface) = 0; + + /** + * Loads the given surface with depth information of a given scene + */ + virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) = 0; public: int _sceneId; int _artFileNum; |