diff options
Diffstat (limited to 'engines/mohawk/graphics.cpp')
-rw-r--r-- | engines/mohawk/graphics.cpp | 28 |
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; |