From 08e642314e3e9f5645753a6fc99d41921e1a55f1 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 1 Jul 2017 23:01:02 +0200 Subject: MOHAWK: Check the Books external commands against the original --- engines/mohawk/riven_graphics.cpp | 7 +- engines/mohawk/riven_graphics.h | 2 +- engines/mohawk/riven_stack.cpp | 25 ++++++ engines/mohawk/riven_stack.h | 5 +- engines/mohawk/riven_stacks/aspit.cpp | 149 +++++++++++++++++----------------- engines/mohawk/riven_stacks/aspit.h | 6 +- engines/mohawk/riven_stacks/bspit.cpp | 25 ------ engines/mohawk/riven_stacks/bspit.h | 3 - engines/mohawk/riven_vars.cpp | 4 +- 9 files changed, 115 insertions(+), 111 deletions(-) diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp index f832d79dec..d152419661 100644 --- a/engines/mohawk/riven_graphics.cpp +++ b/engines/mohawk/riven_graphics.cpp @@ -26,6 +26,7 @@ #include "mohawk/riven_graphics.h" #include "mohawk/riven_sound.h" #include "mohawk/riven_stack.h" +#include "mohawk/riven_video.h" #include "common/system.h" #include "engines/util.h" @@ -324,11 +325,13 @@ void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uin applyScreenUpdate(); } -void RivenGraphics::updateScreen(const Common::Rect &updateRect) { +void RivenGraphics::updateScreen() { if (_dirtyScreen) { - // Copy to screen if there's no transition. Otherwise transition. ;) + // Copy to screen if there's no transition. Otherwise transition. if (_scheduledTransition == kRivenTransitionNone || _transitionMode == kRivenTransitionModeDisabled) { + const Common::Rect updateRect = Common::Rect(0, 0, 608, 392); + // mainScreen -> effectScreen -> systemScreen _effectScreen->copyRectToSurface(*_mainScreen, updateRect.left, updateRect.top, updateRect); _vm->_system->copyRectToScreen(_effectScreen->getBasePtr(updateRect.left, updateRect.top), _effectScreen->pitch, updateRect.left, updateRect.top, updateRect.width(), updateRect.height()); diff --git a/engines/mohawk/riven_graphics.h b/engines/mohawk/riven_graphics.h index 12dcfba826..bdc1a2a0c0 100644 --- a/engines/mohawk/riven_graphics.h +++ b/engines/mohawk/riven_graphics.h @@ -138,7 +138,7 @@ private: bool _dirtyScreen; Graphics::PixelFormat _pixelFormat; - void updateScreen(const Common::Rect &updateRect = Common::Rect(0, 0, 608, 392)); + void updateScreen(); void clearMainScreen(); // Credits diff --git a/engines/mohawk/riven_stack.cpp b/engines/mohawk/riven_stack.cpp index 6fa29912f8..79e1ba157c 100644 --- a/engines/mohawk/riven_stack.cpp +++ b/engines/mohawk/riven_stack.cpp @@ -350,6 +350,31 @@ void RivenStack::removeTimer() { _timerTime = 0; } +bool RivenStack::pageTurn(RivenTransition transition) { + // Wait until the previous page turn sound completes + while (_vm->_sound->isEffectPlaying() && !_vm->shouldQuit()) { + if (!mouseIsDown()) { + return false; + } + + _vm->doFrame(); + } + + // Play the page turning sound + const char *soundName = nullptr; + if (_vm->_rnd->getRandomBit()) + soundName = "aPage1"; + else + soundName = "aPage2"; + + _vm->_sound->playCardSound(soundName, 51, true); + + // Now update the screen :) + _vm->_gfx->scheduleTransition(transition); + + return true; +} + RivenNameList::RivenNameList() { } diff --git a/engines/mohawk/riven_stack.h b/engines/mohawk/riven_stack.h index 96bd07b04c..d4d7614749 100644 --- a/engines/mohawk/riven_stack.h +++ b/engines/mohawk/riven_stack.h @@ -29,6 +29,8 @@ #include "common/rect.h" #include "common/str-array.h" +#include "mohawk/riven_graphics.h" + namespace Mohawk { class MohawkEngine_Riven; @@ -153,11 +155,12 @@ public: // Common external commands void xflies(uint16 argc, uint16 *argv); // Start the "flies" effect - // TODO: Misc stuff move elsewhere + // Miscellaneous uint16 getComboDigit(uint32 correctCombo, uint32 digit); void runDemoBoundaryDialog(); void runEndGame(uint16 videoCode, uint32 delay); void runCredits(uint16 video, uint32 delay); + bool pageTurn(RivenTransition transition); protected: typedef Common::Functor2 ExternalCommand; diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp index 04173bb394..bf2adc0e8e 100644 --- a/engines/mohawk/riven_stacks/aspit.cpp +++ b/engines/mohawk/riven_stacks/aspit.cpp @@ -45,13 +45,13 @@ ASpit::ASpit(MohawkEngine_Riven *vm) : REGISTER_COMMAND(ASpit, xaatrusbookback); // Done REGISTER_COMMAND(ASpit, xaatrusbookprevpage); // Done REGISTER_COMMAND(ASpit, xaatrusbooknextpage); // Done -// REGISTER_COMMAND(ASpit, xacathopenbook); -// REGISTER_COMMAND(ASpit, xacathbookback); -// REGISTER_COMMAND(ASpit, xacathbookprevpage); -// REGISTER_COMMAND(ASpit, xacathbooknextpage); -// REGISTER_COMMAND(ASpit, xtrapbookback); -// REGISTER_COMMAND(ASpit, xatrapbookclose); -// REGISTER_COMMAND(ASpit, xatrapbookopen); + REGISTER_COMMAND(ASpit, xacathopenbook); + REGISTER_COMMAND(ASpit, xacathbookback); + REGISTER_COMMAND(ASpit, xacathbookprevpage); + REGISTER_COMMAND(ASpit, xacathbooknextpage); + REGISTER_COMMAND(ASpit, xtrapbookback); + REGISTER_COMMAND(ASpit, xatrapbookclose); + REGISTER_COMMAND(ASpit, xatrapbookopen); REGISTER_COMMAND(ASpit, xarestoregame); // Done // REGISTER_COMMAND(ASpit, xadisablemenureturn); // REGISTER_COMMAND(ASpit, xaenablemenureturn); @@ -77,7 +77,7 @@ void ASpit::xasetupcomplete(uint16 argc, uint16 *argv) { void ASpit::xaatrusopenbook(uint16 argc, uint16 *argv) { // Get the variable - uint32 &page = _vm->_vars["aatruspage"]; + uint32 &page = _vm->_vars["aatrusbook"]; // Set hotspots depending on the page RivenHotspot *openBook = _vm->getCard()->getHotspotByName("openBook"); @@ -101,34 +101,9 @@ void ASpit::xaatrusbookback(uint16 argc, uint16 *argv) { _vm->_inventory->backFromItemScript(); } -bool ASpit::pageTurn(RivenTransition transition) { - // Wait until the previous page turn sound completes - while (_vm->_sound->isEffectPlaying() && !_vm->shouldQuit()) { - if (!mouseIsDown()) { - return false; - } - - _vm->doFrame(); - } - - // Play the page turning sound - const char *soundName = nullptr; - if (_vm->_rnd->getRandomBit()) - soundName = "aPage1"; - else - soundName = "aPage2"; - - _vm->_sound->playCardSound(soundName, 51, true); - - // Now update the screen :) - _vm->_gfx->scheduleTransition(transition); - - return true; -} - void ASpit::xaatrusbookprevpage(uint16 argc, uint16 *argv) { // Get the page variable - uint32 &page = _vm->_vars["aatruspage"]; + uint32 &page = _vm->_vars["aatrusbook"]; // Keep turning pages while the mouse is pressed bool firstPageTurn = true; @@ -152,7 +127,7 @@ void ASpit::xaatrusbookprevpage(uint16 argc, uint16 *argv) { void ASpit::xaatrusbooknextpage(uint16 argc, uint16 *argv) { // Get the page variable - uint32 &page = _vm->_vars["aatruspage"]; + uint32 &page = _vm->_vars["aatrusbook"]; // Keep turning pages while the mouse is pressed bool firstPageTurn = true; @@ -176,7 +151,7 @@ void ASpit::xaatrusbooknextpage(uint16 argc, uint16 *argv) { void ASpit::xacathopenbook(uint16 argc, uint16 *argv) { // Get the variable - uint32 page = _vm->_vars["acathpage"]; + uint32 page = _vm->_vars["acathbook"]; // Set hotspots depending on the page RivenHotspot *openBook = _vm->getCard()->getHotspotByName("openBook"); @@ -192,7 +167,10 @@ void ASpit::xacathopenbook(uint16 argc, uint16 *argv) { openBook->enable(false); } - // Draw the image of the page + cathBookDrawPage(page); +} + +void ASpit::cathBookDrawPage(uint32 page) {// Draw the image of the page _vm->getCard()->drawPicture(page); // Draw the white page edges @@ -202,22 +180,25 @@ void ASpit::xacathopenbook(uint16 argc, uint16 *argv) { _vm->getCard()->drawPicture(51); if (page == 28) { - // 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->_vars["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++) { + cathBookDrawTelescopeCombination(); + } +} + +void ASpit::cathBookDrawTelescopeCombination() {// 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->_vars["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); } - } } void ASpit::xacathbookback(uint16 argc, uint16 *argv) { @@ -226,36 +207,52 @@ void ASpit::xacathbookback(uint16 argc, uint16 *argv) { void ASpit::xacathbookprevpage(uint16 argc, uint16 *argv) { // Get the variable - uint32 &page = _vm->_vars["acathpage"]; + uint32 &page = _vm->_vars["acathbook"]; + + // Keep turning pages while the mouse is pressed + bool firstPageTurn = true; + while (mouseIsDown() || firstPageTurn) { + // Check for the first page + if (page == 1) + return; - // Increment the page if it's not the first page - if (page == 1) - return; - page--; + if (!pageTurn(kRivenTransitionWipeDown)) { + return; + } - // Play the page turning sound - _vm->_sound->playSound(5); + // Update the page number + page--; + firstPageTurn = false; - // Now update the screen :) - _vm->_gfx->scheduleTransition(kRivenTransitionWipeDown); - _vm->getCard()->drawPicture(page); + cathBookDrawPage(page); + + _vm->doFrame(); + } } void ASpit::xacathbooknextpage(uint16 argc, uint16 *argv) { // Get the variable - uint32 &page = _vm->_vars["acathpage"]; + uint32 &page = _vm->_vars["acathbook"]; - // Increment the page if it's not the last page - if (page == 49) - return; - page++; + // Keep turning pages while the mouse is pressed + bool firstPageTurn = true; + while ((mouseIsDown() || firstPageTurn) && !_vm->shouldQuit()) { + // Check for the last page + if (page == 49) + return; - // Play the page turning sound - _vm->_sound->playSound(6); + if (!pageTurn(kRivenTransitionWipeUp)) { + return; + } - // Now update the screen :) - _vm->_gfx->scheduleTransition(kRivenTransitionWipeUp); - _vm->getCard()->drawPicture(page); + // Update the page number + page++; + firstPageTurn = false; + + cathBookDrawPage(page); + + _vm->doFrame(); + } } void ASpit::xtrapbookback(uint16 argc, uint16 *argv) { @@ -268,20 +265,24 @@ void ASpit::xatrapbookclose(uint16 argc, uint16 *argv) { // Close the trap book _vm->_vars["atrap"] = 0; - // Play the page turning sound - _vm->_sound->playSound(8); + pageTurn(kRivenTransitionWipeRight); + + // Stop the flyby movie to prevent a glitch where the book does not actually + // close because the movie continues to draw over the closed book picture. + // This glitch also happened in the original engine with transitions disabled. + RivenVideo *flyby = _vm->_video->getSlot(1); + flyby->close(); - _vm->refreshCard(); + _vm->getCard()->enter(false); } void ASpit::xatrapbookopen(uint16 argc, uint16 *argv) { // Open the trap book _vm->_vars["atrap"] = 1; - // Play the page turning sound - _vm->_sound->playSound(9); + pageTurn(kRivenTransitionWipeLeft); - _vm->refreshCard(); + _vm->getCard()->enter(false); } void ASpit::xarestoregame(uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/riven_stacks/aspit.h b/engines/mohawk/riven_stacks/aspit.h index 3ac3fa86e2..feeba6637c 100644 --- a/engines/mohawk/riven_stacks/aspit.h +++ b/engines/mohawk/riven_stacks/aspit.h @@ -25,8 +25,6 @@ #include "mohawk/riven_stack.h" -#include "mohawk/riven_graphics.h" - namespace Mohawk { namespace RivenStacks { @@ -71,7 +69,9 @@ public: void xaexittomain(uint16 argc, uint16 *argv); private: - bool pageTurn(RivenTransition transition); + void cathBookDrawTelescopeCombination(); + + void cathBookDrawPage(uint32 page); }; } // End of namespace RivenStacks diff --git a/engines/mohawk/riven_stacks/bspit.cpp b/engines/mohawk/riven_stacks/bspit.cpp index 53d0330880..dc412fe4a0 100644 --- a/engines/mohawk/riven_stacks/bspit.cpp +++ b/engines/mohawk/riven_stacks/bspit.cpp @@ -149,31 +149,6 @@ void BSpit::xblabbooknextpage(uint16 argc, uint16 *argv) { } } -bool BSpit::pageTurn(RivenTransition transition) { - // Wait until the previous page turn sound completes - while (_vm->_sound->isEffectPlaying() && !_vm->shouldQuit()) { - if (!mouseIsDown()) { - return false; - } - - _vm->doFrame(); - } - - // Play the page turning sound - const char *soundName = nullptr; - if (_vm->_rnd->getRandomBit()) - soundName = "aPage1"; - else - soundName = "aPage2"; - - _vm->_sound->playCardSound(soundName, 51, true); - - // Now update the screen :) - _vm->_gfx->scheduleTransition(transition); - - return true; -} - void BSpit::xsoundplug(uint16 argc, uint16 *argv) { if (_vm->_vars["bcratergg"] == 0) { if (_vm->_vars["bblrwtr"] == 0) { diff --git a/engines/mohawk/riven_stacks/bspit.h b/engines/mohawk/riven_stacks/bspit.h index fd11ba814d..d7ce1feea5 100644 --- a/engines/mohawk/riven_stacks/bspit.h +++ b/engines/mohawk/riven_stacks/bspit.h @@ -23,7 +23,6 @@ #ifndef RIVEN_STACKS_BSPIT_H #define RIVEN_STACKS_BSPIT_H -#include #include "mohawk/riven_stacks/domespit.h" namespace Mohawk { @@ -74,8 +73,6 @@ public: void valveChangePosition(uint32 valvePosition, uint16 videoId, uint16 pictureId); void labBookDrawDomeCombination() const; - - bool pageTurn(Mohawk::RivenTransition transition); }; } // End of namespace RivenStacks diff --git a/engines/mohawk/riven_vars.cpp b/engines/mohawk/riven_vars.cpp index 0bf61d4c12..093f491929 100644 --- a/engines/mohawk/riven_vars.cpp +++ b/engines/mohawk/riven_vars.cpp @@ -294,8 +294,8 @@ void MohawkEngine_Riven::initVars() { _vars["bblrwtr"] = 1; _vars["bfans"] = 1; _vars["bytrap"] = 2; - _vars["aatruspage"] = 1; - _vars["acathpage"] = 1; + _vars["aatrusbook"] = 1; + _vars["acathbook"] = 1; _vars["bheat"] = 1; _vars["blabpage"] = 1; _vars["waterenabled"] = 1; -- cgit v1.2.3