MOHAWK: Implement most of Myst's transition system

This commit is contained in:
Bastien Bouclet 2012-12-15 11:49:41 +01:00
parent 0358a44738
commit 07ee25c87d
17 changed files with 332 additions and 82 deletions

View file

@ -75,7 +75,7 @@ bool MystConsole::Cmd_ChangeCard(int argc, const char **argv) {
} }
_vm->_sound->stopSound(); _vm->_sound->stopSound();
_vm->changeToCard((uint16)atoi(argv[1]), true); _vm->changeToCard((uint16)atoi(argv[1]), kTransitionCopy);
return false; return false;
} }

View file

@ -523,7 +523,7 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
_video->playMovieBlockingCentered(wrapMovieFilename(flyby, kMasterpieceOnly)); _video->playMovieBlockingCentered(wrapMovieFilename(flyby, kMasterpieceOnly));
} }
changeToCard(card, true); changeToCard(card, kTransitionCopy);
if (linkDstSound) if (linkDstSound)
_sound->playSoundBlocking(linkDstSound); _sound->playSoundBlocking(linkDstSound);
@ -549,7 +549,7 @@ void MohawkEngine_Myst::drawCardBackground() {
_gfx->copyImageToBackBuffer(getCardBackgroundId(), Common::Rect(0, 0, 544, 332)); _gfx->copyImageToBackBuffer(getCardBackgroundId(), Common::Rect(0, 0, 544, 332));
} }
void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) { void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
debug(2, "changeToCard(%d)", card); debug(2, "changeToCard(%d)", card);
_scriptParser->disablePersistentScripts(); _scriptParser->disablePersistentScripts();
@ -629,9 +629,11 @@ void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) {
} }
// Make sure the screen is updated // Make sure the screen is updated
if (updateScreen) { if (transition != kNoTransition) {
_gfx->copyBackBufferToScreen(Common::Rect(544, 333)); if (!_gameState->_globals.transitions)
_system->updateScreen(); transition = kTransitionCopy;
_gfx->runTransition(transition, Common::Rect(544, 333), 10, 0);
} }
// Make sure we have the right cursor showing // Make sure we have the right cursor showing

View file

@ -75,6 +75,20 @@ enum {
kStoneshipStack // Stoneship Age kStoneshipStack // Stoneship Age
}; };
// Transitions
enum TransitionType {
kTransitionLeftToRight = 0,
kTransitionRightToLeft = 1,
kTransitionUnk2 = 2,
kTransitionDissolve = 4,
kTransitionTopToBottom = 5,
kTransitionBottomToTop = 6,
kTransitionPartToRight = 9,
kTransitionPartToLeft = 10,
kTransitionCopy = 11,
kNoTransition = 999
};
const uint16 kMasterpieceOnly = 0xFFFF; const uint16 kMasterpieceOnly = 0xFFFF;
struct MystCondition { struct MystCondition {
@ -154,7 +168,7 @@ public:
void reloadSaveList(); void reloadSaveList();
void changeToStack(uint16 stack, uint16 card, uint16 linkSrcSound, uint16 linkDstSound); void changeToStack(uint16 stack, uint16 card, uint16 linkSrcSound, uint16 linkDstSound);
void changeToCard(uint16 card, bool updateScreen); void changeToCard(uint16 card, TransitionType transition);
uint16 getCurCard() { return _curCard; } uint16 getCurCard() { return _curCard; }
uint16 getCurStack() { return _curStack; } uint16 getCurStack() { return _curStack; }
void setMainCursor(uint16 cursor); void setMainCursor(uint16 cursor);

View file

@ -70,10 +70,30 @@ MystResource::~MystResource() {
} }
void MystResource::handleMouseUp() { void MystResource::handleMouseUp() {
if (_dest != 0) if (_dest == 0) {
_vm->changeToCard(_dest, true);
else
warning("Movement type resource with null destination at position (%d, %d), (%d, %d)", _rect.left, _rect.top, _rect.right, _rect.bottom); warning("Movement type resource with null destination at position (%d, %d), (%d, %d)", _rect.left, _rect.top, _rect.right, _rect.bottom);
return;
}
uint16 opcode;
switch (type) {
case kMystForwardArea:
opcode = 6;
break;
case kMystLeftArea:
opcode = 8;
break;
case kMystRightArea:
opcode = 7;
break;
default:
opcode = 48;
break;
}
_vm->_scriptParser->setInvokingResource(this);
_vm->_scriptParser->runOpcode(opcode, 0);
} }
bool MystResource::canBecomeActive() { bool MystResource::canBecomeActive() {

View file

@ -209,14 +209,14 @@ void MystGraphics::copyBackBufferToScreen(Common::Rect r) {
_vm->_system->copyRectToScreen(_backBuffer->getBasePtr(r.left, r.top), _backBuffer->pitch, r.left, r.top, r.width(), r.height()); _vm->_system->copyRectToScreen(_backBuffer->getBasePtr(r.left, r.top), _backBuffer->pitch, r.left, r.top, r.width(), r.height());
} }
void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, uint16 delay) { void MystGraphics::runTransition(TransitionType type, Common::Rect rect, uint16 steps, uint16 delay) {
// Do not artificially delay during transitions // Do not artificially delay during transitions
int oldEnableDrawingTimeSimulation = _enableDrawingTimeSimulation; int oldEnableDrawingTimeSimulation = _enableDrawingTimeSimulation;
_enableDrawingTimeSimulation = 0; _enableDrawingTimeSimulation = 0;
switch (type) { switch (type) {
case 0: { case kTransitionLeftToRight: {
debugC(kDebugScript, "Left to Right"); debugC(kDebugScript, "Left to Right");
uint16 step = (rect.right - rect.left) / steps; uint16 step = (rect.right - rect.left) / steps;
@ -239,7 +239,7 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
} }
} }
break; break;
case 1: { case kTransitionRightToLeft: {
debugC(kDebugScript, "Right to Left"); debugC(kDebugScript, "Right to Left");
uint16 step = (rect.right - rect.left) / steps; uint16 step = (rect.right - rect.left) / steps;
@ -262,7 +262,16 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
} }
} }
break; break;
case 5: { case kTransitionDissolve: {
debugC(kDebugScript, "Dissolve");
for (int16 step = 0; step < 8; step++) {
simulatePreviousDrawDelay(rect);
transitionDissolve(rect, step);
}
}
break;
case kTransitionTopToBottom: {
debugC(kDebugScript, "Top to Bottom"); debugC(kDebugScript, "Top to Bottom");
uint16 step = (rect.bottom - rect.top) / steps; uint16 step = (rect.bottom - rect.top) / steps;
@ -285,7 +294,7 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
} }
} }
break; break;
case 6: { case kTransitionBottomToTop: {
debugC(kDebugScript, "Bottom to Top"); debugC(kDebugScript, "Bottom to Top");
uint16 step = (rect.bottom - rect.top) / steps; uint16 step = (rect.bottom - rect.top) / steps;
@ -308,10 +317,23 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
} }
} }
break; break;
default: case kTransitionPartToRight: {
warning("Unknown Update Direction"); debugC(kDebugScript, "Partial left to right");
transitionPartialToRight(rect, 75, 3);
}
break;
case kTransitionPartToLeft: {
debugC(kDebugScript, "Partial right to left");
transitionPartialToLeft(rect, 75, 3);
}
break;
default:
//TODO: Replace minimal implementation //TODO: Replace minimal implementation
warning("Unknown transition %d", type);
// Fallthrough
case kTransitionCopy:
copyBackBufferToScreen(rect); copyBackBufferToScreen(rect);
_vm->_system->updateScreen(); _vm->_system->updateScreen();
break; break;
@ -320,6 +342,130 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
_enableDrawingTimeSimulation = oldEnableDrawingTimeSimulation; _enableDrawingTimeSimulation = oldEnableDrawingTimeSimulation;
} }
void MystGraphics::transitionDissolve(Common::Rect rect, uint step) {
static const bool pattern[][4][4] = {
{
{ true, false, false, false },
{ false, false, false, false },
{ false, false, true, false },
{ false, false, false, false }
},
{
{ false, false, true, false },
{ false, false, false, false },
{ true, false, false, false },
{ false, false, false, false }
},
{
{ false, false, false, false },
{ false, true, false, false },
{ false, false, false, false },
{ false, false, false, true }
},
{
{ false, false, false, false },
{ false, false, false, true },
{ false, false, false, false },
{ false, true, false, false }
},
{
{ false, false, false, false },
{ false, false, true, false },
{ false, true, false, false },
{ false, false, false, false }
},
{
{ false, true, false, false },
{ false, false, false, false },
{ false, false, false, false },
{ false, false, true, false }
},
{
{ false, false, false, false },
{ true, false, false, false },
{ false, false, false, true },
{ false, false, false, false }
},
{
{ false, false, false, true },
{ false, false, false, false },
{ false, false, false, false },
{ true, false, false, false }
}
};
rect.clip(_viewport);
Graphics::Surface *screen = _vm->_system->lockScreen();
for (uint16 y = rect.top; y < rect.bottom; y++) {
const bool *linePattern = pattern[step][y % 4];
if (!linePattern[0] && !linePattern[1] && !linePattern[2] && !linePattern[3])
continue;
for (uint16 x = rect.left; x < rect.right; x++) {
if (linePattern[x % 4]) {
if (_pixelFormat.bytesPerPixel == 2) {
uint16 *dst = (uint16 *)screen->getBasePtr(x, y);
*dst = *(const uint16 *)_backBuffer->getBasePtr(x, y);
} else {
uint32 *dst = (uint32 *)screen->getBasePtr(x, y);
*dst = *(const uint32 *)_backBuffer->getBasePtr(x, y);
}
}
}
}
_vm->_system->unlockScreen();
_vm->_system->updateScreen();
}
void MystGraphics::transitionPartialToRight(Common::Rect rect, uint32 width, uint32 steps)
{
rect.clip(_viewport);
uint32 stepWidth = width / steps;
Common::Rect srcRect = Common::Rect(rect.right, rect.top, rect.right, rect.bottom);
Common::Rect dstRect = Common::Rect(rect.left, rect.top, rect.left, rect.bottom);
for (uint step = 1; step <= steps; step++) {
dstRect.right = dstRect.left + step * stepWidth;
srcRect.left = srcRect.right - step * stepWidth;
simulatePreviousDrawDelay(dstRect);
_vm->_system->copyRectToScreen(_backBuffer->getBasePtr(dstRect.left, dstRect.top),
_backBuffer->pitch, srcRect.left, srcRect.top, srcRect.width(), srcRect.height());
_vm->_system->updateScreen();
}
copyBackBufferToScreen(rect);
_vm->_system->updateScreen();
}
void MystGraphics::transitionPartialToLeft(Common::Rect rect, uint32 width, uint32 steps)
{
rect.clip(_viewport);
uint32 stepWidth = width / steps;
Common::Rect srcRect = Common::Rect(rect.left, rect.top, rect.left, rect.bottom);
Common::Rect dstRect = Common::Rect(rect.right, rect.top, rect.right, rect.bottom);
for (uint step = 1; step <= steps; step++) {
dstRect.left = dstRect.right - step * stepWidth;
srcRect.right = srcRect.left + step * stepWidth;
simulatePreviousDrawDelay(dstRect);
_vm->_system->copyRectToScreen(_backBuffer->getBasePtr(dstRect.left, dstRect.top),
_backBuffer->pitch, srcRect.left, srcRect.top, srcRect.width(), srcRect.height());
_vm->_system->updateScreen();
}
copyBackBufferToScreen(rect);
_vm->_system->updateScreen();
}
void MystGraphics::drawRect(Common::Rect rect, RectState state) { void MystGraphics::drawRect(Common::Rect rect, RectState state) {
rect.clip(_viewport); rect.clip(_viewport);

View file

@ -48,7 +48,7 @@ public:
void copyImageToScreen(uint16 image, Common::Rect dest); void copyImageToScreen(uint16 image, Common::Rect dest);
void copyImageToBackBuffer(uint16 image, Common::Rect dest); void copyImageToBackBuffer(uint16 image, Common::Rect dest);
void copyBackBufferToScreen(Common::Rect r); void copyBackBufferToScreen(Common::Rect r);
void runTransition(uint16 type, Common::Rect rect, uint16 steps, uint16 delay); void runTransition(TransitionType type, Common::Rect rect, uint16 steps, uint16 delay);
void drawRect(Common::Rect rect, RectState state); void drawRect(Common::Rect rect, RectState state);
void drawLine(const Common::Point &p1, const Common::Point &p2, uint32 color); void drawLine(const Common::Point &p1, const Common::Point &p2, uint32 color);
void enableDrawingTimeSimulation(bool enable); void enableDrawingTimeSimulation(bool enable);
@ -60,7 +60,9 @@ protected:
MohawkEngine *getVM() { return (MohawkEngine *)_vm; } MohawkEngine *getVM() { return (MohawkEngine *)_vm; }
void simulatePreviousDrawDelay(const Common::Rect &dest); void simulatePreviousDrawDelay(const Common::Rect &dest);
void copyBackBufferToScreenWithSaturation(int16 saturation); void copyBackBufferToScreenWithSaturation(int16 saturation);
void transitionDissolve(Common::Rect rect, uint step);
void transitionPartialToRight(Common::Rect rect, uint32 width, uint32 steps);
void transitionPartialToLeft(Common::Rect rect, uint32 width, uint32 steps);
private: private:
MohawkEngine_Myst *_vm; MohawkEngine_Myst *_vm;
MystBitmap *_bmpDecoder; MystBitmap *_bmpDecoder;

View file

@ -100,18 +100,18 @@ void MystScriptParser::setupCommonOpcodes() {
// "Standard" Opcodes // "Standard" Opcodes
OPCODE(0, o_toggleVar); OPCODE(0, o_toggleVar);
OPCODE(1, o_setVar); OPCODE(1, o_setVar);
OPCODE(2, o_changeCardSwitch); OPCODE(2, o_changeCardSwitch4);
OPCODE(3, o_takePage); OPCODE(3, o_takePage);
OPCODE(4, o_redrawCard); OPCODE(4, o_redrawCard);
// Opcode 5 Not Present // Opcode 5 Not Present
OPCODE(6, o_goToDest); OPCODE(6, o_goToDestForward);
OPCODE(7, o_goToDest); OPCODE(7, o_goToDestLeft);
OPCODE(8, o_goToDest); OPCODE(8, o_goToDestRight);
OPCODE(9, o_triggerMovie); OPCODE(9, o_triggerMovie);
OPCODE(10, o_toggleVarNoRedraw); OPCODE(10, o_toggleVarNoRedraw);
// Opcode 11 Not Present // Opcode 11 Not Present
OPCODE(12, o_changeCardSwitch); OPCODE(12, o_changeCardSwitchLtR);
OPCODE(13, o_changeCardSwitch); OPCODE(13, o_changeCardSwitchRtL);
OPCODE(14, o_drawAreaState); OPCODE(14, o_drawAreaState);
OPCODE(15, o_redrawAreaForVar); OPCODE(15, o_redrawAreaForVar);
OPCODE(16, o_changeCardDirectional); OPCODE(16, o_changeCardDirectional);
@ -120,7 +120,7 @@ void MystScriptParser::setupCommonOpcodes() {
OPCODE(19, o_enableAreas); OPCODE(19, o_enableAreas);
OPCODE(20, o_disableAreas); OPCODE(20, o_disableAreas);
OPCODE(21, o_directionalUpdate); OPCODE(21, o_directionalUpdate);
OPCODE(22, o_goToDest); OPCODE(22, o_goToDestUp);
OPCODE(23, o_toggleAreasActivation); OPCODE(23, o_toggleAreasActivation);
OPCODE(24, o_playSound); OPCODE(24, o_playSound);
// Opcode 25 is unused; original calls replaceSoundMyst // Opcode 25 is unused; original calls replaceSoundMyst
@ -145,6 +145,7 @@ void MystScriptParser::setupCommonOpcodes() {
OPCODE(44, o_restoreMainCursor); OPCODE(44, o_restoreMainCursor);
// Opcode 45 Not Present // Opcode 45 Not Present
OPCODE(46, o_soundWaitStop); OPCODE(46, o_soundWaitStop);
OPCODE(48, o_goToDest);
OPCODE(51, o_exitMap); OPCODE(51, o_exitMap);
// Opcodes 47 to 99 Not Present // Opcodes 47 to 99 Not Present
@ -273,7 +274,7 @@ void MystScriptParser::animatedUpdate(uint16 argc, uint16 *argv, uint16 delay) {
while (argsRead < argc) { while (argsRead < argc) {
Common::Rect rect = Common::Rect(argv[argsRead], argv[argsRead + 1], argv[argsRead + 2], argv[argsRead + 3]); Common::Rect rect = Common::Rect(argv[argsRead], argv[argsRead + 1], argv[argsRead + 2], argv[argsRead + 3]);
uint16 kind = argv[argsRead + 4]; TransitionType kind = static_cast<TransitionType>(argv[argsRead + 4]);
uint16 steps = argv[argsRead + 5]; uint16 steps = argv[argsRead + 5];
debugC(kDebugScript, "\trect.left: %d", rect.left); debugC(kDebugScript, "\trect.left: %d", rect.left);
@ -323,16 +324,41 @@ void MystScriptParser::o_setVar(uint16 op, uint16 var, uint16 argc, uint16 *argv
_vm->redrawArea(var); _vm->redrawArea(var);
} }
void MystScriptParser::o_changeCardSwitch(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void MystScriptParser::o_changeCardSwitch4(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Opcodes 2, 12, and 13 are the same
uint16 value = getVar(var); uint16 value = getVar(var);
debugC(kDebugScript, "Opcode %d: changeCardSwitch var %d: %d", op, var, value); debugC(kDebugScript, "Opcode %d: changeCardSwitch var %d: %d", op, var, value);
if (value) if (value)
_vm->changeToCard(argv[value -1 ], true); _vm->changeToCard(argv[value -1 ], kTransitionDissolve);
else if (_invokingResource != NULL) else if (_invokingResource != NULL)
_vm->changeToCard(_invokingResource->getDest(), true); _vm->changeToCard(_invokingResource->getDest(), kTransitionDissolve);
else
warning("Missing invokingResource in altDest call");
}
void MystScriptParser::o_changeCardSwitchLtR(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
uint16 value = getVar(var);
debugC(kDebugScript, "Opcode %d: changeCardSwitch var %d: %d", op, var, value);
if (value)
_vm->changeToCard(argv[value -1 ], kTransitionLeftToRight);
else if (_invokingResource != NULL)
_vm->changeToCard(_invokingResource->getDest(), kTransitionLeftToRight);
else
warning("Missing invokingResource in altDest call");
}
void MystScriptParser::o_changeCardSwitchRtL(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
uint16 value = getVar(var);
debugC(kDebugScript, "Opcode %d: changeCardSwitch var %d: %d", op, var, value);
if (value)
_vm->changeToCard(argv[value -1 ], kTransitionRightToLeft);
else if (_invokingResource != NULL)
_vm->changeToCard(_invokingResource->getDest(), kTransitionRightToLeft);
else else
warning("Missing invokingResource in altDest call"); warning("Missing invokingResource in altDest call");
} }
@ -373,10 +399,47 @@ void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *ar
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op); debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
if (_invokingResource != NULL) if (_invokingResource != NULL)
_vm->changeToCard(_invokingResource->getDest(), true); _vm->changeToCard(_invokingResource->getDest(), kTransitionCopy);
else else
warning("Opcode %d: Missing invokingResource", op); warning("Opcode %d: Missing invokingResource", op);
} }
void MystScriptParser::o_goToDestForward(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
if (_invokingResource != NULL)
_vm->changeToCard(_invokingResource->getDest(), kTransitionDissolve);
else
warning("Opcode %d: Missing invokingResource", op);
}
void MystScriptParser::o_goToDestLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
if (_invokingResource != NULL)
_vm->changeToCard(_invokingResource->getDest(), kTransitionPartToRight);
else
warning("Opcode %d: Missing invokingResource", op);
}
void MystScriptParser::o_goToDestRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
if (_invokingResource != NULL)
_vm->changeToCard(_invokingResource->getDest(), kTransitionPartToLeft);
else
warning("Opcode %d: Missing invokingResource", op);
}
void MystScriptParser::o_goToDestUp(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
if (_invokingResource != NULL)
_vm->changeToCard(_invokingResource->getDest(), kTransitionTopToBottom);
else
warning("Opcode %d: Missing invokingResource", op);
}
void MystScriptParser::o_triggerMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void MystScriptParser::o_triggerMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Trigger Type 6 Resource Movie..", op); debugC(kDebugScript, "Opcode %d: Trigger Type 6 Resource Movie..", op);
// TODO: If movie has sound, pause background music // TODO: If movie has sound, pause background music
@ -427,7 +490,7 @@ void MystScriptParser::o_changeCardDirectional(uint16 op, uint16 var, uint16 arg
debugC(kDebugScript, "\tcardId: %d", cardId); debugC(kDebugScript, "\tcardId: %d", cardId);
debugC(kDebugScript, "\tdirectonal update data size: %d", directionalUpdateDataSize); debugC(kDebugScript, "\tdirectonal update data size: %d", directionalUpdateDataSize);
_vm->changeToCard(cardId, false); _vm->changeToCard(cardId, kNoTransition);
animatedUpdate(directionalUpdateDataSize, &argv[2], 0); animatedUpdate(directionalUpdateDataSize, &argv[2], 0);
} }
@ -440,23 +503,23 @@ void MystScriptParser::o_changeCardPush(uint16 op, uint16 var, uint16 argc, uint
debugC(kDebugScript, "Opcode %d: Jump to Card Id, Storing Current Card Id", op); debugC(kDebugScript, "Opcode %d: Jump to Card Id, Storing Current Card Id", op);
_savedCardId = _vm->getCurCard(); _savedCardId = _vm->getCurCard();
uint16 cardId = argv[0];
// argv[1] is not used in the original engine uint16 cardId = argv[0];
TransitionType transition = static_cast<TransitionType>(argv[1]);
debugC(kDebugScript, "\tCurrent CardId: %d", _savedCardId); debugC(kDebugScript, "\tCurrent CardId: %d", _savedCardId);
debugC(kDebugScript, "\tJump to CardId: %d", cardId); debugC(kDebugScript, "\tJump to CardId: %d", cardId);
_vm->changeToCard(cardId, true); _vm->changeToCard(cardId, transition);
} }
void MystScriptParser::o_changeCardPop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void MystScriptParser::o_changeCardPop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Return To Stored Card Id", op); debugC(kDebugScript, "Opcode %d: Return To Stored Card Id", op);
debugC(kDebugScript, "\tCardId: %d", _savedCardId); debugC(kDebugScript, "\tCardId: %d", _savedCardId);
// argv[0] is not used in the original engine TransitionType transition = static_cast<TransitionType>(argv[0]);
_vm->changeToCard(_savedCardId, true); _vm->changeToCard(_savedCardId, transition);
} }
void MystScriptParser::o_enableAreas(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void MystScriptParser::o_enableAreas(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@ -752,14 +815,11 @@ void MystScriptParser::o_changeCard(uint16 op, uint16 var, uint16 argc, uint16 *
debugC(kDebugScript, "Opcode %d: Change Card", op); debugC(kDebugScript, "Opcode %d: Change Card", op);
uint16 cardId = argv[0]; uint16 cardId = argv[0];
TransitionType transition = static_cast<TransitionType>(argv[1]);
// Argument 1 if present is not used
// uint16 u0 = argv[1];
debugC(kDebugScript, "\tTarget Card: %d", cardId); debugC(kDebugScript, "\tTarget Card: %d", cardId);
//debugC(kDebugScript, "\tu0: %d", u0); // Unused data
_vm->changeToCard(cardId, true); _vm->changeToCard(cardId, transition);
} }
void MystScriptParser::o_drawImageChangeCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void MystScriptParser::o_drawImageChangeCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@ -767,7 +827,7 @@ void MystScriptParser::o_drawImageChangeCard(uint16 op, uint16 var, uint16 argc,
uint16 imageId = argv[0]; uint16 imageId = argv[0];
uint16 cardId = argv[1]; uint16 cardId = argv[1];
// argv[2] is not used in the original engine TransitionType transition = static_cast<TransitionType>(argv[2]);
debugC(kDebugScript, "\timageId: %d", imageId); debugC(kDebugScript, "\timageId: %d", imageId);
debugC(kDebugScript, "\tcardId: %d", cardId); debugC(kDebugScript, "\tcardId: %d", cardId);
@ -775,7 +835,7 @@ void MystScriptParser::o_drawImageChangeCard(uint16 op, uint16 var, uint16 argc,
_vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333)); _vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333));
_vm->_system->updateScreen(); _vm->_system->updateScreen();
_vm->changeToCard(cardId, true); _vm->changeToCard(cardId, transition);
} }
void MystScriptParser::o_changeMainCursor(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void MystScriptParser::o_changeMainCursor(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@ -850,7 +910,7 @@ void MystScriptParser::o_changeCardPlaySoundDirectional(uint16 op, uint16 var, u
if (soundId) if (soundId)
_vm->_sound->replaceSoundMyst(soundId); _vm->_sound->replaceSoundMyst(soundId);
_vm->changeToCard(cardId, false); _vm->changeToCard(cardId, kNoTransition);
animatedUpdate(dataSize, &argv[4], delayBetweenSteps); animatedUpdate(dataSize, &argv[4], delayBetweenSteps);
} }
@ -901,12 +961,12 @@ void MystScriptParser::o_quit(uint16 op, uint16 var, uint16 argc, uint16 *argv)
void MystScriptParser::showMap() { void MystScriptParser::showMap() {
if (_vm->getCurCard() != getMap()) { if (_vm->getCurCard() != getMap()) {
_savedMapCardId = _vm->getCurCard(); _savedMapCardId = _vm->getCurCard();
_vm->changeToCard(getMap(), true); _vm->changeToCard(getMap(), kTransitionCopy);
} }
} }
void MystScriptParser::o_exitMap(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void MystScriptParser::o_exitMap(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_vm->changeToCard(_savedMapCardId, true); _vm->changeToCard(_savedMapCardId, kTransitionCopy);
} }
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -86,10 +86,16 @@ public:
// Common opcodes // Common opcodes
DECLARE_OPCODE(o_toggleVar); DECLARE_OPCODE(o_toggleVar);
DECLARE_OPCODE(o_setVar); DECLARE_OPCODE(o_setVar);
DECLARE_OPCODE(o_changeCardSwitch); DECLARE_OPCODE(o_changeCardSwitch4);
DECLARE_OPCODE(o_changeCardSwitchLtR);
DECLARE_OPCODE(o_changeCardSwitchRtL);
DECLARE_OPCODE(o_takePage); DECLARE_OPCODE(o_takePage);
DECLARE_OPCODE(o_redrawCard); DECLARE_OPCODE(o_redrawCard);
DECLARE_OPCODE(o_goToDest); DECLARE_OPCODE(o_goToDest);
DECLARE_OPCODE(o_goToDestForward);
DECLARE_OPCODE(o_goToDestLeft);
DECLARE_OPCODE(o_goToDestRight);
DECLARE_OPCODE(o_goToDestUp);
DECLARE_OPCODE(o_triggerMovie); DECLARE_OPCODE(o_triggerMovie);
DECLARE_OPCODE(o_toggleVarNoRedraw); DECLARE_OPCODE(o_toggleVarNoRedraw);
DECLARE_OPCODE(o_drawAreaState); DECLARE_OPCODE(o_drawAreaState);

View file

@ -341,7 +341,7 @@ void Channelwood::o_drawImageChangeCardAndVolume(uint16 op, uint16 var, uint16 a
_vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333)); _vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333));
_vm->_system->updateScreen(); _vm->_system->updateScreen();
_vm->changeToCard(cardId, true); _vm->changeToCard(cardId, kTransitionPartToLeft);
if (argc == 3) { if (argc == 3) {
uint16 volume = argv[2]; uint16 volume = argv[2];

View file

@ -104,14 +104,14 @@ void Demo::returnToMenu_run() {
switch (_returnToMenuStep){ switch (_returnToMenuStep){
case 0: case 0:
_vm->_gfx->fadeToBlack(); _vm->_gfx->fadeToBlack();
_vm->changeToCard(2003, false); _vm->changeToCard(2003, kNoTransition);
_vm->_gfx->fadeFromBlack(); _vm->_gfx->fadeFromBlack();
_returnToMenuStep++; _returnToMenuStep++;
break; break;
case 1: case 1:
_vm->_gfx->fadeToBlack(); _vm->_gfx->fadeToBlack();
_vm->changeToCard(2001, false); _vm->changeToCard(2001, kNoTransition);
_vm->_gfx->fadeFromBlack(); _vm->_gfx->fadeFromBlack();
_vm->_cursor->showCursor(); _vm->_cursor->showCursor();

View file

@ -127,9 +127,9 @@ void Intro::introMovies_run() {
break; break;
default: default:
if (_vm->getFeatures() & GF_DEMO) if (_vm->getFeatures() & GF_DEMO)
_vm->changeToCard(2001, true); _vm->changeToCard(2001, kTransitionRightToLeft);
else else
_vm->changeToCard(2, true); _vm->changeToCard(2, kTransitionRightToLeft);
} }
} }
@ -148,7 +148,7 @@ void Intro::mystLinkBook_run() {
_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333)); _vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
} }
} else if (!_linkBookMovie->isPlaying()) { } else if (!_linkBookMovie->isPlaying()) {
_vm->changeToCard(5, true); _vm->changeToCard(5, kTransitionRightToLeft);
} }
} }

View file

@ -616,7 +616,7 @@ void Mechanical::elevatorGoMiddle_run() {
_vm->_sound->playSoundBlocking(11120); _vm->_sound->playSoundBlocking(11120);
_vm->_gfx->copyImageToBackBuffer(6118, Common::Rect(544, 333)); _vm->_gfx->copyImageToBackBuffer(6118, Common::Rect(544, 333));
_vm->_sound->replaceSoundMyst(12120); _vm->_sound->replaceSoundMyst(12120);
_vm->_gfx->runTransition(2, Common::Rect(177, 0, 370, 333), 25, 0); _vm->_gfx->runTransition(kTransitionUnk2, Common::Rect(177, 0, 370, 333), 25, 0);
_vm->_sound->playSoundBlocking(13120); _vm->_sound->playSoundBlocking(13120);
_vm->_sound->replaceSoundMyst(8120); _vm->_sound->replaceSoundMyst(8120);
_vm->_gfx->copyImageToBackBuffer(6327, Common::Rect(544, 333)); _vm->_gfx->copyImageToBackBuffer(6327, Common::Rect(544, 333));
@ -630,7 +630,7 @@ void Mechanical::elevatorGoMiddle_run() {
_elevatorPosition = 1; _elevatorPosition = 1;
_vm->changeToCard(6327, true); _vm->changeToCard(6327, kTransitionRightToLeft);
} }
} }
} }

View file

@ -1043,7 +1043,7 @@ void Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// No page or white page // No page or white page
if (!_globals.heldPage || _globals.heldPage == 13) { if (!_globals.heldPage || _globals.heldPage == 13) {
_vm->changeToCard(cardIdBookCover, true); _vm->changeToCard(cardIdBookCover, kTransitionDissolve);
return; return;
} }
@ -1085,7 +1085,7 @@ void Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Wrong book // Wrong book
if (bookVar != var) { if (bookVar != var) {
_vm->changeToCard(cardIdBookCover, true); _vm->changeToCard(cardIdBookCover, kTransitionDissolve);
return; return;
} }
@ -1111,9 +1111,9 @@ void Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
else else
_globals.currentAge = 10; _globals.currentAge = 10;
_vm->changeToCard(cardIdLose, true); _vm->changeToCard(cardIdLose, kTransitionDissolve);
} else { } else {
_vm->changeToCard(cardIdBookCover, true); _vm->changeToCard(cardIdBookCover, kTransitionDissolve);
} }
} }
@ -1300,7 +1300,7 @@ void Myst::imagerValidation_run() {
if (_imagerValidationStep == 11) { if (_imagerValidationStep == 11) {
_imagerValidationStep = 0; _imagerValidationStep = 0;
_vm->changeToCard(_imagerValidationCard, true); _vm->changeToCard(_imagerValidationCard, kTransitionBottomToTop);
} else { } else {
_startTime = time + 100; _startTime = time + 100;
} }
@ -1475,10 +1475,10 @@ void Myst::o_cabinSafeHandleMove(uint16 op, uint16 var, uint16 argc, uint16 *arg
if (soundId) if (soundId)
_vm->_sound->replaceSoundMyst(soundId); _vm->_sound->replaceSoundMyst(soundId);
_vm->changeToCard(4103, false); _vm->changeToCard(4103, kNoTransition);
Common::Rect screenRect = Common::Rect(544, 333); Common::Rect screenRect = Common::Rect(544, 333);
_vm->_gfx->runTransition(0, screenRect, 2, 5); _vm->_gfx->runTransition(kTransitionLeftToRight, screenRect, 2, 5);
} }
_tempVar = 1; _tempVar = 1;
} else { } else {
@ -3296,7 +3296,7 @@ void Myst::libraryBookcaseTransform_run(void) {
if (_state.libraryBookcaseDoor) { if (_state.libraryBookcaseDoor) {
_vm->_gfx->copyImageSectionToBackBuffer(11179, Common::Rect(0, 0, 106, 81), Common::Rect(0, 72, 106, 153)); _vm->_gfx->copyImageSectionToBackBuffer(11179, Common::Rect(0, 0, 106, 81), Common::Rect(0, 72, 106, 153));
_vm->_gfx->runTransition(6, Common::Rect(0, 72, 106, 153), 5, 10); _vm->_gfx->runTransition(kTransitionBottomToTop, Common::Rect(0, 72, 106, 153), 5, 10);
_vm->_sound->playSoundBlocking(7348); _vm->_sound->playSoundBlocking(7348);
_vm->_sound->replaceBackgroundMyst(4348, 16384); _vm->_sound->replaceBackgroundMyst(4348, 16384);
} else { } else {

View file

@ -139,7 +139,7 @@ void Preview::speech_run() {
break; break;
case 1: // Open book case 1: // Open book
if (_currentCue >= 1) { if (_currentCue >= 1) {
_vm->changeToCard(3001, true); _vm->changeToCard(3001, kTransitionDissolve);
_speechStep++; _speechStep++;
} }
@ -147,7 +147,7 @@ void Preview::speech_run() {
case 2: // Go to Myst case 2: // Go to Myst
if (_currentCue >= 2) { if (_currentCue >= 2) {
_vm->_gfx->fadeToBlack(); _vm->_gfx->fadeToBlack();
_vm->changeToCard(3002, false); _vm->changeToCard(3002, kNoTransition);
_vm->_gfx->fadeFromBlack(); _vm->_gfx->fadeFromBlack();
_speechStep++; _speechStep++;
@ -164,7 +164,7 @@ void Preview::speech_run() {
if (_currentCue >= 4) { if (_currentCue >= 4) {
_library->drawConditionalDataToScreen(0); _library->drawConditionalDataToScreen(0);
_vm->changeToCard(3003, true); _vm->changeToCard(3003, kTransitionDissolve);
_speechNextTime = time + 2000; _speechNextTime = time + 2000;
_speechStep++; _speechStep++;
@ -181,7 +181,7 @@ void Preview::speech_run() {
if (time < _speechNextTime) if (time < _speechNextTime)
break; break;
_vm->changeToCard(3004, true); _vm->changeToCard(3004, kTransitionDissolve);
_speechNextTime = time + 2000; _speechNextTime = time + 2000;
_speechStep++; _speechStep++;
break; break;
@ -190,7 +190,7 @@ void Preview::speech_run() {
break; break;
_vm->_gfx->fadeToBlack(); _vm->_gfx->fadeToBlack();
_vm->changeToCard(3005, false); _vm->changeToCard(3005, kNoTransition);
_vm->_gfx->fadeFromBlack(); _vm->_gfx->fadeFromBlack();
_speechNextTime = time + 1000; _speechNextTime = time + 1000;
_speechStep++; _speechStep++;
@ -205,7 +205,7 @@ void Preview::speech_run() {
if (time < _speechNextTime) if (time < _speechNextTime)
break; break;
_vm->changeToCard(3006 + _speechStep - 7, true); _vm->changeToCard(3006 + _speechStep - 7, kTransitionDissolve);
_speechNextTime = time + 2000; _speechNextTime = time + 2000;
_speechStep++; _speechStep++;
break; break;
@ -213,7 +213,7 @@ void Preview::speech_run() {
if (time < _speechNextTime) if (time < _speechNextTime)
break; break;
_vm->changeToCard(4329, true); _vm->changeToCard(4329, kTransitionDissolve);
_speechRunning = false; _speechRunning = false;
_globals.currentAge = 2; _globals.currentAge = 2;

View file

@ -729,11 +729,11 @@ void Selenitic::o_mazeRunnerDoorButton(uint16 op, uint16 var, uint16 argc, uint1
uint16 cardIdEntry = argv[1]; uint16 cardIdEntry = argv[1];
if (_mazeRunnerPosition == 288) { if (_mazeRunnerPosition == 288) {
_vm->changeToCard(cardIdEntry, false); _vm->changeToCard(cardIdEntry, kNoTransition);
_vm->_sound->replaceSoundMyst(cardIdEntry); _vm->_sound->replaceSoundMyst(cardIdEntry);
animatedUpdate(argv[2], &argv[3], 10); animatedUpdate(argv[2], &argv[3], 10);
} else if (_mazeRunnerPosition == 289) { } else if (_mazeRunnerPosition == 289) {
_vm->changeToCard(cardIdExit, false); _vm->changeToCard(cardIdExit, kNoTransition);
_vm->_sound->replaceSoundMyst(cardIdExit); _vm->_sound->replaceSoundMyst(cardIdExit);
animatedUpdate(argv[2], &argv[3], 10); animatedUpdate(argv[2], &argv[3], 10);
} }
@ -895,9 +895,9 @@ void Selenitic::o_soundLockButton(uint16 op, uint16 var, uint16 argc, uint16 *ar
uint16 cardIdClosed = argv[0]; uint16 cardIdClosed = argv[0];
uint16 cardIdOpen = argv[1]; uint16 cardIdOpen = argv[1];
_vm->changeToCard(cardIdClosed, true); _vm->changeToCard(cardIdClosed, kTransitionDissolve);
_vm->changeToCard(cardIdOpen, false); _vm->changeToCard(cardIdOpen, kNoTransition);
_vm->_sound->replaceSoundMyst(argv[2]); _vm->_sound->replaceSoundMyst(argv[2]);
animatedUpdate(argv[4], &argv[5], argv[3]); animatedUpdate(argv[4], &argv[5], argv[3]);

View file

@ -63,7 +63,7 @@ void Slides::runPersistentScripts() {
// Used on Cards... // Used on Cards...
if (_vm->_system->getMillis() > _nextCardTime) { if (_vm->_system->getMillis() > _nextCardTime) {
_vm->_gfx->fadeToBlack(); _vm->_gfx->fadeToBlack();
_vm->changeToCard(_nextCardID, false); _vm->changeToCard(_nextCardID, kNoTransition);
_vm->_gfx->fadeFromBlack(); _vm->_gfx->fadeFromBlack();
} }
} }

View file

@ -440,9 +440,9 @@ void Stoneship::o_drawerOpenSirius(uint16 op, uint16 var, uint16 argc, uint16 *a
drawer->drawConditionalDataToScreen(0, 0); drawer->drawConditionalDataToScreen(0, 0);
} }
uint16 transition = 5; TransitionType transition = kTransitionTopToBottom;
if (argc == 2 && argv[1]) if (argc == 2 && argv[1])
transition = 11; transition = kTransitionCopy;
_vm->_gfx->runTransition(transition, drawer->getRect(), 25, 5); _vm->_gfx->runTransition(transition, drawer->getRect(), 25, 5);
} }
@ -579,7 +579,7 @@ void Stoneship::o_drawerOpenAchenar(uint16 op, uint16 var, uint16 argc, uint16 *
MystResourceType8 *drawer = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]); MystResourceType8 *drawer = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]);
drawer->drawConditionalDataToScreen(0, 0); drawer->drawConditionalDataToScreen(0, 0);
_vm->_gfx->runTransition(5, drawer->getRect(), 25, 5); _vm->_gfx->runTransition(kTransitionTopToBottom, drawer->getRect(), 25, 5);
} }
void Stoneship::o_hologramPlayback(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_hologramPlayback(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@ -777,7 +777,7 @@ void Stoneship::o_cloudOrbLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv
_cloudOrbMovie->pauseMovie(true); _cloudOrbMovie->pauseMovie(true);
_vm->_sound->replaceSoundMyst(_cloudOrbStopSound); _vm->_sound->replaceSoundMyst(_cloudOrbStopSound);
_vm->_gfx->runTransition(5, _invokingResource->getRect(), 4, 0); _vm->_gfx->runTransition(kTransitionTopToBottom, _invokingResource->getRect(), 4, 0);
} }
void Stoneship::o_drawerCloseOpened(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_drawerCloseOpened(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@ -794,7 +794,7 @@ void Stoneship::drawerClose(uint16 drawer) {
_vm->drawResourceImages(); _vm->drawResourceImages();
MystResource *res = _vm->_resources[drawer]; MystResource *res = _vm->_resources[drawer];
_vm->_gfx->runTransition(6, res->getRect(), 25, 5); _vm->_gfx->runTransition(kTransitionBottomToTop, res->getRect(), 25, 5);
} }
void Stoneship::o_hologramDisplay_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_hologramDisplay_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {