aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/graphics.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2010-12-17 18:18:52 +0000
committerBastien Bouclet2010-12-17 18:18:52 +0000
commit7daea87e617198796220f5915b43fd27d57772e6 (patch)
tree5c07e7e7ffca6dbeb77d5f99c40fa012302f1cfd /engines/mohawk/graphics.cpp
parent8ec9f96d5478e3c06a7b240a86a537a391665b44 (diff)
downloadscummvm-rg350-7daea87e617198796220f5915b43fd27d57772e6.tar.gz
scummvm-rg350-7daea87e617198796220f5915b43fd27d57772e6.tar.bz2
scummvm-rg350-7daea87e617198796220f5915b43fd27d57772e6.zip
MOHAWK: Yet more Myst vertical alignment / clipping fixes.
Fixes the boiler wheels drawing incorrectly. Fixes the rocket piano's leftmost key drawing too high. Fixes the timeclock controls beeing misaligned. svn-id: r54947
Diffstat (limited to 'engines/mohawk/graphics.cpp')
-rw-r--r--engines/mohawk/graphics.cpp44
1 files changed, 28 insertions, 16 deletions
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index ed30cc25cf..29d8802a8a 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -354,12 +354,21 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm
if (dest.right > _vm->_system->getWidth() || dest.bottom > _vm->_system->getHeight())
dest.debugPrint(4, "Clipping destination rect to the screen:");
- dest.right = CLIP<int>(dest.right, 0, _vm->_system->getWidth());
- dest.bottom = CLIP<int>(dest.bottom, 0, _vm->_system->getHeight());
+ Graphics::Surface *surface = findImage(image)->getSurface();
- src.clip(_viewport);
+ // Make sure the image is bottom aligned in the dest rect
+ dest.top = dest.bottom - MIN<int>(surface->h, dest.height());
- Graphics::Surface *surface = findImage(image)->getSurface();
+ // Convert from bitmap coordinates to surface coordinates
+ uint16 top = surface->h - (src.top + MIN<int>(surface->h, dest.height()));
+
+ // Do not draw the top pixels if the image is too tall
+ if (dest.height() > _viewport.height()) {
+ top += dest.height() - _viewport.height();
+ }
+
+ dest.right = CLIP<int>(dest.right, 0, _vm->_system->getWidth());
+ dest.bottom = CLIP<int>(dest.bottom, 0, _vm->_system->getHeight());
debug(3, "Image Blit:");
debug(3, "src.x: %d", src.left);
@@ -372,9 +381,6 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm
uint16 width = MIN<int>(surface->w, dest.width());
uint16 height = MIN<int>(surface->h, dest.height());
- // Convert from bitmap coordinates to surface coordinates
- uint16 top = surface->h - src.top - height;
-
_vm->_system->copyRectToScreen((byte *)surface->getBasePtr(src.left, top), surface->pitch, dest.left, dest.top, width, height);
}
@@ -383,12 +389,21 @@ void MystGraphics::copyImageSectionToBackBuffer(uint16 image, Common::Rect src,
if (dest.right > _vm->_system->getWidth() || dest.bottom > _vm->_system->getHeight())
dest.debugPrint(4, "Clipping destination rect to the screen:");
- dest.right = CLIP<int>(dest.right, 0, _vm->_system->getWidth());
- dest.bottom = CLIP<int>(dest.bottom, 0, _vm->_system->getHeight());
+ Graphics::Surface *surface = findImage(image)->getSurface();
- src.clip(_viewport);
+ // Make sure the image is bottom aligned in the dest rect
+ dest.top = dest.bottom - MIN<int>(surface->h, dest.height());
- Graphics::Surface *surface = findImage(image)->getSurface();
+ // Convert from bitmap coordinates to surface coordinates
+ uint16 top = surface->h - (src.top + MIN<int>(surface->h, dest.height()));
+
+ // Do not draw the top pixels if the image is too tall
+ if (dest.height() > _viewport.height()) {
+ top += dest.height() - _viewport.height();
+ }
+
+ dest.right = CLIP<int>(dest.right, 0, _vm->_system->getWidth());
+ dest.bottom = CLIP<int>(dest.bottom, 0, _vm->_system->getHeight());
debug(3, "Image Blit:");
debug(3, "src.x: %d", src.left);
@@ -401,19 +416,16 @@ void MystGraphics::copyImageSectionToBackBuffer(uint16 image, Common::Rect src,
uint16 width = MIN<int>(surface->w, dest.width());
uint16 height = MIN<int>(surface->h, dest.height());
- // Convert from bitmap coordinates to surface coordinates
- uint16 top = surface->h - src.top - height;
-
for (uint16 i = 0; i < height; i++)
memcpy(_backBuffer->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel);
}
void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) {
- copyImageSectionToScreen(image, _viewport, dest);
+ copyImageSectionToScreen(image, Common::Rect(544, 333), dest);
}
void MystGraphics::copyImageToBackBuffer(uint16 image, Common::Rect dest) {
- copyImageSectionToBackBuffer(image, _viewport, dest);
+ copyImageSectionToBackBuffer(image, Common::Rect(544, 333), dest);
}
void MystGraphics::copyBackBufferToScreen(Common::Rect r) {