diff options
author | Colin Snover | 2017-01-02 16:59:06 -0600 |
---|---|---|
committer | Colin Snover | 2017-01-02 17:02:31 -0600 |
commit | a91b432cdbd97b1fde73dae2b67bd2b6b4ef6257 (patch) | |
tree | d9f0ca2ea6b7c2c52250fdfb9e53c100f940d4f1 /engines | |
parent | 3be2025a5e5b029fc5e4a26a221ac8383efb587f (diff) | |
download | scummvm-rg350-a91b432cdbd97b1fde73dae2b67bd2b6b4ef6257.tar.gz scummvm-rg350-a91b432cdbd97b1fde73dae2b67bd2b6b4ef6257.tar.bz2 scummvm-rg350-a91b432cdbd97b1fde73dae2b67bd2b6b4ef6257.zip |
SCI32: Load VMDs from resource bundles
GK2 includes some VMDs in the RESSCI.00n volume bundles for the
chase scene at the end of Chapter 6.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 19 | ||||
-rw-r--r-- | engines/sci/graphics/video32.cpp | 29 | ||||
-rw-r--r-- | engines/sci/graphics/video32.h | 7 |
3 files changed, 43 insertions, 12 deletions
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 0e29ccf783..77ef92b349 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -102,15 +102,9 @@ reg_t kLock(EngineState *s, int argc, reg_t *argv) { } reg_t kResCheck(EngineState *s, int argc, reg_t *argv) { - Resource *res = NULL; + Resource *res = nullptr; ResourceType restype = g_sci->getResMan()->convertResType(argv[0].toUint16()); - if (restype == kResourceTypeVMD) { - char fileName[10]; - sprintf(fileName, "%d.vmd", argv[1].toUint16()); - return make_reg(0, Common::File::exists(fileName)); - } - if ((restype == kResourceTypeAudio36) || (restype == kResourceTypeSync36)) { if (argc >= 6) { uint noun = argv[2].toUint16() & 0xff; @@ -124,7 +118,16 @@ reg_t kResCheck(EngineState *s, int argc, reg_t *argv) { res = g_sci->getResMan()->testResource(ResourceId(restype, argv[1].toUint16())); } - return make_reg(0, res != NULL); +#ifdef ENABLE_SCI32 + // GK2 stores some VMDs inside of resource volumes, but usually they are + // streamed from the filesystem + if (res == nullptr && restype == kResourceTypeVMD) { + const Common::String fileName = Common::String::format("%u.vmd", argv[1].toUint16()); + return make_reg(0, Common::File::exists(fileName)); + } +#endif + + return make_reg(0, res != nullptr); } reg_t kClone(EngineState *s, int argc, reg_t *argv) { diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp index c3aafb62bf..4af1e76ed9 100644 --- a/engines/sci/graphics/video32.cpp +++ b/engines/sci/graphics/video32.cpp @@ -39,6 +39,7 @@ #include "sci/graphics/palette32.h" // for GfxPalette32 #include "sci/graphics/plane32.h" // for Plane, PlanePictureCodes::kP... #include "sci/graphics/screen_item32.h" // for ScaleInfo, ScreenItem, Scale... +#include "sci/resource.h" // for ResourceManager, ResourceId,... #include "sci/sci.h" // for SciEngine, g_sci, getSciVersion #include "sci/sound/audio32.h" // for Audio32 #include "sci/video/seq_decoder.h" // for SEQDecoder @@ -492,6 +493,7 @@ VMDPlayer::VMDPlayer(SegManager *segMan, EventManager *eventMan) : _isOpen(false), _isInitialized(false), + _bundledVmd(nullptr), _yieldFrame(0), _yieldInterval(0), _lastYieldedFrameNo(0), @@ -536,15 +538,29 @@ VMDPlayer::IOStatus VMDPlayer::open(const Common::String &fileName, const OpenFl g_sci->_audio32->stop(kAllChannels); } - if (_decoder->loadFile(fileName)) { + Resource *bundledVmd = g_sci->getResMan()->findResource(ResourceId(kResourceTypeVMD, fileName.asUint64()), true); + + if (bundledVmd != nullptr) { + Common::SeekableReadStream *stream = bundledVmd->makeStream(); + if (_decoder->loadStream(stream)) { + _bundledVmd = bundledVmd; + _isOpen = true; + } else { + delete stream; + g_sci->getResMan()->unlockResource(bundledVmd); + } + } else if (_decoder->loadFile(fileName)) { + _isOpen = true; + } + + if (_isOpen) { if (flags & kOpenFlagMute) { _decoder->setVolume(0); } - _isOpen = true; return kIOSuccess; - } else { - return kIOError; } + + return kIOError; } void VMDPlayer::init(const int16 x, const int16 y, const PlayFlags flags, const int16 boostPercent, const int16 boostStartColor, const int16 boostEndColor) { @@ -571,6 +587,11 @@ VMDPlayer::IOStatus VMDPlayer::close() { _isInitialized = false; _ignorePalettes = false; + if (_bundledVmd) { + g_sci->getResMan()->unlockResource(_bundledVmd); + _bundledVmd = nullptr; + } + _segMan->freeBitmap(_screenItem->_celInfo.bitmap); if (!_planeIsOwned && _screenItem != nullptr) { diff --git a/engines/sci/graphics/video32.h b/engines/sci/graphics/video32.h index 69acdf2fce..5ed8fd954a 100644 --- a/engines/sci/graphics/video32.h +++ b/engines/sci/graphics/video32.h @@ -321,6 +321,13 @@ private: bool _isInitialized; /** + * The Resource object for VMDs that are read out + * of a resource bundle instead of being streamed + * from the filesystem. + */ + Resource *_bundledVmd; + + /** * For VMDs played with the `kEventFlagToFrame` flag, * the target frame for yielding back to the SCI VM. */ |