[Scummvm-git-logs] scummvm master -> dea88ded28ef8974f53eadd0f656648d107a7291
sev-
noreply at scummvm.org
Fri May 24 16:29:29 UTC 2024
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:
25577d4702 COMMON: Improved debug output for dumping archives
dea88ded28 DIRECTOR: Patching built-in Projector archive files
Commit: 25577d470277864448747cfaf66450d066ca9c45
https://github.com/scummvm/scummvm/commit/25577d470277864448747cfaf66450d066ca9c45
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-05-24T18:29:08+02:00
Commit Message:
COMMON: Improved debug output for dumping archives
Changed paths:
common/archive.cpp
diff --git a/common/archive.cpp b/common/archive.cpp
index ca42afd3a0e..f47427e5511 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -132,7 +132,7 @@ Common::Error Archive::dumpArchive(const Path &destPath) {
for (auto &f : files) {
Common::Path filePath = f->getPathInArchive().punycodeEncode();
- debug(1, "File: %s", filePath.toString().c_str());
+ debug(1, "dumpArchive(): File: %s", filePath.toString().c_str());
// skip if f represents a directory
if (filePath.isSeparatorTerminated()) continue;
Commit: dea88ded28ef8974f53eadd0f656648d107a7291
https://github.com/scummvm/scummvm/commit/dea88ded28ef8974f53eadd0f656648d107a7291
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-05-24T18:29:08+02:00
Commit Message:
DIRECTOR: Patching built-in Projector archive files
This lets McLuhan to finally properly start and load
these movies
Changed paths:
engines/director/resource.cpp
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 6d95a1f459c..9358f8b377a 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -795,6 +795,9 @@ Common::SeekableReadStream *ProjectorArchive::createReadStreamForMember(const Co
if (fDesc == _files.end())
return nullptr;
+ debugC(3, kDebugLoading, "ProjectorArchive::createReadStreamForMember(): Opening built-in file '%s' @ 0x%08x, %d bytes",
+ path.toString().c_str(), fDesc->_value.offset, fDesc->_value.size);
+
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(_path);
stream->seek(fDesc->_value.offset, SEEK_SET);
@@ -802,6 +805,106 @@ Common::SeekableReadStream *ProjectorArchive::createReadStreamForMember(const Co
stream->read(data, fDesc->_value.size);
delete stream;
+ // Now we need to patch the mmap offset
+
+ // First, do sanity checking for the file
+ byte *ptr = data;
+ uint32 headerTag = READ_UINT32(ptr);
+ ptr += 4;
+ bool formatOK = true;
+ bool isBigEndian = false; // LE
+
+ if (headerTag == MKTAG('X', 'F', 'I', 'R')) {
+ isBigEndian = false;
+ } else if (headerTag == MKTAG('R', 'I', 'F', 'X')) {
+ isBigEndian = true;
+ } else {
+ formatOK = false;
+ }
+
+ // 4 bytes size
+ ptr += 4;
+
+ uint32 rifxType = isBigEndian ? READ_LE_UINT32(ptr) : READ_BE_UINT32(ptr);
+ ptr += 4;
+
+ uint32 mmapOffset;
+ uint32 resCount;
+
+ int patchedOffests = 0;
+
+ switch (rifxType) {
+ case MKTAG('M', 'V', '9', '3'):
+ case MKTAG('M', 'C', '9', '5'):
+ case MKTAG('A', 'P', 'P', 'L'):
+ if ((isBigEndian ? READ_LE_UINT32(ptr) : READ_BE_UINT32(ptr)) != MKTAG('i', 'm', 'a', 'p')) {
+ formatOK = false;
+ break;
+ }
+ ptr += 4;
+
+ // patch it
+ ptr += 4; // imap length
+ ptr += 4; // unknown
+ mmapOffset = isBigEndian ? READ_LE_UINT32(ptr) : READ_BE_UINT32(ptr);
+
+ debugC(8, kDebugLoading, "ProjectorArchive::createReadStreamForMember(): Patched offset at 0x%08x from %u to %u",
+ (uint32)(ptr - data), mmapOffset, mmapOffset - fDesc->_value.offset);
+
+ mmapOffset -= fDesc->_value.offset;
+
+ isBigEndian ? WRITE_LE_UINT32(ptr, mmapOffset) : WRITE_BE_UINT32(ptr, mmapOffset);
+ patchedOffests++;
+
+ ptr = data + mmapOffset;
+
+ if ((isBigEndian ? READ_LE_UINT32(ptr) : READ_BE_UINT32(ptr)) != MKTAG('m', 'm', 'a', 'p')) {
+ formatOK = false;
+ break;
+ }
+
+ ptr += 4; // mmap length
+ ptr += 4; // unknown
+ ptr += 4; // unknown
+ ptr += 4; // resCount + empty entries
+ resCount = isBigEndian ? READ_LE_UINT32(ptr) : READ_BE_UINT32(ptr);
+ ptr += 4;
+ ptr += 8; // all 0xFF
+ ptr += 4; // id of the first free resource, -1 if none.
+
+ for (uint32 i = 0; i < resCount; i++) {
+ ptr += 4; // tag
+ uint32 size = isBigEndian ? READ_LE_UINT32(ptr) : READ_BE_UINT32(ptr);
+ ptr += 4;
+ int32 offset = isBigEndian ? READ_LE_UINT32(ptr) : READ_BE_UINT32(ptr);
+
+ if (size > 0 || offset >= fDesc->_value.offset) {
+ debugC(8, kDebugLoading, "ProjectorArchive::createReadStreamForMember(): Patched offset at 0x%08x from %u to %u",
+ (uint32)(ptr - data), offset, offset - fDesc->_value.offset);
+
+ offset -= fDesc->_value.offset;
+ patchedOffests++;
+
+ isBigEndian ? WRITE_LE_UINT32(ptr, offset) : WRITE_BE_UINT32(ptr, offset);
+ }
+ ptr += 4;
+
+ ptr += 2; // flags
+ ptr += 2; // unk1
+ ptr += 4; // nextFreeResourceId
+ }
+
+ break;
+
+ default:
+ formatOK = false;
+ }
+
+ if (!formatOK)
+ warning("ProjectorArchive::createReadStreamForMember(): File %s has unsupported format", path.toString().c_str());
+
+ debugC(3, kDebugLoading, "ProjectorArchive::createReadStreamForMember(): Patched %d offsets", patchedOffests);
+
return new Common::MemoryReadStream(data, fDesc->_value.size, DisposeAfterUse::YES);
}
} // End of namespace Director
More information about the Scummvm-git-logs
mailing list