diff options
-rw-r--r-- | engines/gob/videoplayer.cpp | 16 | ||||
-rw-r--r-- | graphics/video/coktel_decoder.cpp | 18 | ||||
-rw-r--r-- | graphics/video/coktel_decoder.h | 6 |
3 files changed, 33 insertions, 7 deletions
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index 715d5cfb9a..d126d0e963 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -137,23 +137,29 @@ int VideoPlayer::openVideo(bool primary, const Common::String &file, Properties properties.sprite = -1; video->surface.reset(); video->decoder->setSurfaceMemory(); + video->decoder->setXY(0, 0); } else { video->surface = _vm->_draw->_spritesArray[properties.sprite]; video->decoder->setSurfaceMemory(video->surface->getVidMem(), video->surface->getWidth(), video->surface->getHeight(), 1); + + if (!ownSurf || (ownSurf && screenSize)) + video->decoder->setXY(properties.x, properties.y); + else + video->decoder->setXY(0, 0); } } else { properties.sprite = -1; video->surface.reset(); video->decoder->setSurfaceMemory(); + video->decoder->setXY(0, 0); } if (primary) _needBlit = (properties.flags & kFlagUseBackSurfaceContent) && (properties.sprite == Draw::kFrontSurface); // video->decoder->setFrameRate(_vm->_util->getFrameRate()); - // video->decoder->setXY(x, y); WRITE_VAR(7, video->decoder->getFrameCount()); @@ -306,14 +312,18 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) { if (properties.sprite == Draw::kBackSurface) { - _vm->_draw->invalidateRect(0, 0, video->decoder->getWidth(), video->decoder->getHeight()); + _vm->_draw->invalidateRect(properties.x, properties.y, + properties.x + video->decoder->getWidth(), + properties.y + video->decoder->getHeight()); _vm->_draw->blitInvalidated(); // if (!noRetrace) _vm->_video->retrace(); } else if (properties.sprite == Draw::kFrontSurface) { - _vm->_video->dirtyRectsAdd(0, 0, video->decoder->getWidth(), video->decoder->getHeight()); + _vm->_video->dirtyRectsAdd(properties.x, properties.y, + properties.x + video->decoder->getWidth(), + properties.y + video->decoder->getHeight()); // if (!noRetrace) _vm->_video->retrace(); diff --git a/graphics/video/coktel_decoder.cpp b/graphics/video/coktel_decoder.cpp index d13e678d44..6f846c9a07 100644 --- a/graphics/video/coktel_decoder.cpp +++ b/graphics/video/coktel_decoder.cpp @@ -34,7 +34,7 @@ CoktelDecoder::State::State() : left(0), top(0), right(0), bottom(0), flags(0), CoktelDecoder::CoktelDecoder(Audio::Mixer &mixer, Audio::Mixer::SoundType soundType) : - _mixer(&mixer), _soundType(soundType), _width(0), _height(0), _frameCount(0), + _mixer(&mixer), _soundType(soundType), _width(0), _height(0), _x(0), _y(0), _frameCount(0), _paletteDirty(false), _ownSurface(true) { memset(_palette, 0, 768); @@ -92,8 +92,18 @@ void CoktelDecoder::freeSurface() { _ownSurface = true; } +void CoktelDecoder::setXY(uint16 x, uint16 y) { + _x = x; + _y = y; +} + void CoktelDecoder::close() { freeSurface(); + + _x = 0; + _y = 0; + + _frameCount = 0; } uint16 CoktelDecoder::getWidth() const { @@ -289,11 +299,11 @@ void PreIMDDecoder::processFrame() { } void PreIMDDecoder::renderFrame() { - uint16 w = MIN<uint16>(_surface.w, _width); - uint16 h = MIN<uint16>(_surface.h, _height); + uint16 w = CLIP<int32>(_surface.w - _x, 0, _width); + uint16 h = CLIP<int32>(_surface.h - _y, 0, _height); const byte *src = _videoBuffer; - byte *dst = (byte *) _surface.pixels; // + x/y + byte *dst = (byte *) _surface.pixels + (_y * _surface.pitch) + _x; uint32 frameDataSize = _videoBufferSize; diff --git a/graphics/video/coktel_decoder.h b/graphics/video/coktel_decoder.h index ec9acbe879..a4d12c5294 100644 --- a/graphics/video/coktel_decoder.h +++ b/graphics/video/coktel_decoder.h @@ -69,6 +69,9 @@ public: /** Reset the video memory. */ void setSurfaceMemory(); + /** Draw the video starting at this position within the video memory. */ + void setXY(uint16 x, uint16 y); + // VideoDecoder interface void close(); @@ -88,6 +91,9 @@ protected: uint16 _width; uint16 _height; + uint16 _x; + uint16 _y; + uint32 _frameCount; byte _palette[768]; |