aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mads/dragonsphere/dragonsphere_scenes.cpp31
-rw-r--r--engines/mads/phantom/phantom_scenes.cpp31
-rw-r--r--engines/mads/scene_data.cpp52
3 files changed, 55 insertions, 59 deletions
diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.cpp b/engines/mads/dragonsphere/dragonsphere_scenes.cpp
index 59d7914378..f32d17d9c9 100644
--- a/engines/mads/dragonsphere/dragonsphere_scenes.cpp
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.cpp
@@ -201,9 +201,10 @@ Common::String DragonsphereScene::formAnimName(char sepChar, int suffixNum) {
/*------------------------------------------------------------------------*/
void SceneInfoDragonsphere::loadCodes(MSurface &depthSurface, int variant) {
- File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+ Common::String ext = Common::String::format(".WW%d", variant);
+ File f(Resources::formatName(RESPREFIX_RM, _sceneId, ext));
MadsPack codesPack(&f);
- Common::SeekableReadStream *stream = codesPack.getItemStream(variant + 1);
+ Common::SeekableReadStream *stream = codesPack.getItemStream(0);
loadCodes(depthSurface, stream);
@@ -213,22 +214,20 @@ void SceneInfoDragonsphere::loadCodes(MSurface &depthSurface, int variant) {
void SceneInfoDragonsphere::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) {
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();
+ byte *walkMap = new byte[stream->size()];
+ stream->read(walkMap, stream->size());
+
+ for (int y = 0; y < 156; ++y) {
+ for (int x = 0; x < 320; ++x) {
+ int offset = x + (y * 320);
+ if ((walkMap[offset / 8] << (offset % 8)) & 0x80)
+ *destP++ = 1; // walkable
+ else
+ *destP++ = 0;
+ }
}
- if (destP < endP)
- Common::fill(destP, endP, 0);
+ delete[] walkMap;
}
} // End of namespace Dragonsphere
diff --git a/engines/mads/phantom/phantom_scenes.cpp b/engines/mads/phantom/phantom_scenes.cpp
index dbce014525..7fd7ce642d 100644
--- a/engines/mads/phantom/phantom_scenes.cpp
+++ b/engines/mads/phantom/phantom_scenes.cpp
@@ -169,9 +169,10 @@ Common::String PhantomScene::formAnimName(char sepChar, int suffixNum) {
/*------------------------------------------------------------------------*/
void SceneInfoPhantom::loadCodes(MSurface &depthSurface, int variant) {
- File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+ Common::String ext = Common::String::format(".WW%d", variant);
+ File f(Resources::formatName(RESPREFIX_RM, _sceneId, ext));
MadsPack codesPack(&f);
- Common::SeekableReadStream *stream = codesPack.getItemStream(variant + 1);
+ Common::SeekableReadStream *stream = codesPack.getItemStream(0);
loadCodes(depthSurface, stream);
@@ -181,22 +182,20 @@ void SceneInfoPhantom::loadCodes(MSurface &depthSurface, int variant) {
void SceneInfoPhantom::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) {
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();
+ byte *walkMap = new byte[stream->size()];
+ stream->read(walkMap, stream->size());
+
+ for (int y = 0; y < 156; ++y) {
+ for (int x = 0; x < 320; ++x) {
+ int offset = x + (y * 320);
+ if ((walkMap[offset / 8] << (offset % 8)) & 0x80)
+ *destP++ = 1; // walkable
+ else
+ *destP++ = 0;
+ }
}
- if (destP < endP)
- Common::fill(destP, endP, 0);
+ delete[] walkMap;
}
} // End of namespace Phantom
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 1494f62d7a..36aa831c0b 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -151,30 +151,34 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
_sceneId = sceneId;
}
- // TODO: The following isn't quite right for V2 games (it's all 0)
- _artFileNum = infoStream->readUint16LE();
- _depthStyle = infoStream->readUint16LE();
- _width = infoStream->readUint16LE();
- _height = infoStream->readUint16LE();
-
- // HACK for V2 games (for now)
- if (_vm->getGameID() != GType_RexNebular) {
+ int nodeCount = 20;
+
+ if (_vm->getGameID() == GType_RexNebular) {
+ _artFileNum = infoStream->readUint16LE();
+ _depthStyle = infoStream->readUint16LE();
+ _width = infoStream->readUint16LE();
+ _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(24);
- int 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();
+ infoStream->skip(140);
+ }
- // Load the set of objects that are associated with the scene
+ // Load the scene's walk nodes
for (int i = 0; i < 20; ++i) {
WalkNode node;
node.load(infoStream);
@@ -223,13 +227,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
depthSurface.setSize(width, height);
}
- if (_vm->getGameID() == GType_RexNebular) {
- // Load the depth surface with the scene codes
- Common::SeekableReadStream *depthStream = infoPack.getItemStream(variant + 1);
- loadCodes(depthSurface, depthStream);
- delete depthStream;
- }
-
+ loadCodes(depthSurface, variant);
infoFile.close();
if (_vm->getGameID() == GType_RexNebular) {