diff options
author | Bastien Bouclet | 2011-01-09 10:14:40 +0000 |
---|---|---|
committer | Bastien Bouclet | 2011-01-09 10:14:40 +0000 |
commit | 9265c85c4967fa3ae3efba1ca5fe0f315237052a (patch) | |
tree | 97e7e365b7242f4a666de97755829b1fe2d90dad | |
parent | cf94a99bb7551e8338d4d127094295deec1d489d (diff) | |
download | scummvm-rg350-9265c85c4967fa3ae3efba1ca5fe0f315237052a.tar.gz scummvm-rg350-9265c85c4967fa3ae3efba1ca5fe0f315237052a.tar.bz2 scummvm-rg350-9265c85c4967fa3ae3efba1ca5fe0f315237052a.zip |
MOHAWK: Implement minimal D'ni stack. Lacking movie control.
svn-id: r55180
-rw-r--r-- | engines/mohawk/myst_stacks/dni.cpp | 125 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/dni.h | 9 | ||||
-rw-r--r-- | engines/mohawk/myst_state.cpp | 35 | ||||
-rw-r--r-- | engines/mohawk/myst_state.h | 24 |
4 files changed, 95 insertions, 98 deletions
diff --git a/engines/mohawk/myst_stacks/dni.cpp b/engines/mohawk/myst_stacks/dni.cpp index e14ecc4b90..417fa90aa3 100644 --- a/engines/mohawk/myst_stacks/dni.cpp +++ b/engines/mohawk/myst_stacks/dni.cpp @@ -24,19 +24,19 @@ */ #include "mohawk/myst.h" +#include "mohawk/cursors.h" #include "mohawk/graphics.h" #include "mohawk/myst_areas.h" #include "mohawk/sound.h" #include "mohawk/video.h" #include "mohawk/myst_stacks/dni.h" -#include "gui/message.h" - namespace Mohawk { MystScriptParser_Dni::MystScriptParser_Dni(MohawkEngine_Myst *vm) : - MystScriptParser(vm), _state(_vm->_gameState->_dni) { + MystScriptParser(vm) { setupOpcodes(); + _notSeenAtrus = true; } MystScriptParser_Dni::~MystScriptParser_Dni() { @@ -47,10 +47,10 @@ MystScriptParser_Dni::~MystScriptParser_Dni() { void MystScriptParser_Dni::setupOpcodes() { // "Stack-Specific" Opcodes OPCODE(100, opcode_100); - OPCODE(101, opcode_101); + OPCODE(101, o_handPage); // "Init" Opcodes - OPCODE(200, opcode_200); + OPCODE(200, o_atrus_init); // "Exit" Opcodes OPCODE(300, opcode_300); @@ -59,81 +59,92 @@ void MystScriptParser_Dni::setupOpcodes() { #undef OPCODE void MystScriptParser_Dni::disablePersistentScripts() { + _atrusRunning = false; } void MystScriptParser_Dni::runPersistentScripts() { + if (_atrusRunning) + atrus_run(); } uint16 MystScriptParser_Dni::getVar(uint16 var) { switch(var) { -// case 0: // Atrus Gone (from across room) -// return 0; // Present -// return 1; // Absent -// case 1: // Myst Book Status -// return 0; // Not Usuable -// return 1; // Openable, but not linkable (Atrus Gone?) -// return 2; // Linkable -// case 2: // Music Type -// return 0; -// return 1; -// return 2; -// case 106: // Atrus Static Image State -// return 0; // Initial State -// return 1; // Holding Out Hand for Page -// return 2; // Gone, Book Open -// return 3; // Back #1 -// return 4; // Back #2 + case 0: // Atrus Gone (from across room) + return _globals.ending == 2; + case 1: // Myst Book Status + if (_globals.ending != 4) + return _globals.ending == 3; + else + return 2; // Linkable + case 2: // Music Type + if (_notSeenAtrus) { + _notSeenAtrus = false; + return _globals.ending != 4 && _globals.heldPage != 13; + } else + return 2; default: return MystScriptParser::getVar(var); } } void MystScriptParser_Dni::opcode_100(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - // Used in Card 5022 (Rocks) - varUnusedCheck(op, var); - - if (argc == 0) { - debugC(kDebugScript, "Opcode %d: Unknown Function", op); - - // TODO: Fill in Logic. - } else - unknown(op, var, argc, argv); + // Used in Card 5014 (Atrus) + debugC(kDebugScript, "Opcode %d: Stop persistent scripts", op); + // TODO: Stop persistent scripts } -void MystScriptParser_Dni::opcode_101(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void MystScriptParser_Dni::o_handPage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Hand page to Atrus", op); // Used in Card 5014 (Atrus) - // Hotspot Resource Used to hand Page to Atrus... - varUnusedCheck(op, var); - // TODO: Fill in Logic. + if (_globals.ending == 1) { + _globals.ending = 2; + _globals.heldPage = 0; + _vm->_cursor->setCursor(kDefaultMystCursor); + + // TODO: Complete, play movie end + } } -void MystScriptParser_Dni::opcode_200(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - varUnusedCheck(op, var); - // Used on Card 5014 - - // TODO: Logic for Atrus Reactions and Movies - if (false) { - // Var 0 used for Atrus Gone (from across room) 0 = Present, 1 = Not Present - // Var 1 used for Myst Book Status 0 = Not Usuable - // 1 = Openable, but not linkable (Atrus Gone?) - // 2 = Linkable - // Var 2 used for Music Type 0 to 2.. - // Var 106 used for Atrus Static Image State 0 = Initial State - // 1 = Holding Out Hand for Page - // 2 = Gone, Book Open - // 3 = Back #1 - // 4 = Back #2 - _vm->_video->playMovie(_vm->wrapMovieFilename("atr1nopg", kDniStack), 215, 77); - _vm->_video->playMovie(_vm->wrapMovieFilename("atr1page", kDniStack), 215, 77); - _vm->_video->playMovie(_vm->wrapMovieFilename("atrus2", kDniStack), 215, 77); - _vm->_video->playMovie(_vm->wrapMovieFilename("atrwrite", kDniStack), 215, 77); +void MystScriptParser_Dni::atrus_run() { + if (_globals.ending == 2) { + VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF); + if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle)) { + _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atrus2", kDniStack), 215, 77); + _globals.ending = 4; + _globals.bluePagesInBook = 63; + _globals.redPagesInBook = 63; + } + // TODO: Complete / fix + } else if (_globals.ending == 1) { + // TODO: Complete, loop atr1page end + } else if (_globals.ending != 3 && _globals.ending != 4) { + if (_globals.heldPage == 13) { + _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atr1page", kDniStack), 215, 77); + _globals.ending = 1; + + // TODO: Complete, movie control / looping + } else { + _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atr1nopg", kDniStack), 215, 77); + _globals.ending = 3; + + // TODO: Complete, movie control / looping + } + } else { + VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF); + if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle)) + _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atrwrite", kDniStack), 215, 77, true); } } +void MystScriptParser_Dni::o_atrus_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Atrus init", op); + + _atrusRunning = true; +} + void MystScriptParser_Dni::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) { // Used in Card 5014 (Atrus Writing) - varUnusedCheck(op, var); - // TODO: Fill in Logic. + // TODO: Stop persistent scripts } } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/dni.h b/engines/mohawk/myst_stacks/dni.h index f376fb2025..653e52037c 100644 --- a/engines/mohawk/myst_stacks/dni.h +++ b/engines/mohawk/myst_stacks/dni.h @@ -49,14 +49,17 @@ private: void setupOpcodes(); uint16 getVar(uint16 var); + void atrus_run(); + DECLARE_OPCODE(opcode_100); - DECLARE_OPCODE(opcode_101); + DECLARE_OPCODE(o_handPage); - DECLARE_OPCODE(opcode_200); + DECLARE_OPCODE(o_atrus_init); DECLARE_OPCODE(opcode_300); - MystGameState::Dni &_state; + bool _atrusRunning; + bool _notSeenAtrus; // 56 }; } // End of namespace Mohawk diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp index 8b845b3952..da1ca727f1 100644 --- a/engines/mohawk/myst_state.cpp +++ b/engines/mohawk/myst_state.cpp @@ -40,7 +40,6 @@ MystGameState::MystGameState(MohawkEngine_Myst *vm, Common::SaveFileManager *sav memset(&_mechanical, 0, sizeof(_mechanical)); memset(&_selenitic, 0, sizeof(_selenitic)); memset(&_stoneship, 0, sizeof(_stoneship)); - memset(&_dni, 0, sizeof(_dni)); // Unknown _globals.u0 = 2; @@ -140,7 +139,7 @@ void MystGameState::syncGameState(Common::Serializer &s, bool isME) { s.syncAsUint16LE(_globals.heldPage); s.syncAsUint16LE(_globals.u1); s.syncAsUint16LE(_globals.transitions); - s.syncAsUint16LE(_globals.ending); + s.syncAsUint16LE(_globals.zipMode); s.syncAsUint16LE(_globals.redPagesInBook); s.syncAsUint16LE(_globals.bluePagesInBook); @@ -289,36 +288,26 @@ void MystGameState::syncGameState(Common::Serializer &s, bool isME) { s.syncAsUint16LE(_stoneship.generatorPowerLevel[i]); // D'ni - s.syncAsUint16LE(_dni.outcomeState); + s.syncAsUint16LE(_globals.ending); // Reading unknown region... // When Zero Value regions are included, these are 5 blocks of // 41 uint16 values. - for (byte i = 0; i < 31; i++) - s.syncAsUint16LE(unknownMyst[i]); - - s.skip(20); - - for (byte i = 0; i < 37; i++) - s.syncAsUint16LE(unknownChannelwood[i]); - - s.skip(8); - - for (byte i = 0; i < 18; i++) - s.syncAsUint16LE(unknownMech[i]); - - s.skip(46); + for (byte i = 0; i < 41; i++) + s.syncAsUint16LE(mystReachableZipDests[i]); - for (byte i = 0; i < 30; i++) - s.syncAsUint16LE(unknownSelenitic[i]); + for (byte i = 0; i < 41; i++) + s.syncAsUint16LE(channelwoodReachableZipDests[i]); - s.skip(22); + for (byte i = 0; i < 41; i++) + s.syncAsUint16LE(mechReachableZipDests[i]); - for (byte i = 0; i < 22; i++) - s.syncAsUint16LE(unknownStoneship[i]); + for (byte i = 0; i < 41; i++) + s.syncAsUint16LE(seleniticReachableZipDests[i]); - s.skip(38); + for (byte i = 0; i < 41; i++) + s.syncAsUint16LE(stoneshipReachableZipDests[i]); if ((isME && s.bytesSynced() != 664) || (!isME && s.bytesSynced() != 601)) warning("Unexpected File Position 0x%03X At End of Save/Load", s.bytesSynced()); diff --git a/engines/mohawk/myst_state.h b/engines/mohawk/myst_state.h index 2787efac4f..400f379502 100644 --- a/engines/mohawk/myst_state.h +++ b/engines/mohawk/myst_state.h @@ -64,9 +64,10 @@ public: uint16 heldPage; uint16 u1; uint16 transitions; - uint16 ending; + uint16 zipMode; uint16 redPagesInBook; uint16 bluePagesInBook; + uint16 ending; } _globals; /* 50 Myst Specific Variables : @@ -268,24 +269,17 @@ public: uint16 generatorPowerLevel[5]; } _stoneship; - /* 1 Dunny Specific Variable : - 0 = Outcome State - */ - struct Dni { - uint16 outcomeState; - } _dni; - - // The values in these regions seem to be lists of resource IDs - // which correspond to VIEW resources i.e. cards - uint16 unknownMyst[31]; + // The values in these regions are lists of VIEW resources + // which correspond to visited zip destinations + uint16 mystReachableZipDests[41]; - uint16 unknownChannelwood[37]; + uint16 channelwoodReachableZipDests[41]; - uint16 unknownMech[18]; + uint16 mechReachableZipDests[41]; - uint16 unknownSelenitic[30]; + uint16 seleniticReachableZipDests[41]; - uint16 unknownStoneship[22]; + uint16 stoneshipReachableZipDests[41]; private: void syncGameState(Common::Serializer &s, bool isME); |