aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mohawk/graphics.cpp')
-rw-r--r--engines/mohawk/graphics.cpp153
1 files changed, 102 insertions, 51 deletions
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index 1974aec9c2..f472a9d721 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -326,7 +326,7 @@ void RivenGraphics::drawPLST(uint16 x) {
// draw PLST 1 each time. This "hack" is here to catch any PLST attempting to draw
// twice. There should never be a problem with doing it this way.
if (index == x && !(Common::find(_activatedPLSTs.begin(), _activatedPLSTs.end(), x) != _activatedPLSTs.end())) {
- debug (0, "Drawing image %d", id);
+ debug(0, "Drawing image %d", id);
copyImageToScreen(id, left, top, right, bottom);
_activatedPLSTs.push_back(x);
break;
@@ -399,7 +399,7 @@ void RivenGraphics::clearWaterEffects() {
bool RivenGraphics::runScheduledWaterEffects() {
// Don't run the effect if it's disabled
- if (*_vm->matchVarToString("waterenabled") == 0)
+ if (*_vm->getVar("waterenabled") == 0)
return false;
Graphics::Surface *screen = NULL;
@@ -491,95 +491,106 @@ void RivenGraphics::runScheduledTransition() {
_scheduledTransition = -1; // Clear scheduled transition
}
-// TODO: Marble Cursors/Palettes
void RivenGraphics::changeCursor(uint16 num) {
// All of Riven's cursors are hardcoded. See riven_cursors.h for these definitions.
switch (num) {
case 1002:
// Zip Mode
- CursorMan.replaceCursor(zipModeCursor, 16, 16, 8, 8, 0);
- CursorMan.replaceCursorPalette(zipModeCursorPalette, 1, ARRAYSIZE(zipModeCursorPalette) / 4);
+ CursorMan.replaceCursor(s_zipModeCursor, 16, 16, 8, 8, 0);
+ CursorMan.replaceCursorPalette(s_zipModeCursorPalette, 1, ARRAYSIZE(s_zipModeCursorPalette) / 4);
break;
case 2003:
// Hand Over Object
- CursorMan.replaceCursor(objectHandCursor, 16, 16, 8, 8, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_objectHandCursor, 16, 16, 8, 8, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 2004:
// Grabbing/Using Object
- CursorMan.replaceCursor(grabbingHandCursor, 13, 13, 6, 6, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_grabbingHandCursor, 13, 13, 6, 6, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 3000:
// Standard Hand
- CursorMan.replaceCursor(standardHandCursor, 15, 16, 6, 0, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_standardHandCursor, 15, 16, 6, 0, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 3001:
// Pointing Left
- CursorMan.replaceCursor(pointingLeftCursor, 15, 13, 0, 3, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_pointingLeftCursor, 15, 13, 0, 3, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 3002:
// Pointing Right
- CursorMan.replaceCursor(pointingRightCursor, 15, 13, 14, 3, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_pointingRightCursor, 15, 13, 14, 3, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 3003:
// Pointing Down (Palm Up)
- CursorMan.replaceCursor(pointingDownCursorPalmUp, 13, 16, 3, 15, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_pointingDownCursorPalmUp, 13, 16, 3, 15, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 3004:
// Pointing Up (Palm Up)
- CursorMan.replaceCursor(pointingUpCursorPalmUp, 13, 16, 3, 0, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_pointingUpCursorPalmUp, 13, 16, 3, 0, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 3005:
// Pointing Left (Curved)
- CursorMan.replaceCursor(pointingLeftCursorBent, 15, 13, 0, 5, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_pointingLeftCursorBent, 15, 13, 0, 5, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 3006:
// Pointing Right (Curved)
- CursorMan.replaceCursor(pointingRightCursorBent, 15, 13, 14, 5, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_pointingRightCursorBent, 15, 13, 14, 5, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 3007:
// Pointing Down (Palm Down)
- CursorMan.replaceCursor(pointingDownCursorPalmDown, 15, 16, 7, 15, 0);
- CursorMan.replaceCursorPalette(handCursorPalette, 1, ARRAYSIZE(handCursorPalette) / 4);
+ CursorMan.replaceCursor(s_pointingDownCursorPalmDown, 15, 16, 7, 15, 0);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
break;
case 4001:
// Red Marble
+ CursorMan.replaceCursor(s_redMarbleCursor, 12, 12, 5, 5, 0);
+ CursorMan.replaceCursorPalette(s_redMarbleCursorPalette, 1, ARRAYSIZE(s_redMarbleCursorPalette) / 4);
break;
case 4002:
// Orange Marble
+ CursorMan.replaceCursor(s_orangeMarbleCursor, 12, 12, 5, 5, 0);
+ CursorMan.replaceCursorPalette(s_orangeMarbleCursorPalette, 1, ARRAYSIZE(s_orangeMarbleCursorPalette) / 4);
break;
case 4003:
// Yellow Marble
+ CursorMan.replaceCursor(s_yellowMarbleCursor, 12, 12, 5, 5, 0);
+ CursorMan.replaceCursorPalette(s_yellowMarbleCursorPalette, 1, ARRAYSIZE(s_yellowMarbleCursorPalette) / 4);
break;
case 4004:
// Green Marble
+ CursorMan.replaceCursor(s_greenMarbleCursor, 12, 12, 5, 5, 0);
+ CursorMan.replaceCursorPalette(s_greenMarbleCursorPalette, 1, ARRAYSIZE(s_greenMarbleCursorPalette) / 4);
break;
case 4005:
// Blue Marble
+ CursorMan.replaceCursor(s_blueMarbleCursor, 12, 12, 5, 5, 0);
+ CursorMan.replaceCursorPalette(s_blueMarbleCursorPalette, 1, ARRAYSIZE(s_blueMarbleCursorPalette) / 4);
break;
case 4006:
- // Purple Marble
+ // Violet Marble
+ CursorMan.replaceCursor(s_violetMarbleCursor, 12, 12, 5, 5, 0);
+ CursorMan.replaceCursorPalette(s_violetMarbleCursorPalette, 1, ARRAYSIZE(s_violetMarbleCursorPalette) / 4);
break;
case 5000:
// Pellet
- CursorMan.replaceCursor(pelletCursor, 8, 8, 4, 4, 0);
- CursorMan.replaceCursorPalette(pelletCursorPalette, 1, ARRAYSIZE(pelletCursorPalette) / 4);
+ CursorMan.replaceCursor(s_pelletCursor, 8, 8, 4, 4, 0);
+ CursorMan.replaceCursorPalette(s_pelletCursorPalette, 1, ARRAYSIZE(s_pelletCursorPalette) / 4);
break;
case 9000:
// Hide Cursor
CursorMan.showMouse(false);
break;
default:
- error ("Cursor %d does not exist!", num);
+ error("Cursor %d does not exist!", num);
}
if (num != 9000) // Show Cursor
@@ -597,28 +608,35 @@ void RivenGraphics::showInventory() {
// Clear the inventory area
clearInventoryArea();
- // The demo doesn't have the inventory system and we don't want
- // to show the inventory on setup screens or in other journals.
- if (_vm->getFeatures() & GF_DEMO || _vm->getCurStack() == aspit)
- return;
-
- // There are three books and three vars. We have three different
- // combinations. At the start you have just Atrus' journal. Later,
- // you get Catherine's journal and the trap book. Near the end,
- // you lose the trap book and have just the two journals.
-
- bool hasCathBook = *_vm->matchVarToString("acathbook") != 0;
- bool hasTrapBook = *_vm->matchVarToString("atrapbook") != 0;
-
- if (!hasCathBook) {
- drawInventoryImage(101, g_atrusJournalRect1);
- } else if (!hasTrapBook) {
- drawInventoryImage(101, g_atrusJournalRect2);
- drawInventoryImage(102, g_cathJournalRect2);
+ // Draw the demo's exit button
+ if (_vm->getFeatures() & GF_DEMO) {
+ // extras.mhk tBMP 101 contains "EXIT" instead of Atrus' journal in the demo!
+ // The demo's extras.mhk contains all the other inventory/marble/credits image
+ // but has hacked tBMP 101 with "EXIT". *sigh*
+ drawInventoryImage(101, g_demoExitRect);
} else {
- drawInventoryImage(101, g_atrusJournalRect3);
- drawInventoryImage(102, g_cathJournalRect3);
- drawInventoryImage(100, g_trapBookRect3);
+ // We don't want to show the inventory on setup screens or in other journals.
+ if (_vm->getCurStack() == aspit)
+ return;
+
+ // There are three books and three vars. We have three different
+ // combinations. At the start you have just Atrus' journal. Later,
+ // you get Catherine's journal and the trap book. Near the end,
+ // you lose the trap book and have just the two journals.
+
+ bool hasCathBook = *_vm->getVar("acathbook") != 0;
+ bool hasTrapBook = *_vm->getVar("atrapbook") != 0;
+
+ if (!hasCathBook) {
+ drawInventoryImage(101, g_atrusJournalRect1);
+ } else if (!hasTrapBook) {
+ drawInventoryImage(101, g_atrusJournalRect2);
+ drawInventoryImage(102, g_cathJournalRect2);
+ } else {
+ drawInventoryImage(101, g_atrusJournalRect3);
+ drawInventoryImage(102, g_cathJournalRect3);
+ drawInventoryImage(100, g_trapBookRect3);
+ }
}
_vm->_system->updateScreen();
@@ -672,6 +690,39 @@ 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;
+
+ _dirtyScreen = true;
+}
+
+void RivenGraphics::drawExtrasImage(uint16 id, Common::Rect dstRect) {
+ ImageData *imageData = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id));
+ Graphics::Surface *surface = imageData->getSurface();
+ delete imageData;
+
+ assert(dstRect.width() == surface->w);
+
+ for (uint16 i = 0; i < surface->h; i++)
+ memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(0, i), surface->pitch);
+
+ surface->free();
+ delete surface;
+
+ _dirtyScreen = true;
+}
+
LBGraphics::LBGraphics(MohawkEngine_LivingBooks *vm) : _vm(vm) {
_bmpDecoder = (_vm->getGameType() == GType_LIVINGBOOKSV1) ? new OldMohawkBitmap() : new MohawkBitmap();
_palette = new byte[256 * 4];
@@ -707,7 +758,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) {