[Scummvm-cvs-logs] scummvm master -> df838f50ebdc4005dc07df263cead32a4c398d4e

waltervn walter at vanniftrik-it.nl
Sun Aug 21 13:38:17 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
df838f50eb ADL: Add "current picture" variable to state


Commit: df838f50ebdc4005dc07df263cead32a4c398d4e
    https://github.com/scummvm/scummvm/commit/df838f50ebdc4005dc07df263cead32a4c398d4e
Author: Walter van Niftrik (walter at scummvm.org)
Date: 2016-08-21T12:41:31+02:00

Commit Message:
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.

Changed paths:
    engines/adl/adl.cpp
    engines/adl/adl.h
    engines/adl/adl_v2.cpp
    engines/adl/adl_v2.h
    engines/adl/adl_v3.cpp
    engines/adl/hires1.cpp
    engines/adl/hires6.cpp



diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 83181c9..1959560 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 c9d77fc..89cdabe 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 4fdf796..e18f333 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 f18972b..4a473e9 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 623db66..005478c 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 096d8ef..26565c0 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 465538f..e9df7b5 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)






More information about the Scummvm-git-logs mailing list