[Scummvm-cvs-logs] SF.net SVN: scummvm:[54912] scummvm/trunk/engines/mohawk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Tue Dec 14 23:58:51 CET 2010
Revision: 54912
http://scummvm.svn.sourceforge.net/scummvm/?rev=54912&view=rev
Author: mthreepwood
Date: 2010-12-14 22:58:51 +0000 (Tue, 14 Dec 2010)
Log Message:
-----------
MOHAWK: Add support for DOS v2 archives (CSWorld Deluxe)
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/resource.cpp
scummvm/trunk/engines/mohawk/resource.h
Modified: scummvm/trunk/engines/mohawk/resource.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/resource.cpp 2010-12-14 22:55:55 UTC (rev 54911)
+++ scummvm/trunk/engines/mohawk/resource.cpp 2010-12-14 22:58:51 UTC (rev 54912)
@@ -473,4 +473,53 @@
return -1; // not found
}
+// Partially based on the Prince of Persia Format Specifications
+// See http://sdfg.com.ar/git/?p=fp-git.git;a=blob;f=FP/doc/FormatSpecifications
+// However, I'm keeping with the terminology we've been using with the
+// later archive formats.
+
+bool DOSArchive_v2::open(Common::SeekableReadStream *stream) {
+ close();
+
+ uint32 typeTableOffset = stream->readUint32LE();
+ uint16 typeTableSize = stream->readUint16LE();
+
+ if (typeTableOffset + typeTableSize != (uint32)stream->size())
+ return false;
+
+ stream->seek(typeTableOffset);
+
+ _typeTable.resource_types = stream->readUint16LE();
+ _types = new OldType[_typeTable.resource_types];
+
+ for (uint16 i = 0; i < _typeTable.resource_types; i++) {
+ _types[i].tag = stream->readUint32LE();
+ _types[i].resource_table_offset = stream->readUint16LE();
+
+ debug(3, "Type[%02d]: Tag = \'%s\' ResTable Offset = %04x", i, tag2str(_types[i].tag), _types[i].resource_table_offset);
+
+ uint32 oldPos = stream->pos();
+
+ // Resource Table/File Table
+ stream->seek(_types[i].resource_table_offset + typeTableOffset);
+ _types[i].resTable.resources = stream->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 = stream->readUint16LE();
+ _types[i].resTable.entries[j].offset = stream->readUint32LE() + 1; // Need to add one to the offset to skip the checksum byte
+ _types[i].resTable.entries[j].size = stream->readUint16LE();
+ stream->skip(3); // Skip the useless flags
+
+ 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);
+ }
+
+ stream->seek(oldPos);
+ debug (3, "\n");
+ }
+
+ _mhk = stream;
+ return true;
+}
+
} // End of namespace Mohawk
Modified: scummvm/trunk/engines/mohawk/resource.h
===================================================================
--- scummvm/trunk/engines/mohawk/resource.h 2010-12-14 22:55:55 UTC (rev 54911)
+++ scummvm/trunk/engines/mohawk/resource.h 2010-12-14 22:58:51 UTC (rev 54912)
@@ -214,13 +214,13 @@
bool hasResource(uint32 tag, uint16 id);
bool hasResource(uint32 tag, const Common::String &resName) { return false; }
- bool open(Common::SeekableReadStream *stream);
+ virtual bool open(Common::SeekableReadStream *stream);
Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
Common::SeekableReadStream *getResource(uint32 tag, const Common::String &resName) { return 0; }
uint32 getOffset(uint32 tag, uint16 id);
uint16 findResourceID(uint32 type, const Common::String &resName) { return 0xFFFF; }
-private:
+protected:
struct OldType {
uint32 tag;
uint16 resource_table_offset;
@@ -234,10 +234,19 @@
} resTable;
} *_types;
+private:
int getTypeIndex(uint32 tag);
int getIDIndex(int typeIndex, uint16 id);
};
+class DOSArchive_v2 : public LivingBooksArchive_v1 {
+public:
+ DOSArchive_v2() : LivingBooksArchive_v1() {}
+ ~DOSArchive_v2() {}
+
+ virtual bool open(Common::SeekableReadStream *stream);
+};
+
} // End of namespace Mohawk
#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