[Scummvm-cvs-logs] SF.net SVN: scummvm:[54818] tools/trunk/engines/mohawk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Tue Dec 7 21:58:27 CET 2010
Revision: 54818
http://scummvm.svn.sourceforge.net/scummvm/?rev=54818&view=rev
Author: mthreepwood
Date: 2010-12-07 20:58:27 +0000 (Tue, 07 Dec 2010)
Log Message:
-----------
TOOLS: Add the ability to extract CSWorld Deluxe resources to extract_mohawk
Modified Paths:
--------------
tools/trunk/engines/mohawk/archive.cpp
tools/trunk/engines/mohawk/archive.h
Modified: tools/trunk/engines/mohawk/archive.cpp
===================================================================
--- tools/trunk/engines/mohawk/archive.cpp 2010-12-07 19:46:21 UTC (rev 54817)
+++ tools/trunk/engines/mohawk/archive.cpp 2010-12-07 20:58:27 UTC (rev 54818)
@@ -414,6 +414,50 @@
return output;
}
+void CSWorldDeluxeArchive::open(Common::SeekableReadStream *stream) {
+ close();
+ _mhk = stream;
+
+ // CSWorld Deluxe uses another similar format, but with less features
+ // then the next archive version. There is no possibility for a name
+ // table here and is the simplest of the three formats.
+
+ uint32 typeTableOffset = _mhk->readUint32LE();
+
+ _mhk->seek(typeTableOffset);
+
+ _typeTable.resource_types = _mhk->readUint16LE();
+ _types = new OldType[_typeTable.resource_types];
+
+ debug (0, "CSWorld Deluxe File: Number of Resource Types = %04x", _typeTable.resource_types);
+
+ for (uint16 i = 0; i < _typeTable.resource_types; i++) {
+ _types[i].tag = _mhk->readUint32LE();
+ _types[i].resource_table_offset = _mhk->readUint16LE();
+
+ debug (3, "Type[%02d]: Tag = \'%s\' ResTable Offset = %04x", i, tag2str(_types[i].tag), _types[i].resource_table_offset);
+
+ uint32 oldPos = _mhk->pos();
+
+ // Resource Table/File Table
+ _mhk->seek(_types[i].resource_table_offset + typeTableOffset);
+ _types[i].resTable.resources = _mhk->readUint16LE();
+ _types[i].resTable.entries = new OldType::ResourceTable::Entries[_types[i].resTable.resources];
+
+ for (uint16 j = 0; j < _types[i].resTable.resources; j++) {
+ _types[i].resTable.entries[j].id = _mhk->readUint16LE();
+ _types[i].resTable.entries[j].offset = _mhk->readUint32LE() + 1; // Need to add one to the offset!
+ _types[i].resTable.entries[j].size = (_mhk->readUint32LE() & 0xfffff); // Seems only the bottom 20 bits are valid (top two bytes might be flags?)
+ _mhk->readByte(); // Unknown (always 0?)
+
+ debug (4, "Entry[%02x]: ID = %04x (%d)\tOffset = %08x, Size = %08x", j, _types[i].resTable.entries[j].id, _types[i].resTable.entries[j].id, _types[i].resTable.entries[j].offset, _types[i].resTable.entries[j].size);
+ }
+
+ _mhk->seek(oldPos);
+ debug (3, "\n");
+ }
+}
+
MohawkArchive *MohawkArchive::createMohawkArchive(Common::SeekableReadStream *stream) {
uint32 headerTag = stream->readUint32BE();
@@ -427,6 +471,28 @@
} else if (headerTag == 6 || SWAP_BYTES_32(headerTag) == 6) {
// Assume the Living Books v1 archive format
mohawkArchive = new LivingBooksArchive_v1();
+ } else {
+ headerTag = SWAP_BYTES_32(headerTag);
+ // Use a simple heuristic for testing if it's a CSWorld Deluxe file
+ if (headerTag + 2 < stream->size()) {
+ stream->seek(headerTag);
+ uint16 typeCount = stream->readUint16LE();
+
+ if (typeCount * 6 + stream->pos() < stream->size()) {
+ bool isDeluxeArchive = true;
+
+ for (uint16 i = 0; i < typeCount; i++) {
+ stream->readUint32LE(); // Ignore tag
+ if (stream->readUint16LE() + headerTag >= stream->size()) {
+ isDeluxeArchive = false;
+ break;
+ }
+ }
+
+ if (isDeluxeArchive)
+ mohawkArchive = new CSWorldDeluxeArchive();
+ }
+ }
}
stream->seek(0);
Modified: tools/trunk/engines/mohawk/archive.h
===================================================================
--- tools/trunk/engines/mohawk/archive.h 2010-12-07 19:46:21 UTC (rev 54817)
+++ tools/trunk/engines/mohawk/archive.h 2010-12-07 20:58:27 UTC (rev 54818)
@@ -31,7 +31,6 @@
// Main FourCC's
#define ID_MHWK MKID_BE('MHWK') // Main FourCC
#define ID_RSRC MKID_BE('RSRC') // Resource Directory Tag
-#define ID_LBRC MKID_BE('LBRC') // Living Books v2 FourCC
// Myst Resource FourCC's
#define ID_CLRC MKID_BE('CLRC') // Cursor Hotspots
@@ -236,11 +235,11 @@
LivingBooksArchive_v1() : MohawkArchive() {}
~LivingBooksArchive_v1() {}
- void open(Common::SeekableReadStream *stream);
+ virtual void open(Common::SeekableReadStream *stream);
MohawkOutputStream getRawData(uint32 tag, uint16 id);
MohawkOutputStream getNextFile();
-private:
+protected:
struct OldType {
uint32 tag;
uint16 resource_table_offset;
@@ -269,4 +268,11 @@
}
};
+class CSWorldDeluxeArchive : public LivingBooksArchive_v1 {
+public:
+ CSWorldDeluxeArchive() : LivingBooksArchive_v1() {}
+ ~CSWorldDeluxeArchive() {}
+ void open(Common::SeekableReadStream *stream);
+};
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list