aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2016-02-20 11:44:33 +0100
committerBastien Bouclet2016-02-20 14:00:59 +0100
commit84841fa635d90ae1936339b63ec675d62a4d84b9 (patch)
treed754145a57eb1725dabf0b2e7fc0864433bb4c8d /engines
parent406cc5a553989d7e6ff511eb47371b1d8ccf6dc9 (diff)
downloadscummvm-rg350-84841fa635d90ae1936339b63ec675d62a4d84b9.tar.gz
scummvm-rg350-84841fa635d90ae1936339b63ec675d62a4d84b9.tar.bz2
scummvm-rg350-84841fa635d90ae1936339b63ec675d62a4d84b9.zip
MOHAWK: Clip the videos to make sure they don't go outside of the screen
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/myst_areas.cpp6
-rw-r--r--engines/mohawk/video.cpp32
2 files changed, 28 insertions, 10 deletions
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 005ee2a6b6..59871ed49f 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -201,12 +201,6 @@ MystAreaVideo::MystAreaVideo(MohawkEngine_Myst *vm, Common::SeekableReadStream *
_loop = rlstStream->readUint16LE();
_playRate = rlstStream->readUint16LE();
- // TODO: Out of bound values should clip the movie
- if (_left < 0)
- _left = 0;
- if (_top < 0)
- _top = 0;
-
debugC(kDebugResource, "\tvideoFile: \"%s\"", _videoFile.c_str());
debugC(kDebugResource, "\tleft: %d", _left);
debugC(kDebugResource, "\ttop: %d", _top);
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index 31e8de77b1..522dd5ecdd 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -343,10 +343,34 @@ bool VideoManager::updateMovies() {
_vm->_system->getPaletteManager()->setPalette(video->getPalette(), 0, 256);
}
- // Clip the width/height to make sure we stay on the screen (Myst does this a few times)
- uint16 width = MIN<int32>(video->getWidth(), _vm->_system->getWidth() - (*it)->getX());
- uint16 height = MIN<int32>(video->getHeight(), _vm->_system->getHeight() - (*it)->getY());
- _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, (*it)->getX(), (*it)->getY(), width, height);
+ // Clip the video to make sure it stays on the screen (Myst does this a few times)
+ Common::Rect targetRect = Common::Rect(video->getWidth(), video->getHeight());
+ targetRect.translate((*it)->getX(), (*it)->getY());
+
+ Common::Rect frameRect = Common::Rect(video->getWidth(), video->getHeight());
+
+ if (targetRect.left < 0) {
+ frameRect.left -= targetRect.left;
+ targetRect.left = 0;
+ }
+
+ if (targetRect.top < 0) {
+ frameRect.top -= targetRect.top;
+ targetRect.top = 0;
+ }
+
+ if (targetRect.right > _vm->_system->getWidth()) {
+ frameRect.right -= targetRect.right - _vm->_system->getWidth();
+ targetRect.right = _vm->_system->getWidth();
+ }
+
+ if (targetRect.bottom > _vm->_system->getHeight()) {
+ frameRect.bottom -= targetRect.bottom - _vm->_system->getHeight();
+ targetRect.bottom = _vm->_system->getHeight();
+ }
+
+ _vm->_system->copyRectToScreen(frame->getBasePtr(frameRect.left, frameRect.top), frame->pitch,
+ targetRect.left, targetRect.top, targetRect.width(), targetRect.height());
// We've drawn something to the screen, make sure we update it
updateScreen = true;