diff options
Diffstat (limited to 'engines/adl')
-rw-r--r-- | engines/adl/adl.cpp | 9 | ||||
-rw-r--r-- | engines/adl/adl.h | 1 | ||||
-rw-r--r-- | engines/adl/adl_v2.cpp | 7 | ||||
-rw-r--r-- | engines/adl/adl_v2.h | 3 | ||||
-rw-r--r-- | engines/adl/adl_v4.cpp | 2 | ||||
-rw-r--r-- | engines/adl/adl_v5.cpp | 25 | ||||
-rw-r--r-- | engines/adl/hires6.cpp | 21 |
7 files changed, 49 insertions, 19 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index 34e398de91..58d5fa9e67 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -55,6 +55,7 @@ AdlEngine::AdlEngine(OSystem *syst, const AdlGameDescription *gd) : _dumpFile(nullptr), _display(nullptr), _graphics(nullptr), + _textMode(false), _isRestarting(false), _isRestoring(false), _isQuitting(false), @@ -911,10 +912,6 @@ byte AdlEngine::convertKey(uint16 ascii) const { } Common::String AdlEngine::getLine() { - // Original engine uses a global here, which isn't reset between - // calls and may not match actual mode - bool textMode = false; - while (1) { Common::String line = inputString(APPLECHAR('?')); @@ -922,8 +919,8 @@ Common::String AdlEngine::getLine() { return ""; if ((byte)line[0] == ('\r' | 0x80)) { - textMode = !textMode; - _display->setMode(textMode ? DISPLAY_MODE_TEXT : DISPLAY_MODE_MIXED); + _textMode = !_textMode; + _display->setMode(_textMode ? DISPLAY_MODE_TEXT : DISPLAY_MODE_MIXED); continue; } diff --git a/engines/adl/adl.h b/engines/adl/adl.h index 75df3395d7..d71d40816e 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -348,6 +348,7 @@ protected: Display *_display; GraphicsMan *_graphics; + bool _textMode; // Opcodes typedef Common::Functor1<ScriptEnv &, int> Opcode; diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index 9653e2e40b..272e7801e7 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -37,6 +37,7 @@ AdlEngine_v2::~AdlEngine_v2() { AdlEngine_v2::AdlEngine_v2(OSystem *syst, const AdlGameDescription *gd) : AdlEngine(syst, gd), _linesPrinted(0), + _maxLines(4), _disk(nullptr), _itemRemoved(false), _roomOnScreen(0), @@ -151,9 +152,11 @@ void AdlEngine_v2::checkTextOverflow(char c) { ++_linesPrinted; - if (_linesPrinted < 4) - return; + if (_linesPrinted >= _maxLines) + handleTextOverflow(); +} +void AdlEngine_v2::handleTextOverflow() { _linesPrinted = 0; _display->updateTextScreen(); bell(); diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h index f0af9eba22..5447974a2e 100644 --- a/engines/adl/adl_v2.h +++ b/engines/adl/adl_v2.h @@ -62,6 +62,7 @@ protected: int askForSlot(const Common::String &question); void checkTextOverflow(char c); + void handleTextOverflow(); int o2_isFirstTime(ScriptEnv &e); int o2_isRandomGT(ScriptEnv &e); @@ -85,7 +86,7 @@ protected: Common::String restoreInsert, restoreReplace; } _strings_v2; - uint _linesPrinted; + uint _linesPrinted, _maxLines; DiskImage *_disk; Common::Array<DataBlockPtr> _itemPics; bool _itemRemoved; diff --git a/engines/adl/adl_v4.cpp b/engines/adl/adl_v4.cpp index 8370bead6f..a5d2de264d 100644 --- a/engines/adl/adl_v4.cpp +++ b/engines/adl/adl_v4.cpp @@ -127,7 +127,7 @@ void AdlEngine_v4::loadState(Common::ReadStream &stream) { if (size != expectedSize) error("Variable count mismatch (expected %i; found %i)", expectedSize, size); - for (uint i = getRegion(1).vars.size(); i < size; ++i) + for (uint i = getRegion(1).vars.size(); i < _state.vars.size(); ++i) _state.vars[i] = stream.readByte(); if (stream.err() || stream.eos()) diff --git a/engines/adl/adl_v5.cpp b/engines/adl/adl_v5.cpp index be0c31a64c..011ef88848 100644 --- a/engines/adl/adl_v5.cpp +++ b/engines/adl/adl_v5.cpp @@ -85,12 +85,12 @@ void AdlEngine_v5::setupOpcodeTables() { Opcode(o5_dummy); Opcode(o5_setTextMode); // 0x0c - Opcode(o2_moveAllItems); + Opcode(o4_moveAllItems); Opcode(o1_quit); Opcode(o5_dummy); - Opcode(o2_save); + Opcode(o4_save); // 0x10 - Opcode(o2_restore); + Opcode(o4_restore); Opcode(o1_restart); Opcode(o5_setRegionRoom); Opcode(o5_dummy); @@ -154,13 +154,28 @@ int AdlEngine_v5::o5_setTextMode(ScriptEnv &e) { // 2: 24-line mode switch (e.arg(1)) { + case 1: + if (_linesPrinted != 0) { + _display->printChar(APPLECHAR(' ')); + handleTextOverflow(); + _display->moveCursorTo(Common::Point(0, 23)); + _maxLines = 4; + } + return 1; + case 2: + _textMode = true; + _display->setMode(DISPLAY_MODE_TEXT); + _display->home(); + _maxLines = 24; + _linesPrinted = 0; + return 1; case 3: // We re-use the restarting flag here, to simulate a long jump _isRestarting = true; return -1; + default: + error("Invalid text mode %d", e.arg(1)); } - - return 1; } int AdlEngine_v5::o5_setRegionRoom(ScriptEnv &e) { diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp index 91ab16313b..01de061584 100644 --- a/engines/adl/hires6.cpp +++ b/engines/adl/hires6.cpp @@ -50,6 +50,8 @@ private: void showRoom(); Common::String formatVerbError(const Common::String &verb) const; Common::String formatNounError(const Common::String &verb, const Common::String &noun) const; + void loadState(Common::ReadStream &stream); + void saveState(Common::WriteStream &stream); // AdlEngine_v2 void printString(const Common::String &str); @@ -146,12 +148,9 @@ void HiRes6Engine::init() { _strings.lineFeeds = readStringAt(*stream, 0x408); - // Read opcode strings (TODO) _strings_v2.saveInsert = readStringAt(*stream, 0xad8); - readStringAt(*stream, 0xb95); // Confirm save - // _strings_v2.saveReplace + _strings_v2.saveReplace = readStringAt(*stream, 0xb95); _strings_v2.restoreInsert = readStringAt(*stream, 0xc07); - // _strings_v2.restoreReplace _strings.playAgain = readStringAt(*stream, 0xcdf, 0xff); _messageIds.cantGoThere = 249; @@ -275,6 +274,20 @@ Common::String HiRes6Engine::formatNounError(const Common::String &verb, const C return err; } +void HiRes6Engine::loadState(Common::ReadStream &stream) { + AdlEngine_v5::loadState(stream); + _state.moves = (getVar(39) << 8) | getVar(24); + setVar(39, 0); +} + +void HiRes6Engine::saveState(Common::WriteStream &stream) { + // Move counter is stuffed into variables, in order to save it + setVar(24, _state.moves & 0xff); + setVar(39, _state.moves >> 8); + AdlEngine_v5::saveState(stream); + setVar(39, 0); +} + void HiRes6Engine::printString(const Common::String &str) { Common::String s; uint found = 0; |