[Scummvm-cvs-logs] scummvm master -> be9c3bf72bfc6d0abf650664df4be3595ad96933
bluegr
bluegr at gmail.com
Wed Jul 23 01:48:23 CEST 2014
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9118f38b29 MADS: Add support for FAB decompression in the dump_file command
be9c3bf72b MADS: WIP handling of V2 walk nodes and walkable areas
Commit: 9118f38b299f6ec5bfc6971306f5b99cf0a1fd6c
https://github.com/scummvm/scummvm/commit/9118f38b299f6ec5bfc6971306f5b99cf0a1fd6c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-07-23T02:47:29+03:00
Commit Message:
MADS: Add support for FAB decompression in the dump_file command
Changed paths:
engines/mads/debugger.cpp
diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 1ff42c5..6bc6cf5 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -21,6 +21,7 @@
*/
#include "common/file.h"
+#include "mads/compression.h"
#include "mads/mads.h"
#include "mads/debugger.h"
@@ -169,8 +170,10 @@ bool Debugger::Cmd_ShowCodes(int argc, const char **argv) {
}
bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
- if (argc != 2) {
- debugPrintf("Usage: %s <resource>\n", argv[0]);
+ if (argc < 2) {
+ debugPrintf("Usage: %s <resource> <unpack>\n", argv[0]);
+ debugPrintf(" resource: the resource name\n");
+ debugPrintf(" unpack: optional, when specified, the FAB/MADSPACK compressed resource is unpacked\n");
} else {
Common::DumpFile outFile;
Common::File inFile;
@@ -179,10 +182,32 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
debugPrintf("Specified resource does not exist\n");
} else {
outFile.open(argv[1]);
- byte *data = new byte[inFile.size()];
-
- inFile.read(data, inFile.size());
- outFile.write(data, inFile.size());
+ bool unpack = ((argc >= 3) && !scumm_stricmp(argv[2], "unpack"));
+
+ byte *data;
+ int totalSize = 0;
+
+ if (!unpack) {
+ totalSize = inFile.size();
+ data = new byte[totalSize];
+ inFile.read(data, totalSize);
+ } else {
+ MadsPack dataPack(&inFile);
+ int count = dataPack.getCount();
+ for (int i = 0; i < count; i++) {
+ totalSize += dataPack.getItem(i)._size;
+ }
+ data = new byte[totalSize];
+ byte *ptr = data;
+
+ for (int i = 0; i < count; i++) {
+ Common::SeekableReadStream *readStream = dataPack.getItemStream(i);
+ readStream->read(ptr, readStream->size());
+ ptr += readStream->size();
+ }
+ }
+
+ outFile.write(data, totalSize);
outFile.flush();
delete[] data;
Commit: be9c3bf72bfc6d0abf650664df4be3595ad96933
https://github.com/scummvm/scummvm/commit/be9c3bf72bfc6d0abf650664df4be3595ad96933
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-07-23T02:47:29+03:00
Commit Message:
MADS: WIP handling of V2 walk nodes and walkable areas
Changed paths:
engines/mads/dragonsphere/dragonsphere_scenes.cpp
engines/mads/phantom/phantom_scenes.cpp
engines/mads/scene_data.cpp
diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.cpp b/engines/mads/dragonsphere/dragonsphere_scenes.cpp
index 59d7914..f32d17d 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 dbce014..7fd7ce6 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 1494f62..36aa831 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) {
More information about the Scummvm-git-logs
mailing list