diff options
author | Matthew Hoops | 2010-04-06 23:38:43 +0000 |
---|---|---|
committer | Matthew Hoops | 2010-04-06 23:38:43 +0000 |
commit | 3fe570cd70bda759dd9863c9da05289d0d072d98 (patch) | |
tree | 4abb3f33c2abb01a4bcaef9e79597668d56f0bfb /engines/mohawk/myst.cpp | |
parent | 8e8b6cfa788c594ad8a841999afaeba779254b58 (diff) | |
download | scummvm-rg350-3fe570cd70bda759dd9863c9da05289d0d072d98.tar.gz scummvm-rg350-3fe570cd70bda759dd9863c9da05289d0d072d98.tar.bz2 scummvm-rg350-3fe570cd70bda759dd9863c9da05289d0d072d98.zip |
Cleanup the Myst resource caching code a bit and add support for caching Myst ME MJMP sound 'jumps'
svn-id: r48579
Diffstat (limited to 'engines/mohawk/myst.cpp')
-rw-r--r-- | engines/mohawk/myst.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 5835c7e69d..f935e576b7 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -94,10 +94,10 @@ MohawkEngine_Myst::~MohawkEngine_Myst() { // Uses cached data objects in preference to disk access Common::SeekableReadStream *MohawkEngine_Myst::getRawData(uint32 tag, uint16 id) { - Common::SeekableReadStream *ret; + Common::SeekableReadStream *ret = _cache.search(tag, id); - ret = _cache.search(tag, id); - if(ret != NULL) return ret; + if (ret) + return ret; for (uint32 i = 0; i < _mhk.size(); i++) if (_mhk[i]->hasResource(tag, id)) { @@ -106,24 +106,37 @@ Common::SeekableReadStream *MohawkEngine_Myst::getRawData(uint32 tag, uint16 id) return ret; } - error ("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); + error("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); return NULL; } void MohawkEngine_Myst::cachePreload(uint32 tag, uint16 id) { - Common::SeekableReadStream *tempData; + if (!_cache.enabled) + return; - if (!_cache.enabled) return; + for (uint32 i = 0; i < _mhk.size(); i++) { + // Check for MJMP in Myst ME + if ((getFeatures() & GF_ME) && tag == ID_MSND && _mhk[i]->hasResource(ID_MJMP, id)) { + Common::SeekableReadStream *tempData = _mhk[i]->getRawData(ID_MJMP, id); + uint16 msndId = tempData->readUint16LE(); + delete tempData; + + // We've found where the real MSND data is, so go get that + tempData = _mhk[i]->getRawData(tag, msndId); + _cache.add(tag, id, tempData); + delete tempData; + return; + } - for (uint32 i = 0; i < _mhk.size(); i++) if (_mhk[i]->hasResource(tag, id)) { - tempData = _mhk[i]->getRawData(tag, id); + Common::SeekableReadStream *tempData = _mhk[i]->getRawData(tag, id); _cache.add(tag, id, tempData); delete tempData; return; } + } - warning ("cachePreload : Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); + warning("cachePreload: Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); } static const char *mystFiles[] = { |