aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-01 22:53:08 -0500
committerPaul Gilbert2014-03-01 22:53:08 -0500
commit411a4054006be03c0c465b2707c5ef7c50eb87a1 (patch)
tree1222baca9d4d9649d3e6136de031a1b76621a5c3 /engines
parent7f8b2025c0f4e8ee3378b4c7317f31bf31e889ec (diff)
downloadscummvm-rg350-411a4054006be03c0c465b2707c5ef7c50eb87a1.tar.gz
scummvm-rg350-411a4054006be03c0c465b2707c5ef7c50eb87a1.tar.bz2
scummvm-rg350-411a4054006be03c0c465b2707c5ef7c50eb87a1.zip
MADS: Further fixes for SceneInfo data loading
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/scene.cpp3
-rw-r--r--engines/mads/scene_data.cpp53
-rw-r--r--engines/mads/scene_data.h39
3 files changed, 78 insertions, 17 deletions
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e9ae3e6ddd..c640ff8da1 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -120,7 +120,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
_messages.clear();
// TODO: palletteUsage reset? setPalette(_nullPalette);
- _sceneInfo = SceneInfo::load(_vm, _currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
+ _sceneInfo = SceneInfo::init(_vm);
+ _sceneInfo->load(_currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
_depthSurface, _backgroundSurface);
}
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 8fe03f2056..0204699165 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -205,14 +205,17 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
/*------------------------------------------------------------------------*/
-SceneInfo *SceneInfo::load(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
- int v3, MSurface &depthSurface, MSurface &bgSurface) {
- return new SceneInfo(vm, sceneId, v1, resName, v3, depthSurface, bgSurface);
+SceneInfo *SceneInfo::init(MADSEngine *vm) {
+ if (vm->getGameID() == GType_RexNebular) {
+ return new SceneInfoNebular(vm);
+ }
+ else {
+ return new SceneInfo(vm);
+ }
}
-SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
+void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
int flags, MSurface &depthSurface, MSurface &bgSurface) {
- _vm = vm;
bool sceneFlag = sceneId >= 0;
// Figure out the resource to use
@@ -308,7 +311,6 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
ARTHeader artHeader;
artHeader.load(stream);
delete stream;
- artFile.close();
// Copy out the palette data
for (uint i = 0; i < artHeader._palData.size(); ++i)
@@ -333,8 +335,13 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
// Read in the background surface data
assert(_width == bgSurface.w && _height == bgSurface.h);
+ stream = artResource.getItemStream(1);
stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h);
+ // Close the ART file
+ delete stream;
+ artFile.close();
+
Common::Array<SpriteAsset *> spriteSets;
Common::Array<int> xpList;
@@ -371,13 +378,17 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
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[f.size()];
+ byte *walkMap = new byte[stream->size()];
depthSurface.setSize(width, height);
- f.read(walkMap, f.size());
+ stream->read(walkMap, f.size());
+ delete stream;
+ f.close();
byte *ptr = (byte *)depthSurface.getPixels();
@@ -396,4 +407,30 @@ void SceneInfo::loadCodes(MSurface &depthSurface) {
/*------------------------------------------------------------------------*/
+void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
+ File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+ MadsPack codesPack(&f);
+ Common::SeekableReadStream *stream = codesPack.getItemStream(0);
+
+ byte *destP = depthSurface.getData();
+ byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
+
+ byte runLength = stream->readByte();
+ while (destP < endP && runLength > 0) {
+ byte runValue = stream->readByte();
+
+ // Write out the run length
+ Common::fill(destP, destP + runLength, runValue);
+ destP += runLength;
+
+ // Get the next run length
+ runLength = stream->readByte();
+ }
+
+ if (destP < endP)
+ Common::fill(destP, endP, 0);
+ delete stream;
+ f.close();
+}
+
} // End of namespace MADS
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index bcdd50a9d0..1b98b9d165 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -272,16 +272,18 @@ class SceneInfo {
void load(Common::SeekableReadStream *f);
};
-private:
+protected:
MADSEngine *_vm;
- SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
- int v3, MSurface &depthSurface, MSurface &bgSurface);
-
+ /**
+ * Constructor
+ */
+ SceneInfo(MADSEngine *vm) : _vm(vm) {}
+
/**
* Loads the given surface with depth information of a given scene
*/
- void loadCodes(MSurface &depthSurface);
+ virtual void loadCodes(MSurface &depthSurface);
public:
int _sceneId;
int _artFileNum;
@@ -302,10 +304,31 @@ public:
Common::Array<RGB4> _palette;
public:
/**
- * Instantiates the class and loads the data
+ * Destructor
*/
- static SceneInfo *load(MADSEngine *vm, int sceneId, int flags,
- const Common::String &resName, int v3, MSurface &depthSurface, MSurface &bgSurface);
+ virtual ~SceneInfo() {}
+
+ /**
+ * Instantiates the class
+ */
+ static SceneInfo *init(MADSEngine *vm);
+
+ /**
+ loads the data
+ */
+ void load(int sceneId, int flags, const Common::String &resName, int v3,
+ MSurface &depthSurface, MSurface &bgSurface);
+};
+
+class SceneInfoNebular : public SceneInfo {
+ friend class SceneInfo;
+protected:
+ virtual void loadCodes(MSurface &depthSurface);
+
+ /**
+ * Constructor
+ */
+ SceneInfoNebular(MADSEngine *vm) : SceneInfo(vm) {}
};
} // End of namespace MADS