SCI: Add support for the KQ5 FM Towns resource format
Thanks to alexbevi for providing details on the format
This commit is contained in:
parent
84db0f60b0
commit
758e495872
4 changed files with 30 additions and 4 deletions
|
@ -38,6 +38,7 @@ namespace Sci {
|
|||
enum {
|
||||
SCI0_RESMAP_ENTRIES_SIZE = 6,
|
||||
SCI1_RESMAP_ENTRIES_SIZE = 6,
|
||||
KQ5FMT_RESMAP_ENTRIES_SIZE = 7,
|
||||
SCI11_RESMAP_ENTRIES_SIZE = 5
|
||||
};
|
||||
|
||||
|
@ -1115,6 +1116,8 @@ const char *ResourceManager::versionDescription(ResVersion version) const {
|
|||
return "SCI0 / Early SCI1";
|
||||
case kResVersionSci1Middle:
|
||||
return "Middle SCI1";
|
||||
case kResVersionKQ5FMT:
|
||||
return "KQ5 FM Towns";
|
||||
case kResVersionSci1Late:
|
||||
return "Late SCI1";
|
||||
case kResVersionSci11:
|
||||
|
@ -1164,6 +1167,14 @@ ResVersion ResourceManager::detectMapVersion() {
|
|||
fileStream->seek(-4, SEEK_END);
|
||||
uint32 uEnd = fileStream->readUint32LE();
|
||||
if (uEnd == 0xFFFFFFFF) {
|
||||
// check if the last 7 bytes are all ff, indicating a KQ5 FM-Towns map
|
||||
fileStream->seek(-7, SEEK_END);
|
||||
fileStream->read(buff, 3);
|
||||
if (buff[0] == 0xff && buff[1] == 0xff && buff[2] == 0xff) {
|
||||
delete fileStream;
|
||||
return kResVersionKQ5FMT;
|
||||
}
|
||||
|
||||
// check if 0 or 01 - try to read resources in SCI0 format and see if exists
|
||||
fileStream->seek(0, SEEK_SET);
|
||||
while (fileStream->read(buff, 6) == 6 && !(buff[0] == 0xFF && buff[1] == 0xFF && buff[2] == 0xFF)) {
|
||||
|
@ -1578,10 +1589,15 @@ int ResourceManager::readResourceMapSCI0(ResourceSource *map) {
|
|||
|
||||
fileStream->seek(0, SEEK_SET);
|
||||
|
||||
byte bMask = (_mapVersion == kResVersionSci1Middle) ? 0xF0 : 0xFC;
|
||||
byte bShift = (_mapVersion == kResVersionSci1Middle) ? 28 : 26;
|
||||
byte bMask = (_mapVersion >= kResVersionSci1Middle) ? 0xF0 : 0xFC;
|
||||
byte bShift = (_mapVersion >= kResVersionSci1Middle) ? 28 : 26;
|
||||
|
||||
do {
|
||||
// King's Quest 5 FM-Towns uses a 7 byte version of the SCI1 Middle map,
|
||||
// splitting the type from the id.
|
||||
if (_mapVersion == kResVersionKQ5FMT)
|
||||
type = convertResType(fileStream->readByte());
|
||||
|
||||
id = fileStream->readUint16LE();
|
||||
offset = fileStream->readUint32LE();
|
||||
|
||||
|
@ -1590,11 +1606,17 @@ int ResourceManager::readResourceMapSCI0(ResourceSource *map) {
|
|||
warning("Error while reading %s", map->getLocationName().c_str());
|
||||
return SCI_ERROR_RESMAP_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (offset == 0xFFFFFFFF)
|
||||
break;
|
||||
|
||||
type = convertResType(id >> 11);
|
||||
number = id & 0x7FF;
|
||||
if (_mapVersion == kResVersionKQ5FMT) {
|
||||
number = id;
|
||||
} else {
|
||||
type = convertResType(id >> 11);
|
||||
number = id & 0x7FF;
|
||||
}
|
||||
|
||||
ResourceId resId = ResourceId(type, number);
|
||||
// adding a new resource
|
||||
if (_resMap.contains(resId) == false) {
|
||||
|
@ -2233,6 +2255,7 @@ void ResourceManager::detectSciVersion() {
|
|||
s_sciVersion = SCI_VERSION_1_EARLY;
|
||||
return;
|
||||
case kResVersionSci1Middle:
|
||||
case kResVersionKQ5FMT:
|
||||
s_sciVersion = SCI_VERSION_1_MIDDLE;
|
||||
return;
|
||||
case kResVersionSci1Late:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue