diff options
author | Walter van Niftrik | 2016-08-21 12:27:45 +0200 |
---|---|---|
committer | Walter van Niftrik | 2016-08-21 12:41:31 +0200 |
commit | df838f50ebdc4005dc07df263cead32a4c398d4e (patch) | |
tree | d07ff6d5ffb03f68403b1d10fdfd40e23df4661a /engines/adl | |
parent | ff0bc115b57dc19f4860014bc3c7d72b67c9ce38 (diff) | |
download | scummvm-rg350-df838f50ebdc4005dc07df263cead32a4c398d4e.tar.gz scummvm-rg350-df838f50ebdc4005dc07df263cead32a4c398d4e.tar.bz2 scummvm-rg350-df838f50ebdc4005dc07df263cead32a4c398d4e.zip |
ADL: Add "current picture" variable to state
This mimics the behavior of the original engine. Note that for hires2, this
patch adds some glitches that are also present in the original, and removes
some glitches that are not.
Diffstat (limited to 'engines/adl')
-rw-r--r-- | engines/adl/adl.cpp | 7 | ||||
-rw-r--r-- | engines/adl/adl.h | 3 | ||||
-rw-r--r-- | engines/adl/adl_v2.cpp | 28 | ||||
-rw-r--r-- | engines/adl/adl_v2.h | 2 | ||||
-rw-r--r-- | engines/adl/adl_v3.cpp | 4 | ||||
-rw-r--r-- | engines/adl/hires1.cpp | 1 | ||||
-rw-r--r-- | engines/adl/hires6.cpp | 2 |
7 files changed, 37 insertions, 10 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index 83181c9847..19595606e1 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -661,6 +661,11 @@ Common::Error AdlEngine::loadGameState(int slot) { _state.rooms[i].isFirstTime = inFile->readByte(); } + // NOTE: _state.curPicture is part of the save state in the original engine. We + // reconstruct it instead. This is believed to be safe for at least hires 0-2, but + // this may need to be re-evaluated for later games. + _state.curPicture = _state.rooms[_state.room].curPicture; + size = inFile->readUint32BE(); if (size != _state.items.size()) error("Item count mismatch (expected %i; found %i)", _state.items.size(), size); @@ -951,7 +956,7 @@ int AdlEngine::o1_isVarEQ(ScriptEnv &e) { int AdlEngine::o1_isCurPicEQ(ScriptEnv &e) { OP_DEBUG_1("\t&& GET_CURPIC() == %d", e.arg(1)); - if (getCurRoom().curPicture == e.arg(1)) + if (_state.curPicture == e.arg(1)) return 1; return -1; diff --git a/engines/adl/adl.h b/engines/adl/adl.h index c9d77fcc62..89cdabe384 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -165,11 +165,12 @@ struct State { Common::Array<byte> vars; byte room; + byte curPicture; uint16 moves; bool isDark; Time time; - State() : room(1), moves(1), isDark(false) { } + State() : room(1), curPicture(0), moves(1), isDark(false) { } }; typedef Common::List<Command> Commands; diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index 4fdf796701..e18f3339f8 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -79,9 +79,9 @@ void AdlEngine_v2::setupOpcodeTables() { Opcode(o1_listInv); Opcode(o2_moveItem); Opcode(o1_setRoom); - Opcode(o1_setCurPic); + Opcode(o2_setCurPic); // 0x08 - Opcode(o1_setPic); + Opcode(o2_setPic); Opcode(o1_printMsg); Opcode(o1_setLight); Opcode(o1_setDark); @@ -250,6 +250,8 @@ void AdlEngine_v2::loadRoom(byte roomNr) { void AdlEngine_v2::showRoom() { bool redrawPic = false; + _state.curPicture = getCurRoom().curPicture; + if (_state.room != _roomOnScreen) { loadRoom(_state.room); clearScreen(); @@ -257,15 +259,15 @@ void AdlEngine_v2::showRoom() { if (!_state.isDark) redrawPic = true; } else { - if (getCurRoom().curPicture != _picOnScreen || _itemRemoved) + if (_state.curPicture != _picOnScreen || _itemRemoved) redrawPic = true; } if (redrawPic) { _roomOnScreen = _state.room; - _picOnScreen = getCurRoom().curPicture; + _picOnScreen = _state.curPicture; - drawPic(getCurRoom().curPicture); + drawPic(_state.curPicture); _itemRemoved = false; _itemsOnScreen = 0; @@ -336,7 +338,7 @@ void AdlEngine_v2::drawItems() { Common::Array<byte>::const_iterator pic; for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) { - if (*pic == getCurRoom().curPicture || *pic == IDI_ANY) { + if (*pic == _state.curPicture || *pic == IDI_ANY) { drawItem(*item, item->position); break; } @@ -425,6 +427,20 @@ int AdlEngine_v2::o2_moveItem(ScriptEnv &e) { return 2; } +int AdlEngine_v2::o2_setCurPic(ScriptEnv &e) { + OP_DEBUG_1("\tSET_CURPIC(%d)", e.arg(1)); + + getCurRoom().curPicture = _state.curPicture = e.arg(1); + return 1; +} + +int AdlEngine_v2::o2_setPic(ScriptEnv &e) { + OP_DEBUG_1("\tSET_PIC(%d)", e.arg(1)); + + getCurRoom().picture = getCurRoom().curPicture = _state.curPicture = e.arg(1); + return 1; +} + int AdlEngine_v2::o2_moveAllItems(ScriptEnv &e) { OP_DEBUG_2("\tMOVE_ALL_ITEMS(%s, %s)", itemRoomStr(e.arg(1)).c_str(), itemRoomStr(e.arg(2)).c_str()); diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h index f18972b74b..4a473e9b1f 100644 --- a/engines/adl/adl_v2.h +++ b/engines/adl/adl_v2.h @@ -64,6 +64,8 @@ protected: int o2_isCarryingSomething(ScriptEnv &e); int o2_moveItem(ScriptEnv &e); + int o2_setCurPic(ScriptEnv &e); + int o2_setPic(ScriptEnv &e); int o2_moveAllItems(ScriptEnv &e); int o2_save(ScriptEnv &e); int o2_restore(ScriptEnv &e); diff --git a/engines/adl/adl_v3.cpp b/engines/adl/adl_v3.cpp index 623db661bc..005478c376 100644 --- a/engines/adl/adl_v3.cpp +++ b/engines/adl/adl_v3.cpp @@ -110,9 +110,9 @@ void AdlEngine_v3::setupOpcodeTables() { Opcode(o1_listInv); Opcode(o3_moveItem); Opcode(o1_setRoom); - Opcode(o1_setCurPic); + Opcode(o2_setCurPic); // 0x08 - Opcode(o1_setPic); + Opcode(o2_setPic); Opcode(o1_printMsg); Opcode(o3_dummy); Opcode(o3_setTextMode); diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp index 096d8ef496..26565c03c3 100644 --- a/engines/adl/hires1.cpp +++ b/engines/adl/hires1.cpp @@ -338,6 +338,7 @@ void HiRes1Engine::loadRoom(byte roomNr) { } void HiRes1Engine::showRoom() { + _state.curPicture = getCurRoom().curPicture; clearScreen(); loadRoom(_state.room); diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp index 465538fe26..e9df7b513a 100644 --- a/engines/adl/hires6.cpp +++ b/engines/adl/hires6.cpp @@ -317,6 +317,8 @@ void HiRes6Engine::initGameState() { } void HiRes6Engine::showRoom() { + _state.curPicture = getCurRoom().curPicture; + bool redrawPic = false; if (getVar(26) == 0xfe) |