From ce9afcfab13bbbfe6ef5fe384a249a218067774a Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 19 Aug 2010 17:33:10 +0000 Subject: MOHAWK: Draw in the telescope combination in Catherine's journal svn-id: r52215 --- engines/mohawk/graphics.cpp | 17 ++++++++++++++++- engines/mohawk/graphics.h | 4 ++-- engines/mohawk/riven_external.cpp | 16 +++++++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) (limited to 'engines/mohawk') diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index 1974aec9c2..db11cb76a9 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -672,6 +672,21 @@ void RivenGraphics::drawRect(Common::Rect rect, bool active) { _vm->_system->unlockScreen(); } +void RivenGraphics::drawImageRect(uint16 id, Common::Rect srcRect, Common::Rect dstRect) { + // Draw tBMP id from srcRect to dstRect + ImageData *imageData = _bitmapDecoder->decodeImage(_vm->getRawData(ID_TBMP, id)); + Graphics::Surface *surface = imageData->getSurface(); + delete imageData; + + assert(srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height()); + + for (uint16 i = 0; i < srcRect.height(); i++) + memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(srcRect.left, i + srcRect.top), srcRect.width() * surface->bytesPerPixel); + + surface->free(); + delete surface; +} + LBGraphics::LBGraphics(MohawkEngine_LivingBooks *vm) : _vm(vm) { _bmpDecoder = (_vm->getGameType() == GType_LIVINGBOOKSV1) ? new OldMohawkBitmap() : new MohawkBitmap(); _palette = new byte[256 * 4]; @@ -707,7 +722,7 @@ void LBGraphics::copyImageToScreen(uint16 image, uint16 left, uint16 right) { } void LBGraphics::setPalette(uint16 id) { - // Old Living Books gamnes use the old CTBL-style palette format while newer + // Old Living Books games use the old CTBL-style palette format while newer // games use the better tPAL format which can store partial palettes. if (_vm->getGameType() == GType_LIVINGBOOKSV1) { diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h index dd1764e6d6..5670f6d071 100644 --- a/engines/mohawk/graphics.h +++ b/engines/mohawk/graphics.h @@ -117,7 +117,7 @@ private: uint16 type; uint16 width; uint16 height; - } *entries; + } *entries; Common::File picFile; } _pictureFile; @@ -147,6 +147,7 @@ public: Common::Array _activatedPLSTs; void drawPLST(uint16 x); void drawRect(Common::Rect rect, bool active); + void drawImageRect(uint16 id, Common::Rect srcRect, Common::Rect dstRect); // Water Effect void scheduleWaterEffect(uint16); @@ -181,7 +182,6 @@ private: Graphics::Surface *_mainScreen; bool _dirtyScreen; Graphics::PixelFormat _pixelFormat; - byte findBlackIndex(); }; class LBGraphics { diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp index 67d621a54c..4813ad5b33 100644 --- a/engines/mohawk/riven_external.cpp +++ b/engines/mohawk/riven_external.cpp @@ -340,7 +340,21 @@ void RivenExternal::xacathopenbook(uint16 argc, uint16 *argv) { _vm->_gfx->drawPLST(51); if (page == 28) { - // TODO: Draw telescope combination + // Draw the telescope combination + // The images for the numbers are tBMP's 13 through 17. + // The start point is at (156, 247) + uint32 teleCombo = *_vm->matchVarToString("tcorrectorder"); + static const uint16 kNumberWidth = 32; + static const uint16 kNumberHeight = 25; + static const uint16 kDstX = 156; + static const uint16 kDstY = 247; + + for (byte i = 0; i < 5; i++) { + uint16 offset = (getComboDigit(teleCombo, i) - 1) * kNumberWidth; + Common::Rect srcRect = Common::Rect(offset, 0, offset + kNumberWidth, kNumberHeight); + Common::Rect dstRect = Common::Rect(i * kNumberWidth + kDstX, kDstY, (i + 1) * kNumberWidth + kDstX, kDstY + kNumberHeight); + _vm->_gfx->drawImageRect(i + 13, srcRect, dstRect); + } } } -- cgit v1.2.3