aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/graphics.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2010-11-17 19:58:19 +0000
committerMatthew Hoops2010-11-17 19:58:19 +0000
commitecb42156ce6f4530f3e5fcaec68544d2ab552565 (patch)
tree5eebbac24f3db0380b033a638fac0aabe95277dd /engines/mohawk/graphics.cpp
parent84a753d8409ba0dc9323b135bf730bff5dd39aa3 (diff)
downloadscummvm-rg350-ecb42156ce6f4530f3e5fcaec68544d2ab552565.tar.gz
scummvm-rg350-ecb42156ce6f4530f3e5fcaec68544d2ab552565.tar.bz2
scummvm-rg350-ecb42156ce6f4530f3e5fcaec68544d2ab552565.zip
MOHAWK: Cache the Myst screen buffer
This is needed for use with sliders. The screen is now updated fewer times as well. svn-id: r54300
Diffstat (limited to 'engines/mohawk/graphics.cpp')
-rw-r--r--engines/mohawk/graphics.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index e4f9a009fd..e0dce6369a 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -86,6 +86,11 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : _vm(vm) {
}
_pictureFile.entries = NULL;
+
+ // Initialize our buffer
+ _mainScreen = new Graphics::Surface();
+ _mainScreen->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel);
+ _dirtyScreen = false;
}
MystGraphics::~MystGraphics() {
@@ -93,6 +98,9 @@ MystGraphics::~MystGraphics() {
delete _jpegDecoder;
delete _pictDecoder;
delete[] _pictureFile.entries;
+
+ _mainScreen->free();
+ delete _mainScreen;
}
static const char* picFileNames[] = {
@@ -144,7 +152,6 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm
Graphics::Surface *surface = NULL;
-
// Myst ME uses JPEG/PICT images instead of compressed Windows Bitmaps for room images,
// though there are a few weird ones that use that format. For further nonsense with images,
// the Macintosh version stores images in external "picture files." We check them before
@@ -210,19 +217,30 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm
// 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);
+ for (uint16 i = 0; i < height; i++)
+ memcpy(_mainScreen->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel);
+
surface->free();
delete surface;
- }
- // FIXME: Remove this and update only at certain points
- _vm->_system->updateScreen();
+ // Mark the screen as dirty
+ _dirtyScreen = true;
+ }
}
void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) {
copyImageSectionToScreen(image, Common::Rect(0, 0, 544, 333), dest);
}
+void MystGraphics::updateScreen() {
+ if (_dirtyScreen) {
+ // Only copy the buffer to the screen if it's dirty
+ _vm->_system->copyRectToScreen((byte *)_mainScreen->pixels, _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h);
+ _vm->_system->updateScreen();
+ _dirtyScreen = false;
+ }
+}
+
void MystGraphics::showCursor(void) {
CursorMan.showMouse(true);
_vm->_needsUpdate = true;