MYST3: Add support for decrypting text metadata

This commit is contained in:
Bastien Bouclet 2012-01-12 17:08:37 +01:00
parent 0b0565771b
commit 7002f6c8d4
2 changed files with 32 additions and 0 deletions

View File

@ -129,4 +129,35 @@ uint32 DirectorySubEntry::getMiscData(uint index) const {
return _miscData[index];
}
Common::String DirectorySubEntry::getTextData(uint index) const {
uint8 key = 35;
uint8 cnt = 0;
uint8 decrypted[89];
memset(decrypted, 0, sizeof(decrypted));
uint8 *out = &decrypted[0];
while (_miscData[cnt / 4] && cnt < 89) {
// XORed text stored in little endian 32 bit words
*out++ = (_miscData[cnt / 4] >> (8 * (3 - (cnt % 4)))) ^ key++;
cnt++;
}
// decrypted contains a null separated string array
// extract the wanted one
cnt = 0;
int i = 0;
Common::String text;
while (cnt <= index && i < 89) {
if (cnt == index)
text += decrypted[i];
if (!decrypted[i])
cnt++;
i++;
}
return text;
}
} // end of namespace Myst3

View File

@ -76,6 +76,7 @@ class DirectorySubEntry {
const SpotItemData &getSpotItemData() const { return _spotItemData; }
const VideoData &getVideoData() const { return _videoData; }
uint32 getMiscData(uint index) const;
Common::String getTextData(uint index) const;
private:
uint32 _offset;