Skip to content

Commit

Permalink
SCI: Fix SCI1.1 patch resources
Browse files Browse the repository at this point in the history
While earlier commits had fixed handling of audio resources in
audio bundles to match SSCI, audio *patches* in SCI16 were still
being treated like standard resource patches. They are now
special-cased in the resource manager, just like SCI32.

Incidentally, while fixing the problem with audio patches, I also
noticed that the patch resource fixes for SQ5/German were very
similar to the special-case operations for resources in SCI32,
though using an odd heuristic. After investigating, it appears
that Sierra SCI1.1 works mostly like SCI32, and not like what
was there from SCI View. So, the old special-case code is deleted
and the special-case code for SCI32 has been expanded to cover
SCI1.1. (SSCI prior to 1.1 do not appear to do this
special-casing.)

Fixes Trac#9773.
  • Loading branch information
csnover committed May 9, 2017
1 parent ae628c1 commit eb6e179
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions engines/sci/resource.cpp
Expand Up @@ -1465,18 +1465,21 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType resource
};

int32 patchDataOffset = kResourceHeaderSize;
if (_volVersion < kResVersionSci2) {
if (_volVersion < kResVersionSci11) {
patchDataOffset += fileStream->readByte();
}
#ifdef ENABLE_SCI32
else {
} else {
switch (patchType) {
case kResourceTypeView:
fileStream->seek(3, SEEK_SET);
patchDataOffset += fileStream->readByte() + kViewHeaderSize + kExtraHeaderSize;
break;
case kResourceTypePic:
patchDataOffset += kExtraHeaderSize;
if (_volVersion < kResVersionSci2) {
fileStream->seek(3, SEEK_SET);
patchDataOffset += fileStream->readByte() + kViewHeaderSize + kExtraHeaderSize;
} else {
patchDataOffset += kExtraHeaderSize;
}
break;
case kResourceTypePalette:
fileStream->seek(3, SEEK_SET);
Expand All @@ -1499,7 +1502,6 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType resource
break;
}
}
#endif

delete fileStream;

Expand All @@ -1509,24 +1511,6 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType resource
return;
}

// Fixes SQ5/German, patch file special case logic taken from SCI View disassembly
if (patchDataOffset & 0x80) {
switch ((patchDataOffset - kResourceHeaderSize) & 0x7F) {
case 0:
patchDataOffset = kResourceHeaderSize + 24;
break;
case 1:
patchDataOffset = kResourceHeaderSize + 2;
break;
case 4:
patchDataOffset = kResourceHeaderSize + 8;
break;
default:
error("Resource patch unsupported special case %X", patchDataOffset & 0x7F);
return;
}
}

if (patchDataOffset >= fsize) {
debug("Patching %s failed - patch starting at offset %d can't be in file of size %d",
source->getLocationName().c_str(), patchDataOffset, fsize);
Expand Down

0 comments on commit eb6e179

Please sign in to comment.