diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 2 | ||||
-rw-r--r-- | engines/access/access.h | 1 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 22 | ||||
-rw-r--r-- | engines/access/scripts.h | 4 | ||||
-rw-r--r-- | engines/access/sound.cpp | 2 | ||||
-rw-r--r-- | engines/access/sound.h | 2 | ||||
-rw-r--r-- | engines/access/video.cpp | 49 | ||||
-rw-r--r-- | engines/access/video.h | 20 |
8 files changed, 74 insertions, 28 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 92ded4facf..e02b0c0da8 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -71,7 +71,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleI = 0; _scaleFlag = false; _eseg = nullptr; - _plotBuffer = nullptr; _conversation = 0; _currentMan = 0; @@ -130,7 +129,6 @@ AccessEngine::~AccessEngine() { delete _music; delete _title; delete _eseg; - delete _plotBuffer; } void AccessEngine::setVGA() { diff --git a/engines/access/access.h b/engines/access/access.h index 8e05da7104..55810e8a16 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -129,7 +129,6 @@ public: ASurface *_current; ASurface _buffer1; ASurface _buffer2; - byte *_plotBuffer; Common::Array<CharEntry *> _charTable; SpriteResource *_objectsTable[100]; bool _establishTable[100]; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 5e0986e379..2d6fc5040b 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -103,7 +103,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, &Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel, - &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::CMDPLAYVID, + &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, @@ -112,7 +112,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, - &Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::CMDPLAYVIDSND, + &Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut, @@ -426,7 +426,9 @@ void Scripts::cmdSetVideo() { _vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate); } -void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); } +void Scripts::cmdPlayVideo() { + _vm->_video->playVideo(); +} void Scripts::cmdPlotImage() { _vm->_destIn = _vm->_current; @@ -667,11 +669,19 @@ void Scripts::cmdSetVideoSound() { cmdSetVideo(); _data->skip(2); - _vm->_sound->_soundFrame = _data->readUint16LE(); - _vm->_sound->_soundFlag = false; + _vm->_video->_soundFrame = _data->readUint16LE(); + _vm->_video->_soundFlag = false; +} + +void Scripts::cmdPlayVideoSound() { + _vm->_video->playVideo(); + if (_vm->_video->_soundFrame == _vm->_video->_videoFrame && + !_vm->_video->_soundFlag) { + _vm->_sound->playSound(0); + _vm->_video->_soundFlag = true; + } } -void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); } void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); } void Scripts::cmdPlayerOff() { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index ec386cf35a..414ba46f81 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -91,7 +91,7 @@ protected: void cmdCheckTimer(); void cmdSetTravel(); void cmdSetVideo(); - void CMDPLAYVID(); + void cmdPlayVideo(); void cmdPlotImage(); void cmdSetDisplay(); void cmdSetBuffer(); @@ -114,7 +114,7 @@ protected: void cmdClearBlock(); void cmdLoadSound(); void cmdSetVideoSound(); - void CMDPLAYVIDSND(); + void cmdPlayVideoSound(); void CMDPUSHLOCATION(); void cmdPlayerOff(); void cmdPlayerOn(); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index bdf8c224e4..2b8e6a7bf1 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -35,8 +35,6 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _music = nullptr; _musicRepeat = false; - _soundFrame = 0; - _soundFlag = false; } SoundManager::~SoundManager() { diff --git a/engines/access/sound.h b/engines/access/sound.h index 284fa845e7..a534eac79f 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -45,8 +45,6 @@ public: int _soundPriority[MAX_SOUNDS]; Resource *_music; bool _musicRepeat; - int _soundFrame; - bool _soundFlag; public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); diff --git a/engines/access/video.cpp b/engines/access/video.cpp index da397a4359..4c380ff915 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -27,10 +27,13 @@ namespace Access { VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _vidSurface = nullptr; + _videoFrame = 0; + _soundFlag = false; + _soundFrame = 0; } VideoPlayer::~VideoPlayer() { - freeVideo(); + closeVideo(); } @@ -55,37 +58,33 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId _frameCount = _header._frameCount - 2; _xCount = _header._width; _scanCount = _header._height; - _vidFrame = 0; + _videoFrame = 0; getFrame(); if (_header._flags == VIDEOFLAG_BG) { // Draw the background - const byte *pSrc = _vm->_plotBuffer; for (int y = 0; y < _scanCount; ++y) { byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y); - Common::copy(pSrc, pSrc + _xCount, pDest); - pSrc += _xCount; + _videoData->_stream->read(pDest, _xCount); } if (vidSurface == _vm->_screen) _vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount)); - - + getFrame(); } _videoEnd = false; } -void VideoPlayer::freeVideo() { +void VideoPlayer::closeVideo() { delete _videoData; _videoData = nullptr; } void VideoPlayer::getFrame() { _frameSize = _videoData->_stream->readUint16LE(); - _videoData->_stream->read(_vm->_plotBuffer, _frameSize); } void VideoPlayer::playVideo() { @@ -93,7 +92,39 @@ void VideoPlayer::playVideo() { return; ++_vm->_timers[31]._flag; + byte *pDest = _startCoord; + byte *pLine = _startCoord; + uint32 frameEnd = _videoData->_stream->pos() + _frameSize; + + while ((uint32)_videoData->_stream->pos() < frameEnd) { + int count = _videoData->_stream->readByte(); + + if (count & 0x80) { + count &= 0x7f; + + // Skip count number of pixels + // Loop across lines if necessary + while ((pDest - pLine + count) >= _xCount) { + pLine += _vidSurface->pitch; + pDest = pLine; + count -= _xCount; + } + + // Skip any remaining pixels in the new line + pDest += count; + } else { + // Readcount number of pixels + assert(count <= (pDest - pLine)); + _videoData->_stream->read(pDest, count); + pDest += count; + } + } + getFrame(); + if (++_videoFrame == _frameCount) { + closeVideo(); + _videoEnd = true; + } } diff --git a/engines/access/video.h b/engines/access/video.h index 7fa1ad2d27..20e5cfc10e 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -47,20 +47,32 @@ private: int _frameCount; int _xCount; int _scanCount; - int _vidFrame; int _frameSize; bool _videoEnd; void getFrame(); - - void playVideo(); +public: + int _videoFrame; + bool _soundFlag; + int _soundFrame; public: VideoPlayer(AccessEngine *vm); ~VideoPlayer(); + /** + * Start up a video + */ void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate); - void freeVideo(); + /** + * Decodes a frame of the video + */ + void playVideo(); + + /** + * Frees the data for a previously loaded video + */ + void closeVideo(); }; } // End of namespace Access |