MOHAWK: Fix Myst library books, fireplace combination book, and bookcase transform animation.
svn-id: r54802
This commit is contained in:
parent
077102f8db
commit
fb854b1483
10 changed files with 297 additions and 182 deletions
|
@ -304,10 +304,6 @@ Common::Error MohawkEngine_Myst::run() {
|
|||
_needsUpdate = _video->updateBackgroundMovies();
|
||||
_scriptParser->runPersistentScripts();
|
||||
|
||||
// Run animations...
|
||||
for (uint16 i = 0; i < _resources.size(); i++)
|
||||
_resources[i]->handleAnimation();
|
||||
|
||||
while (_eventMan->pollEvent(event)) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
|
@ -550,6 +546,9 @@ void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) {
|
|||
// Update the images of each area too
|
||||
drawResourceImages();
|
||||
|
||||
for (uint16 i = 0; i < _resources.size(); i++)
|
||||
_resources[i]->handleCardChange();
|
||||
|
||||
// TODO: Handle Script Resources
|
||||
|
||||
// Make sure we have the right cursor showing
|
||||
|
|
|
@ -161,23 +161,23 @@ MystResourceType6::MystResourceType6(MohawkEngine_Myst *vm, Common::SeekableRead
|
|||
_videoRunning = false;
|
||||
}
|
||||
|
||||
void MystResourceType6::handleAnimation() {
|
||||
// TODO: Implement Code to allow _playOnCardChange when set
|
||||
// and trigger by Opcode 9 when clear
|
||||
|
||||
void MystResourceType6::playMovie() {
|
||||
if (!_videoRunning) {
|
||||
// NOTE: The left and top coordinates are often incorrect and do not make sense.
|
||||
// We use the rect coordinates here instead.
|
||||
|
||||
if (_playBlocking)
|
||||
_vm->_video->playMovie(_videoFile, _rect.left, _rect.top);
|
||||
_vm->_video->playMovie(_videoFile, _left, _top);
|
||||
else
|
||||
_vm->_video->playBackgroundMovie(_videoFile, _rect.left, _rect.top, _loop);
|
||||
_vm->_video->playBackgroundMovie(_videoFile, _left, _top, _loop);
|
||||
|
||||
_videoRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MystResourceType6::handleCardChange() {
|
||||
if (_playOnCardChange) {
|
||||
playMovie();
|
||||
}
|
||||
}
|
||||
|
||||
MystResourceType7::MystResourceType7(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {
|
||||
_var7 = rlstStream->readUint16LE();
|
||||
_numSubResources = rlstStream->readUint16LE();
|
||||
|
@ -218,20 +218,20 @@ void MystResourceType7::drawDataToScreen() {
|
|||
}
|
||||
}
|
||||
|
||||
void MystResourceType7::handleAnimation() {
|
||||
void MystResourceType7::handleCardChange() {
|
||||
if (_var7 == 0xFFFF) {
|
||||
if (_numSubResources == 1)
|
||||
_subResources[0]->handleAnimation();
|
||||
_subResources[0]->handleCardChange();
|
||||
else if (_numSubResources != 0)
|
||||
warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
|
||||
} else {
|
||||
uint16 varValue = _vm->_scriptParser->getVar(_var7);
|
||||
|
||||
if (_numSubResources == 1 && varValue != 0)
|
||||
_subResources[0]->handleAnimation();
|
||||
_subResources[0]->handleCardChange();
|
||||
else if (_numSubResources != 0) {
|
||||
if (varValue < _numSubResources)
|
||||
_subResources[varValue]->handleAnimation();
|
||||
_subResources[varValue]->handleCardChange();
|
||||
else
|
||||
warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _var7, varValue, _numSubResources);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
bool contains(Common::Point point) { return _rect.contains(point); }
|
||||
virtual void drawDataToScreen() {}
|
||||
virtual void handleAnimation() {}
|
||||
virtual void handleCardChange() {}
|
||||
virtual Common::Rect getRect() { return _rect; }
|
||||
bool isEnabled();
|
||||
void setEnabled(bool enabled);
|
||||
|
@ -103,7 +103,8 @@ protected:
|
|||
class MystResourceType6 : public MystResourceType5 {
|
||||
public:
|
||||
MystResourceType6(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
|
||||
void handleAnimation();
|
||||
void playMovie();
|
||||
void handleCardChange();
|
||||
|
||||
protected:
|
||||
static Common::String convertMystVideoName(Common::String name);
|
||||
|
@ -126,13 +127,14 @@ public:
|
|||
virtual ~MystResourceType7();
|
||||
|
||||
virtual void drawDataToScreen();
|
||||
virtual void handleAnimation();
|
||||
virtual void handleCardChange();
|
||||
|
||||
virtual void handleMouseUp(const Common::Point &mouse);
|
||||
virtual void handleMouseDown(const Common::Point &mouse);
|
||||
virtual void handleMouseEnter();
|
||||
virtual void handleMouseLeave();
|
||||
|
||||
MystResource *getSubResource(uint16 index) { return _subResources[index]; }
|
||||
protected:
|
||||
uint16 _var7;
|
||||
uint16 _numSubResources;
|
||||
|
|
|
@ -76,7 +76,7 @@ bool MystSaveLoad::loadGame(const Common::String &filename) {
|
|||
warning("Unexpected value at 0x%03X - Found %u Expected %u", loadFile->pos(), _v->globals.u1, 1);
|
||||
|
||||
_v->globals.transitions = loadFile->readUint16LE();
|
||||
_v->globals.zipMode = loadFile->readUint16LE();
|
||||
_v->globals.ending = loadFile->readUint16LE();
|
||||
_v->globals.redPagesInBook = loadFile->readUint16LE();
|
||||
_v->globals.bluePagesInBook = loadFile->readUint16LE();
|
||||
|
||||
|
@ -353,7 +353,7 @@ bool MystSaveLoad::saveGame(const Common::String &fname) {
|
|||
saveFile->writeUint16LE(_v->globals.heldPage);
|
||||
saveFile->writeUint16LE(_v->globals.u1);
|
||||
saveFile->writeUint16LE(_v->globals.transitions);
|
||||
saveFile->writeUint16LE(_v->globals.zipMode);
|
||||
saveFile->writeUint16LE(_v->globals.ending);
|
||||
saveFile->writeUint16LE(_v->globals.redPagesInBook);
|
||||
saveFile->writeUint16LE(_v->globals.bluePagesInBook);
|
||||
|
||||
|
@ -478,7 +478,7 @@ void MystSaveLoad::initMystVariables(MystVariables *_tv) {
|
|||
_tv->globals.heldPage = 0;
|
||||
_tv->globals.u1 = 1;
|
||||
_tv->globals.transitions = 0;
|
||||
_tv->globals.zipMode = 0;
|
||||
_tv->globals.ending = 0;
|
||||
_tv->globals.redPagesInBook = 0;
|
||||
_tv->globals.bluePagesInBook = 0;
|
||||
|
||||
|
@ -525,7 +525,7 @@ void MystSaveLoad::initMystVariables(MystVariables *_tv) {
|
|||
// called by init scripts may set these up as per the others..
|
||||
|
||||
// Library Bookcase Door - Default to Up
|
||||
_tv->myst_vars[18] = 1;
|
||||
_tv->myst.libraryBookcaseDoor = 1;
|
||||
// Dock Imager Numeric Selection - Default to 67
|
||||
_tv->myst_vars[19] = 67;
|
||||
// Dock Imager Active - Default to Active
|
||||
|
|
|
@ -46,7 +46,7 @@ struct MystVariables {
|
|||
2 = Page Being Held
|
||||
3 = Unknown - Fixed at 1
|
||||
4 = Slide Transitions
|
||||
5 = Zip Mode
|
||||
5 = Ending
|
||||
6 = Red Pages in Book
|
||||
7 = Blue Pages in Book
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@ struct MystVariables {
|
|||
uint16 heldPage;
|
||||
uint16 u1;
|
||||
uint16 transitions;
|
||||
uint16 zipMode;
|
||||
uint16 ending;
|
||||
uint16 redPagesInBook;
|
||||
uint16 bluePagesInBook;
|
||||
} globals;
|
||||
|
@ -119,6 +119,7 @@ struct MystVariables {
|
|||
uint16 generatorBreakers;
|
||||
uint16 generatorButtons;
|
||||
uint16 generatorVoltage;
|
||||
uint16 libraryBookcaseDoor;
|
||||
uint16 rocketSliderPosition[5];
|
||||
} myst;
|
||||
|
||||
|
|
|
@ -225,9 +225,13 @@ MystScript MystScriptParser::readScript(Common::SeekableReadStream *stream, Myst
|
|||
}
|
||||
|
||||
uint16 MystScriptParser::getVar(uint16 var) {
|
||||
MystVariables::Globals &globals = _vm->_saveLoad->_v->globals;
|
||||
|
||||
switch(var) {
|
||||
case 105:
|
||||
return _tempVar;
|
||||
case 106:
|
||||
return globals.ending;
|
||||
default:
|
||||
warning("Unimplemented var getter 0x%02x (%d)", var, var);
|
||||
return _vm->_varStore->getVar(var);
|
||||
|
@ -297,8 +301,6 @@ void MystScriptParser::unknown(uint16 op, uint16 var, uint16 argc, uint16 *argv)
|
|||
}
|
||||
|
||||
void MystScriptParser::NOP(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
// NOTE: Don't check argc/argv here as they vary depending on NOP erased opcode
|
||||
debugC(kDebugScript, "NOP");
|
||||
}
|
||||
|
||||
void MystScriptParser::o_toggleVar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
|
@ -374,7 +376,7 @@ void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *ar
|
|||
}
|
||||
void MystScriptParser::o_triggerMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
debugC(kDebugScript, "Opcode %d: Trigger Type 6 Resource Movie..", op);
|
||||
// If movie has sound, pause background music
|
||||
// TODO: If movie has sound, pause background music
|
||||
|
||||
int16 direction = 1;
|
||||
if (argc == 1) {
|
||||
|
@ -383,8 +385,10 @@ void MystScriptParser::o_triggerMovie(uint16 op, uint16 var, uint16 argc, uint16
|
|||
debugC(kDebugScript, "\tDirection: %d", direction);
|
||||
|
||||
// Trigger resource 6 movie overriding play direction
|
||||
MystResourceType6 *resource = static_cast<MystResourceType6 *>(_invokingResource);
|
||||
resource->playMovie();
|
||||
|
||||
// If movie has sound, resume background music
|
||||
// TODO: If movie has sound, resume background music
|
||||
}
|
||||
|
||||
void MystScriptParser::o_toggleVarNoRedraw(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
|
|
|
@ -140,7 +140,7 @@ protected:
|
|||
|
||||
uint16 _savedCardId;
|
||||
uint16 _savedCursorId;
|
||||
uint16 _tempVar; // Generic temp var used by the scripts
|
||||
int16 _tempVar; // Generic temp var used by the scripts
|
||||
|
||||
static const uint8 _stackMap[];
|
||||
static const uint16 _startCard[];
|
||||
|
|
|
@ -166,7 +166,10 @@ void MystScriptParser_Intro::opcode_201(uint16 op, uint16 var, uint16 argc, uint
|
|||
_vm->_gfx->updateScreen();
|
||||
_vm->_system->delayMillis(4 * 1000);
|
||||
_vm->_gfx->copyImageToScreen(4, Common::Rect(0, 0, 544, 333));
|
||||
// TODO: Wait until video ends, then change to card 5
|
||||
|
||||
MystResourceType6 *resource = static_cast<MystResourceType6 *>(_invokingResource);
|
||||
resource->playMovie();
|
||||
// TODO: Complete
|
||||
}
|
||||
|
||||
void MystScriptParser_Intro::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
|
|
|
@ -44,6 +44,7 @@ MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : MystScript
|
|||
// Card ID preinitialized by the engine for use by opcode 18
|
||||
// when linking back to Myst in the library
|
||||
_savedCardId = 4329;
|
||||
_libraryBookcaseChanged = false;
|
||||
}
|
||||
|
||||
MystScriptParser_Myst::~MystScriptParser_Myst() {
|
||||
|
@ -53,8 +54,9 @@ MystScriptParser_Myst::~MystScriptParser_Myst() {
|
|||
|
||||
void MystScriptParser_Myst::setupOpcodes() {
|
||||
// "Stack-Specific" Opcodes
|
||||
OPCODE(101, opcode_101);
|
||||
OPCODE(102, opcode_102);
|
||||
OPCODE(100, NOP);
|
||||
OPCODE(101, o_libraryBookPageTurnLeft);
|
||||
OPCODE(102, o_libraryBookPageTurnRight);
|
||||
OPCODE(103, opcode_103);
|
||||
OPCODE(104, opcode_104);
|
||||
OPCODE(105, opcode_105);
|
||||
|
@ -103,7 +105,7 @@ void MystScriptParser_Myst::setupOpcodes() {
|
|||
OPCODE(175, opcode_175);
|
||||
OPCODE(176, opcode_176);
|
||||
OPCODE(177, opcode_177);
|
||||
OPCODE(180, opcode_180);
|
||||
OPCODE(180, o_libraryCombinationBookStop);
|
||||
OPCODE(181, opcode_181);
|
||||
OPCODE(182, opcode_182);
|
||||
OPCODE(183, opcode_183);
|
||||
|
@ -112,8 +114,8 @@ void MystScriptParser_Myst::setupOpcodes() {
|
|||
OPCODE(186, opcode_186);
|
||||
OPCODE(188, opcode_188);
|
||||
OPCODE(189, opcode_189);
|
||||
OPCODE(190, opcode_190);
|
||||
OPCODE(191, opcode_191);
|
||||
OPCODE(190, o_libraryCombinationBookStartRight);
|
||||
OPCODE(191, o_libraryCombinationBookStartLeft);
|
||||
OPCODE(192, opcode_192);
|
||||
OPCODE(194, opcode_194);
|
||||
OPCODE(195, opcode_195);
|
||||
|
@ -123,7 +125,7 @@ void MystScriptParser_Myst::setupOpcodes() {
|
|||
OPCODE(199, opcode_199);
|
||||
|
||||
// "Init" Opcodes
|
||||
OPCODE(200, opcode_200);
|
||||
OPCODE(200, o_libraryBook_init);
|
||||
OPCODE(201, opcode_201);
|
||||
OPCODE(202, opcode_202);
|
||||
OPCODE(203, opcode_203);
|
||||
|
@ -131,7 +133,7 @@ void MystScriptParser_Myst::setupOpcodes() {
|
|||
OPCODE(205, opcode_205);
|
||||
OPCODE(206, opcode_206);
|
||||
OPCODE(208, opcode_208);
|
||||
OPCODE(209, opcode_209);
|
||||
OPCODE(209, o_libraryBookcaseTransform_init);
|
||||
OPCODE(210, o_generatorControlRoom_init);
|
||||
OPCODE(211, opcode_211);
|
||||
OPCODE(212, opcode_212);
|
||||
|
@ -163,39 +165,53 @@ void MystScriptParser_Myst::setupOpcodes() {
|
|||
#undef OPCODE
|
||||
|
||||
void MystScriptParser_Myst::disablePersistentScripts() {
|
||||
opcode_200_disable();
|
||||
opcode_201_disable();
|
||||
opcode_202_disable();
|
||||
opcode_203_disable();
|
||||
opcode_205_disable();
|
||||
opcode_209_disable();
|
||||
|
||||
_libraryBookcaseMoving = false;
|
||||
_generatorControlRoomRunning = false;
|
||||
_libraryCombinationBookPagesTurning = false;
|
||||
|
||||
opcode_211_disable();
|
||||
opcode_212_disable();
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::runPersistentScripts() {
|
||||
opcode_200_run();
|
||||
opcode_201_run();
|
||||
opcode_202_run();
|
||||
opcode_203_run();
|
||||
opcode_205_run();
|
||||
opcode_209_run();
|
||||
|
||||
if (_generatorControlRoomRunning)
|
||||
o_generatorControlRoom_run();
|
||||
generatorControlRoom_run();
|
||||
|
||||
if (_libraryCombinationBookPagesTurning)
|
||||
libraryCombinationBook_run();
|
||||
|
||||
if (_libraryBookcaseMoving)
|
||||
libraryBookcaseTransform_run();
|
||||
|
||||
opcode_211_run();
|
||||
opcode_212_run();
|
||||
}
|
||||
|
||||
uint16 MystScriptParser_Myst::getVar(uint16 var) {
|
||||
// MystVariables::Globals &globals = _vm->_saveLoad->_v->globals;
|
||||
MystVariables::Globals &globals = _vm->_saveLoad->_v->globals;
|
||||
MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
|
||||
|
||||
switch(var) {
|
||||
case 0: // Myst Library Bookcase Closed
|
||||
return myst.libraryBookcaseDoor;
|
||||
case 1:
|
||||
if (globals.ending != 4) {
|
||||
return myst.libraryBookcaseDoor != 1;
|
||||
} else if (myst.libraryBookcaseDoor == 1) {
|
||||
return 2;
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
case 44: // Rocket ship power state
|
||||
if (myst.generatorBreakers || myst.generatorVoltage == 0)
|
||||
return 0;
|
||||
|
@ -252,6 +268,18 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {
|
|||
return 0;
|
||||
else
|
||||
return myst.generatorVoltage / 4;
|
||||
case 102: // Red page
|
||||
if (globals.ending != 4) {
|
||||
return !(globals.redPagesInBook & 1) && (globals.heldPage != 7);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
case 103: // Blue page
|
||||
if (globals.ending != 4) {
|
||||
return !(globals.bluePagesInBook & 1) && (globals.heldPage != 1);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
case 300: // Rocket Ship Music Puzzle Slider State
|
||||
return 1;
|
||||
default:
|
||||
|
@ -259,27 +287,92 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {
|
|||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_101(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
debugC(kDebugScript, "Opcode %d: Decrement Variable", op);
|
||||
if (argc == 0) {
|
||||
debugC(kDebugScript, "\tvar: %d", var);
|
||||
uint16 varValue = _vm->_varStore->getVar(var);
|
||||
// Logic to prevent decrement to negative
|
||||
if (varValue != 0)
|
||||
_vm->_varStore->setVar(var, varValue - 1);
|
||||
} else
|
||||
unknown(op, var, argc, argv);
|
||||
void MystScriptParser_Myst::toggleVar(uint16 var) {
|
||||
MystVariables::Globals &globals = _vm->_saveLoad->_v->globals;
|
||||
// MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
|
||||
|
||||
switch(var) {
|
||||
case 102: // Red page
|
||||
if (globals.ending != 4 && !(globals.redPagesInBook & 1)) {
|
||||
if (globals.heldPage == 7)
|
||||
globals.heldPage = 0;
|
||||
else {
|
||||
globals.heldPage = 7;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 103: // Blue page
|
||||
if (globals.ending != 4 && !(globals.bluePagesInBook & 1)) {
|
||||
if (globals.heldPage == 1)
|
||||
globals.heldPage = 0;
|
||||
else {
|
||||
globals.heldPage = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
MystScriptParser::toggleVar(var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_102(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
if (argc == 0) {
|
||||
debugC(kDebugScript, "Opcode %d: Increment Variable", op);
|
||||
debugC(kDebugScript, "\tvar: %d", var);
|
||||
bool MystScriptParser_Myst::setVarValue(uint16 var, uint16 value) {
|
||||
MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
|
||||
bool refresh = false;
|
||||
|
||||
// AFAIK no logic to put ceiling on increment at least in this opcode
|
||||
_vm->_varStore->setVar(var, _vm->_varStore->getVar(var) + 1);
|
||||
} else
|
||||
unknown(op, var, argc, argv);
|
||||
switch (var) {
|
||||
case 0: // Myst Library Bookcase Closed
|
||||
if (myst.libraryBookcaseDoor != value) {
|
||||
myst.libraryBookcaseDoor = value;
|
||||
_tempVar = 0;
|
||||
refresh = true;
|
||||
}
|
||||
break;
|
||||
case 303: // Library Bookcase status changed
|
||||
_libraryBookcaseChanged = value;
|
||||
break;
|
||||
default:
|
||||
refresh = MystScriptParser::setVarValue(var, value);
|
||||
break;
|
||||
}
|
||||
|
||||
return refresh;
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::o_libraryBookPageTurnLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
debugC(kDebugScript, "Opcode %d: Turn book page left", op);
|
||||
|
||||
if (_libraryBookPage - 1 >= 0) {
|
||||
_libraryBookPage--;
|
||||
|
||||
Common::Rect rect = Common::Rect(0, 0, 544, 333);
|
||||
_vm->_gfx->copyImageToScreen(_libraryBookBaseImage + _libraryBookPage, rect);
|
||||
|
||||
if (_vm->_rnd->getRandomBit())
|
||||
_vm->_sound->playSound(_libraryBookSound1);
|
||||
else
|
||||
_vm->_sound->playSound(_libraryBookSound2);
|
||||
|
||||
_vm->_gfx->updateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::o_libraryBookPageTurnRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
debugC(kDebugScript, "Opcode %d: Turn book page right", op);
|
||||
|
||||
if (_libraryBookPage + 1 < _libraryBookNumPages) {
|
||||
_libraryBookPage++;
|
||||
|
||||
Common::Rect rect = Common::Rect(0, 0, 544, 333);
|
||||
_vm->_gfx->copyImageToScreen(_libraryBookBaseImage + _libraryBookPage, rect);
|
||||
|
||||
if (_vm->_rnd->getRandomBit())
|
||||
_vm->_sound->playSound(_libraryBookSound1);
|
||||
else
|
||||
_vm->_sound->playSound(_libraryBookSound2);
|
||||
|
||||
_vm->_gfx->updateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_103(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
|
@ -1095,9 +1188,9 @@ void MystScriptParser_Myst::opcode_177(uint16 op, uint16 var, uint16 argc, uint1
|
|||
// TODO: Time slider mouse up
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_180(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
// Used on Card 4059
|
||||
// TODO: Draw fireplace combination book page
|
||||
void MystScriptParser_Myst::o_libraryCombinationBookStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
debugC(kDebugScript, "Opcode %d: Combiation book stop turning pages", op);
|
||||
_libraryCombinationBookPagesTurning = false;
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_181(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
|
@ -1164,14 +1257,87 @@ void MystScriptParser_Myst::opcode_189(uint16 op, uint16 var, uint16 argc, uint1
|
|||
// TODO: Hour wheel turn
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_190(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
// Used on Card 4059
|
||||
// TODO: Increase fireplace combination book page
|
||||
void MystScriptParser_Myst::o_libraryCombinationBookStartRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
debugC(kDebugScript, "Opcode %d: Combination book start turning pages right", op);
|
||||
|
||||
_tempVar = 0;
|
||||
libraryCombinationBookTurnRight();
|
||||
_libraryCombinationBookStart = _vm->_system->getMillis();
|
||||
_libraryCombinationBookPagesTurning = true;
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_191(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
// Used on Card 4059
|
||||
// TODO: Decrease fireplace combination book page
|
||||
void MystScriptParser_Myst::o_libraryCombinationBookStartLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
debugC(kDebugScript, "Opcode %d: Combination book start turning pages left", op);
|
||||
|
||||
_tempVar = 0;
|
||||
libraryCombinationBookTurnLeft();
|
||||
_libraryCombinationBookStart = _vm->_system->getMillis();
|
||||
_libraryCombinationBookPagesTurning = true;
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::libraryCombinationBookTurnLeft() {
|
||||
// Turn page left
|
||||
if (_libraryBookPage - 1 >= 0) {
|
||||
_tempVar--;
|
||||
|
||||
if (_tempVar >= -5) {
|
||||
_libraryBookPage--;
|
||||
} else {
|
||||
_libraryBookPage -= 5;
|
||||
_tempVar = -5;
|
||||
}
|
||||
|
||||
_libraryBookPage = CLIP<int16>(_libraryBookPage, 0, _libraryBookNumPages - 1);
|
||||
|
||||
Common::Rect rect = Common::Rect(157, 115, 544, 333);
|
||||
_vm->_gfx->copyImageToScreen(_libraryBookBaseImage + _libraryBookPage, rect);
|
||||
|
||||
if (_vm->_rnd->getRandomBit())
|
||||
_vm->_sound->playSound(_libraryBookSound1);
|
||||
else
|
||||
_vm->_sound->playSound(_libraryBookSound2);
|
||||
|
||||
_vm->_gfx->updateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::libraryCombinationBookTurnRight() {
|
||||
// Turn page right
|
||||
if (_libraryBookPage + 1 < _libraryBookNumPages) {
|
||||
_tempVar++;
|
||||
|
||||
if (_tempVar <= 5) {
|
||||
_libraryBookPage++;
|
||||
} else {
|
||||
_libraryBookPage += 5;
|
||||
_tempVar = 5;
|
||||
}
|
||||
|
||||
_libraryBookPage = CLIP<uint16>(_libraryBookPage, 0, _libraryBookNumPages - 1);
|
||||
|
||||
Common::Rect rect = Common::Rect(157, 115, 544, 333);
|
||||
_vm->_gfx->copyImageToScreen(_libraryBookBaseImage + _libraryBookPage, rect);
|
||||
|
||||
if (_vm->_rnd->getRandomBit())
|
||||
_vm->_sound->playSound(_libraryBookSound1);
|
||||
else
|
||||
_vm->_sound->playSound(_libraryBookSound2);
|
||||
|
||||
_vm->_gfx->updateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::libraryCombinationBook_run() {
|
||||
uint32 time = _vm->_system->getMillis();
|
||||
if (time >= _libraryCombinationBookStart + 500) {
|
||||
if (_tempVar > 0) {
|
||||
libraryCombinationBookTurnRight();
|
||||
_libraryCombinationBookStart = time;
|
||||
} else if (_tempVar < 0) {
|
||||
libraryCombinationBookTurnLeft();
|
||||
_libraryCombinationBookStart = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_192(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
|
@ -1271,72 +1437,12 @@ void MystScriptParser_Myst::opcode_199(uint16 op, uint16 var, uint16 argc, uint1
|
|||
unknown(op, var, argc, argv);
|
||||
}
|
||||
|
||||
static struct {
|
||||
bool enabled;
|
||||
|
||||
uint16 var;
|
||||
uint16 imageCount;
|
||||
uint16 imageBaseId;
|
||||
uint16 soundDecrement;
|
||||
uint16 soundIncrement;
|
||||
} g_opcode200Parameters;
|
||||
|
||||
void MystScriptParser_Myst::opcode_200_run() {
|
||||
static uint16 lastImageIndex = 0;
|
||||
|
||||
if (g_opcode200Parameters.enabled) {
|
||||
uint16 curImageIndex = _vm->_varStore->getVar(g_opcode200Parameters.var);
|
||||
|
||||
if (curImageIndex >= g_opcode200Parameters.imageCount) {
|
||||
curImageIndex = g_opcode200Parameters.imageCount - 1;
|
||||
_vm->_varStore->setVar(g_opcode200Parameters.var, curImageIndex);
|
||||
}
|
||||
|
||||
Common::Rect rect;
|
||||
|
||||
// HACK: Think these images are centered on screen (when smaller than full screen),
|
||||
// and since no _gfx call for image size, hack this to deal with this case for now...
|
||||
if (_vm->getCurCard() == 4059)
|
||||
rect = Common::Rect(157, 115, 544, 333);
|
||||
else
|
||||
rect = Common::Rect(0, 0, 544, 333);
|
||||
|
||||
if (curImageIndex != lastImageIndex)
|
||||
_vm->_gfx->copyImageToScreen(g_opcode200Parameters.imageBaseId + curImageIndex, rect);
|
||||
|
||||
// TODO: Comparison with original engine shows that this simple solution
|
||||
// may not be the correct one and the choice of which sound
|
||||
// may be more complicated or even random..
|
||||
if (curImageIndex < lastImageIndex && g_opcode200Parameters.soundDecrement != 0)
|
||||
_vm->_sound->playSound(g_opcode200Parameters.soundDecrement);
|
||||
else if (curImageIndex > lastImageIndex && g_opcode200Parameters.soundIncrement != 0)
|
||||
_vm->_sound->playSound(g_opcode200Parameters.soundIncrement);
|
||||
|
||||
lastImageIndex = curImageIndex;
|
||||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_200_disable() {
|
||||
g_opcode200Parameters.enabled = false;
|
||||
g_opcode200Parameters.var = 0;
|
||||
g_opcode200Parameters.imageCount = 0;
|
||||
g_opcode200Parameters.imageBaseId = 0;
|
||||
g_opcode200Parameters.soundDecrement = 0;
|
||||
g_opcode200Parameters.soundIncrement = 0;
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_200(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
if (argc == 4) {
|
||||
g_opcode200Parameters.var = var;
|
||||
g_opcode200Parameters.imageCount = argv[0];
|
||||
g_opcode200Parameters.imageBaseId = argv[1];
|
||||
g_opcode200Parameters.soundDecrement = argv[2];
|
||||
g_opcode200Parameters.soundIncrement = argv[3];
|
||||
g_opcode200Parameters.enabled = true;
|
||||
|
||||
_vm->_varStore->setVar(var, 0);
|
||||
} else
|
||||
unknown(op, var, argc, argv);
|
||||
void MystScriptParser_Myst::o_libraryBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
_libraryBookPage = 0;
|
||||
_libraryBookNumPages = argv[0];
|
||||
_libraryBookBaseImage = argv[1];
|
||||
_libraryBookSound1 = argv[2];
|
||||
_libraryBookSound2 = argv[3];
|
||||
}
|
||||
|
||||
static struct {
|
||||
|
@ -1482,44 +1588,27 @@ void MystScriptParser_Myst::opcode_208(uint16 op, uint16 var, uint16 argc, uint1
|
|||
unknown(op, var, argc, argv);
|
||||
}
|
||||
|
||||
static struct {
|
||||
uint16 soundId;
|
||||
void MystScriptParser_Myst::libraryBookcaseTransform_run(void) {
|
||||
if (_libraryBookcaseChanged) {
|
||||
_libraryBookcaseChanged = false;
|
||||
_libraryBookcaseMoving = false;
|
||||
|
||||
bool enabled;
|
||||
} g_opcode209Parameters;
|
||||
|
||||
void MystScriptParser_Myst::opcode_209_run(void) {
|
||||
static bool enabledLast;
|
||||
|
||||
if (g_opcode209Parameters.enabled) {
|
||||
// Used for Card 4334 and 4348 (Myst Library Bookcase Door)
|
||||
if (!enabledLast) {
|
||||
// TODO: If Variable changed...
|
||||
_vm->_sound->playSound(g_opcode209Parameters.soundId);
|
||||
}
|
||||
|
||||
// TODO: Code to trigger Type 6 to play movie...
|
||||
// Play transform sound and video
|
||||
_vm->_sound->playSound(_libraryBookcaseSoundId);
|
||||
_libraryBookcaseMovie->playMovie();
|
||||
}
|
||||
|
||||
enabledLast = g_opcode209Parameters.enabled;
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_209_disable(void) {
|
||||
g_opcode209Parameters.enabled = false;
|
||||
void MystScriptParser_Myst::o_libraryBookcaseTransform_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
if (_libraryBookcaseChanged) {
|
||||
MystResourceType7 *resource = static_cast<MystResourceType7 *>(_invokingResource);
|
||||
_libraryBookcaseMovie = static_cast<MystResourceType6 *>(resource->getSubResource(getVar(0)));
|
||||
_libraryBookcaseSoundId = argv[0];
|
||||
_libraryBookcaseMoving = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::opcode_209(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
||||
varUnusedCheck(op, var);
|
||||
|
||||
// Used for Card 4334 and 4348 (Myst Library Bookcase Door)
|
||||
if (argc == 1) {
|
||||
g_opcode209Parameters.soundId = argv[0];
|
||||
g_opcode209Parameters.enabled = true;
|
||||
} else
|
||||
unknown(op, var, argc, argv);
|
||||
}
|
||||
|
||||
void MystScriptParser_Myst::o_generatorControlRoom_run(void) {
|
||||
void MystScriptParser_Myst::generatorControlRoom_run(void) {
|
||||
MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
|
||||
|
||||
if (_generatorVoltage == myst.generatorVoltage) {
|
||||
|
|
|
@ -48,9 +48,9 @@ public:
|
|||
private:
|
||||
void setupOpcodes();
|
||||
uint16 getVar(uint16 var);
|
||||
void toggleVar(uint16 var);
|
||||
bool setVarValue(uint16 var, uint16 value);
|
||||
|
||||
void opcode_200_run();
|
||||
void opcode_200_disable();
|
||||
void opcode_201_run();
|
||||
void opcode_201_disable();
|
||||
void opcode_202_run();
|
||||
|
@ -59,16 +59,17 @@ private:
|
|||
void opcode_203_disable();
|
||||
void opcode_205_run();
|
||||
void opcode_205_disable();
|
||||
void opcode_209_run();
|
||||
void opcode_209_disable();
|
||||
void o_generatorControlRoom_run();
|
||||
void libraryBookcaseTransform_run();
|
||||
void generatorControlRoom_run();
|
||||
void opcode_211_run();
|
||||
void opcode_211_disable();
|
||||
void opcode_212_run();
|
||||
void opcode_212_disable();
|
||||
void libraryCombinationBook_run();
|
||||
|
||||
DECLARE_OPCODE(opcode_101);
|
||||
DECLARE_OPCODE(opcode_102);
|
||||
|
||||
DECLARE_OPCODE(o_libraryBookPageTurnLeft);
|
||||
DECLARE_OPCODE(o_libraryBookPageTurnRight);
|
||||
DECLARE_OPCODE(opcode_103);
|
||||
DECLARE_OPCODE(opcode_104);
|
||||
DECLARE_OPCODE(opcode_105);
|
||||
|
@ -117,7 +118,7 @@ private:
|
|||
DECLARE_OPCODE(opcode_175);
|
||||
DECLARE_OPCODE(opcode_176);
|
||||
DECLARE_OPCODE(opcode_177);
|
||||
DECLARE_OPCODE(opcode_180);
|
||||
DECLARE_OPCODE(o_libraryCombinationBookStop);
|
||||
DECLARE_OPCODE(opcode_181);
|
||||
DECLARE_OPCODE(opcode_182);
|
||||
DECLARE_OPCODE(opcode_183);
|
||||
|
@ -126,8 +127,8 @@ private:
|
|||
DECLARE_OPCODE(opcode_186);
|
||||
DECLARE_OPCODE(opcode_188);
|
||||
DECLARE_OPCODE(opcode_189);
|
||||
DECLARE_OPCODE(opcode_190);
|
||||
DECLARE_OPCODE(opcode_191);
|
||||
DECLARE_OPCODE(o_libraryCombinationBookStartRight);
|
||||
DECLARE_OPCODE(o_libraryCombinationBookStartLeft);
|
||||
DECLARE_OPCODE(opcode_192);
|
||||
DECLARE_OPCODE(opcode_194);
|
||||
DECLARE_OPCODE(opcode_195);
|
||||
|
@ -136,7 +137,7 @@ private:
|
|||
DECLARE_OPCODE(opcode_198);
|
||||
DECLARE_OPCODE(opcode_199);
|
||||
|
||||
DECLARE_OPCODE(opcode_200);
|
||||
DECLARE_OPCODE(o_libraryBook_init);
|
||||
DECLARE_OPCODE(opcode_201);
|
||||
DECLARE_OPCODE(opcode_202);
|
||||
DECLARE_OPCODE(opcode_203);
|
||||
|
@ -144,7 +145,7 @@ private:
|
|||
DECLARE_OPCODE(opcode_205);
|
||||
DECLARE_OPCODE(opcode_206);
|
||||
DECLARE_OPCODE(opcode_208);
|
||||
DECLARE_OPCODE(opcode_209);
|
||||
DECLARE_OPCODE(o_libraryBookcaseTransform_init);
|
||||
DECLARE_OPCODE(o_generatorControlRoom_init);
|
||||
DECLARE_OPCODE(opcode_211);
|
||||
DECLARE_OPCODE(opcode_212);
|
||||
|
@ -182,12 +183,28 @@ private:
|
|||
uint16 _rocketSliderSound; // 294
|
||||
uint16 _rocketLeverPosition; // 296
|
||||
|
||||
bool _libraryCombinationBookPagesTurning;
|
||||
uint32 _libraryCombinationBookStart; // 8
|
||||
int16 _libraryBookPage; // 86
|
||||
uint16 _libraryBookNumPages; // 88
|
||||
uint16 _libraryBookBaseImage; // 90
|
||||
|
||||
bool _libraryBookcaseMoving;
|
||||
MystResourceType6 *_libraryBookcaseMovie; // 104
|
||||
uint16 _libraryBookcaseSoundId; // 284
|
||||
bool _libraryBookcaseChanged; // 288
|
||||
uint16 _libraryBookSound1; // 298
|
||||
uint16 _libraryBookSound2; // 300
|
||||
|
||||
void generatorRedrawRocket();
|
||||
void generatorButtonValue(MystResource *button, uint16 &offset, uint16 &value);
|
||||
|
||||
void rocketSliderMove();
|
||||
uint16 rocketSliderGetSound(uint16 pos);
|
||||
void rocketCheckSolution();
|
||||
|
||||
void libraryCombinationBookTurnRight();
|
||||
void libraryCombinationBookTurnLeft();
|
||||
};
|
||||
|
||||
} // End of namespace Mohawk
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue