[Scummvm-git-logs] scummvm master -> 0f56a48fe4b3e1e7de404bfbde3cd0328fbb38b1

dreammaster paulfgilbert at gmail.com
Thu Oct 22 03:32:24 UTC 2020


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

Summary:
7c6e5c0f15 GLK: COMPREHEND: Properly get item for opcodes
facceff957 GLK: COMPREHEND: Further v2 opcode verification
8b01000876 GLK: COMPREHEND: Proper handling of specified noun in v2 opcodes
0f56a48fe4 GLK: COMPREHEND: Handling of v2 inverted comparisons


Commit: 7c6e5c0f153e4f7c356a48cf85445484bc858dc7
    https://github.com/scummvm/scummvm/commit/7c6e5c0f153e4f7c356a48cf85445484bc858dc7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-10-21T20:26:00-07:00

Commit Message:
GLK: COMPREHEND: Properly get item for opcodes

Changed paths:
    engines/glk/comprehend/game_opcodes.cpp
    engines/glk/comprehend/game_opcodes.h


diff --git a/engines/glk/comprehend/game_opcodes.cpp b/engines/glk/comprehend/game_opcodes.cpp
index 9d4702b755..137b4eb63c 100644
--- a/engines/glk/comprehend/game_opcodes.cpp
+++ b/engines/glk/comprehend/game_opcodes.cpp
@@ -33,8 +33,6 @@ ComprehendGameOpcodes::ComprehendGameOpcodes() {
 	Common::fill(&_opcodeMap[0], &_opcodeMap[0x100], OPCODE_UNKNOWN);
 }
 
-#define GET_ITEM item = get_item(instr->_operand[0] - (_comprehendVersion == 2 ? 0 : 1))
-
 void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sentence *sentence,
 		FunctionState *func_state) {
 //	byte verb = sentence ? sentence->_formattedWords[0] : 0;
@@ -84,7 +82,7 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		break;
 
 	case OPCODE_HAVE_OBJECT:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state, item->_room == ROOM_INVENTORY);
 		break;
 
@@ -115,12 +113,12 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		break;
 
 	case OPCODE_OBJECT_IS_NOWHERE:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state, item->_room == ROOM_NOWHERE);
 		break;
 
 	case OPCODE_OBJECT_PRESENT:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state, item->_room == _currentRoom);
 		break;
 
@@ -191,7 +189,7 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		break;
 
 	case OPCODE_TAKE_OBJECT:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		move_object(item, ROOM_INVENTORY);
 		break;
 
@@ -419,18 +417,18 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_MOVE_OBJECT_TO_CURRENT_ROOM:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		move_object(item, _currentRoom);
 		break;
 
 	case OPCODE_OBJECT_IN_ROOM:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state,
 			item->_room == instr->_operand[1]);
 		break;
 
 	case OPCODE_OBJECT_NOT_IN_ROOM:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state, !item || item->_room != _currentRoom);
 		break;
 
@@ -440,7 +438,7 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_MOVE_OBJECT_TO_ROOM:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		move_object(item, instr->_operand[1]);
 		break;
 
@@ -488,7 +486,7 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_NOT_HAVE_OBJECT:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state,
 			item->_room != ROOM_INVENTORY);
 		break;
@@ -517,7 +515,7 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_OBJECT_IS_NOT_NOWHERE:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state, item->_room != ROOM_NOWHERE);
 		break;
 
@@ -527,12 +525,12 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_OBJECT_NOT_PRESENT:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state, !isItemPresent(item));
 		break;
 
 	case OPCODE_REMOVE_OBJECT:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		move_object(item, ROOM_NOWHERE);
 		break;
 
@@ -566,7 +564,7 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_DROP_OBJECT:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		move_object(item, _currentRoom);
 		break;
 
@@ -588,17 +586,17 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_SET_OBJECT_DESCRIPTION:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		item->_stringDesc = (instr->_operand[2] << 8) | instr->_operand[1];
 		break;
 
 	case OPCODE_SET_OBJECT_LONG_DESCRIPTION:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		item->_longString = (instr->_operand[2] << 8) | instr->_operand[1];
 		break;
 
 	case OPCODE_SET_OBJECT_GRAPHIC:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		item->_graphic = instr->_operand[1];
 		if (item->_room == _currentRoom)
 			_updateFlags |= UPDATE_GRAPHICS;
@@ -676,6 +674,10 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 	}
 }
 
+Item *ComprehendGameV1::getItem(const Instruction *instr, const Sentence *sentence) {
+	return get_item(instr->_operand[0] - (_comprehendVersion == 2 ? 0 : 1));
+}
+
 /*-------------------------------------------------------*/
 
 ComprehendGameV2::ComprehendGameV2() {
@@ -796,7 +798,7 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_OBJECT_CAN_TAKE:
-		GET_ITEM;
+		item = getItem(instr, sentence);
 		func_set_test_result(func_state, item->_flags & ITEMF_CAN_TAKE);
 		break;
 
@@ -811,13 +813,21 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 	}
 }
 
+Item *ComprehendGameV2::getItem(const Instruction *instr, const Sentence *sentence) {
+	if ((instr->_opcode & 0x30) == 0x30) {
+		byte noun = sentence ? sentence->_formattedWords[2] : 0;
+		return get_item_by_noun(noun);
+	} else {
+		return get_item(instr->_operand[0]);
+	}
+}
+
 byte ComprehendGameV2::getOpcode(const Instruction *instr) {
 	// Special pre-processing for opcodes
 	byte opcode = instr->_opcode;
 	if (!(opcode & 0x80))
 		opcode &= 0x3f;
 	if ((opcode & 0x30) == 0x30) {
-		// TODO: Check if getCurrentObjectRoom call in original is needed in ScummVM
 		opcode = (opcode & ~0x10) + 1;
 	}
 
diff --git a/engines/glk/comprehend/game_opcodes.h b/engines/glk/comprehend/game_opcodes.h
index bdd859976b..6dcbace6f7 100644
--- a/engines/glk/comprehend/game_opcodes.h
+++ b/engines/glk/comprehend/game_opcodes.h
@@ -38,6 +38,8 @@ protected:
 
 	void execute_opcode(const Instruction *instr, const Sentence *sentence, FunctionState *func_state) override;
 
+	virtual Item *getItem(const Instruction *instr, const Sentence *sentence) = 0;
+
 	void func_set_test_result(FunctionState *func_state, bool value);
 	bool isItemPresent(Item *item) const;
 public:
@@ -58,6 +60,7 @@ public:
 class ComprehendGameV1 : public ComprehendGameOpcodes {
 protected:
 	void execute_opcode(const Instruction *instr, const Sentence *sentence, FunctionState *func_state) override;
+	Item *getItem(const Instruction *instr, const Sentence *sentence) override;
 public:
 	ComprehendGameV1();
 };
@@ -68,6 +71,7 @@ public:
 class ComprehendGameV2 : public ComprehendGameOpcodes {
 protected:
 	void execute_opcode(const Instruction *instr, const Sentence *sentence, FunctionState *func_state) override;
+	Item *getItem(const Instruction *instr, const Sentence *sentence) override;
 public:
 	ComprehendGameV2();
 


Commit: facceff9575a3eeefaf88bebea84635e798d0e98
    https://github.com/scummvm/scummvm/commit/facceff9575a3eeefaf88bebea84635e798d0e98
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-10-21T20:26:00-07:00

Commit Message:
GLK: COMPREHEND: Further v2 opcode verification

Changed paths:
    engines/glk/comprehend/game_data.h
    engines/glk/comprehend/game_opcodes.cpp


diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index 2abbaebcbd..9c8525cb64 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -97,7 +97,6 @@ enum ScriptOpcode {
 	OPCODE_SET_OBJECT_DESCRIPTION,
 	OPCODE_SET_OBJECT_LONG_DESCRIPTION,
 	OPCODE_MOVE_DEFAULT,
-	OPCODE_MOVE_DIRECTION,
 	OPCODE_PRINT,
 	OPCODE_REMOVE_OBJECT,
 	OPCODE_SET_FLAG,
diff --git a/engines/glk/comprehend/game_opcodes.cpp b/engines/glk/comprehend/game_opcodes.cpp
index 137b4eb63c..1da9aac9a1 100644
--- a/engines/glk/comprehend/game_opcodes.cpp
+++ b/engines/glk/comprehend/game_opcodes.cpp
@@ -180,6 +180,11 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		_currentReplaceWord = instr->_operand[0] - 1;
 		break;
 
+	case OPCODE_SPECIAL:
+		// Game specific opcode
+		handleSpecialOpcode(instr->_operand[0]);
+		break;
+
 	case OPCODE_TAKE_CURRENT_OBJECT:
 		item = get_item_by_noun(noun);
 		if (!item)
@@ -409,13 +414,6 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 			console_println(stringLookup(STRING_CANT_GO).c_str());
 		break;
 
-	case OPCODE_MOVE_DIRECTION:
-		if (room->_direction[instr->_operand[0] - 1])
-			move_to(room->_direction[instr->_operand[0] - 1]);
-		else
-			console_println(stringLookup(STRING_CANT_GO).c_str());
-		break;
-
 	case OPCODE_MOVE_OBJECT_TO_CURRENT_ROOM:
 		item = getItem(instr, sentence);
 		move_object(item, _currentRoom);
@@ -659,11 +657,6 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		console_get_key();
 		break;
 
-	case OPCODE_SPECIAL:
-		// Game specific opcode
-		handleSpecialOpcode(instr->_operand[0]);
-		break;
-
 	case OPCODE_MOVE_DIR:
 		doMovementVerb(instr->_operand[0]);
 		break;
@@ -703,6 +696,7 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x85] = OPCODE_MOVE_TO_ROOM;
 	_opcodeMap[0x86] = OPCODE_VAR_ADD;
 	_opcodeMap[0x87] = OPCODE_SET_ROOM_DESCRIPTION;
+	_opcodeMap[0x89] = OPCODE_SPECIAL;
 	_opcodeMap[0x8a] = OPCODE_VAR_SUB;
 	_opcodeMap[0x8e] = OPCODE_PRINT;
 	_opcodeMap[0x92] = OPCODE_CALL_FUNC;
@@ -716,6 +710,7 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0xc5] = OPCODE_SET_STRING_REPLACEMENT3;
 	_opcodeMap[0xc9] = OPCODE_SET_STRING_REPLACEMENT1;
 	_opcodeMap[0xcd] = OPCODE_SET_STRING_REPLACEMENT2;
+	_opcodeMap[0xd1] = OPCODE_MOVE_DIR;
 	_opcodeMap[0xdd] = OPCODE_VAR_INC;
 	_opcodeMap[0xe5] = OPCODE_SET_CAN_TAKE;
 	_opcodeMap[0xe9] = OPCODE_CLEAR_CAN_TAKE;
@@ -737,7 +732,6 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x70] = OPCODE_CURRENT_OBJECT_NOT_PRESENT;
 	_opcodeMap[0x82] = OPCODE_MOVE_OBJECT_TO_ROOM;
 	_opcodeMap[0x84] = OPCODE_SAVE_ACTION;
-	_opcodeMap[0x89] = OPCODE_SPECIAL;
 	_opcodeMap[0x8b] = OPCODE_SET_OBJECT_DESCRIPTION;
 	_opcodeMap[0x8c] = OPCODE_MOVE_DEFAULT;
 	_opcodeMap[0x8f] = OPCODE_SET_OBJECT_LONG_DESCRIPTION;
@@ -747,11 +741,8 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x9d] = OPCODE_CLEAR_FLAG;
 	_opcodeMap[0x9e] = OPCODE_INVENTORY_ROOM;
 	_opcodeMap[0xa2] = OPCODE_SET_OBJECT_GRAPHIC;
-	_opcodeMap[0xb1] = OPCODE_MOVE_DIR;
-	_opcodeMap[0xb5] = OPCODE_DESCRIBE_CURRENT_OBJECT;
 	_opcodeMap[0xc2] = OPCODE_SET_ROOM_GRAPHIC;
 	_opcodeMap[0xc6] = OPCODE_SET_OBJECT_GRAPHIC;
-	_opcodeMap[0xd1] = OPCODE_MOVE_DIRECTION;
 	_opcodeMap[0xd5] = OPCODE_DRAW_ROOM;
 	_opcodeMap[0xd9] = OPCODE_DRAW_OBJECT;
 	_opcodeMap[0xe1] = OPCODE_MOVE_OBJECT_TO_CURRENT_ROOM;
@@ -764,6 +755,7 @@ ComprehendGameV2::ComprehendGameV2() {
 void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *sentence,
 		FunctionState *func_state) {
 	byte noun = sentence ? sentence->_formattedWords[2] : 0;
+	Room *room = get_room(_currentRoom);
 	Item *item;
 
 	switch (_opcodeMap[getOpcode(instr)]) {
@@ -792,6 +784,13 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 			_variables[instr->_operand[1]]);
 		break;
 
+	case OPCODE_MOVE_DIR:
+		if (room->_direction[instr->_operand[0] - 1])
+			move_to(room->_direction[instr->_operand[0] - 1]);
+		else
+			console_println(stringLookup(STRING_CANT_GO).c_str());
+		break;
+
 	case OPCODE_NOT_TAKEABLE:
 		item = get_item_by_noun(noun);
 		func_set_test_result(func_state, (item->_flags & ITEMF_WEIGHT_MASK) == ITEMF_WEIGHT_MASK);


Commit: 8b01000876495a5de23da7c224bd246e44cb704c
    https://github.com/scummvm/scummvm/commit/8b01000876495a5de23da7c224bd246e44cb704c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-10-21T20:26:00-07:00

Commit Message:
GLK: COMPREHEND: Proper handling of specified noun in v2 opcodes

Changed paths:
    engines/glk/comprehend/game.cpp
    engines/glk/comprehend/game.h
    engines/glk/comprehend/game_opcodes.cpp
    engines/glk/comprehend/game_opcodes.h


diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index d2dab2b370..c10e597795 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -365,6 +365,14 @@ Item *ComprehendGame::get_item_by_noun(byte noun) {
 	return NULL;
 }
 
+int ComprehendGame::get_item_id(byte noun) {
+	for (int i = 0; i < (int)_items.size(); i++)
+		if (_items[i]._word == noun)
+			return i;
+
+	return -1;
+}
+
 void ComprehendGame::update_graphics() {
 	Item *item;
 	Room *room;
diff --git a/engines/glk/comprehend/game.h b/engines/glk/comprehend/game.h
index 98aa386e70..153e1d3677 100644
--- a/engines/glk/comprehend/game.h
+++ b/engines/glk/comprehend/game.h
@@ -113,6 +113,7 @@ protected:
 	}
 
 	Item *get_item_by_noun(byte noun);
+	int get_item_id(byte noun);
 	void weighInventory();
 	size_t num_objects_in_room(int room);
 	void doMovementVerb(uint verbNum);
diff --git a/engines/glk/comprehend/game_opcodes.cpp b/engines/glk/comprehend/game_opcodes.cpp
index 1da9aac9a1..b4408bebe0 100644
--- a/engines/glk/comprehend/game_opcodes.cpp
+++ b/engines/glk/comprehend/game_opcodes.cpp
@@ -58,6 +58,10 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		item->_flags &= ~ITEMF_CAN_TAKE;
 		break;
 
+	case OPCODE_CLEAR_FLAG:
+		_flags[instr->_operand[0]] = false;
+		break;
+
 	case OPCODE_CLEAR_FLAG40:
 		item = get_item_by_noun(noun);
 		item->_flags &= ~ITEMF_UNKNOWN;
@@ -82,7 +86,7 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		break;
 
 	case OPCODE_HAVE_OBJECT:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		func_set_test_result(func_state, item->_room == ROOM_INVENTORY);
 		break;
 
@@ -113,15 +117,10 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		break;
 
 	case OPCODE_OBJECT_IS_NOWHERE:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		func_set_test_result(func_state, item->_room == ROOM_NOWHERE);
 		break;
 
-	case OPCODE_OBJECT_PRESENT:
-		item = getItem(instr, sentence);
-		func_set_test_result(func_state, item->_room == _currentRoom);
-		break;
-
 	case OPCODE_OR:
 		if (func_state->_orCount) {
 			func_state->_orCount += 2;
@@ -135,6 +134,11 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		console_println(instrStringLookup(instr->_operand[0], instr->_operand[1]).c_str());
 		break;
 
+	case OPCODE_REMOVE_OBJECT:
+		item = getItem(instr);
+		move_object(item, ROOM_NOWHERE);
+		break;
+
 	case OPCODE_SET_CAN_TAKE:
 		item = get_item_by_noun(noun);
 		item->_flags |= ITEMF_CAN_TAKE;
@@ -194,7 +198,7 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		break;
 
 	case OPCODE_TAKE_OBJECT:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		move_object(item, ROOM_INVENTORY);
 		break;
 
@@ -268,6 +272,10 @@ bool ComprehendGameOpcodes::isItemPresent(Item *item) const {
 		);
 }
 
+Item *ComprehendGameOpcodes::getItem(const Instruction *instr) {
+	return get_item(instr->_operand[0] - 1);
+}
+
 /*-------------------------------------------------------*/
 
 ComprehendGameV1::ComprehendGameV1() {
@@ -359,6 +367,16 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 			(item->_flags & ITEMF_WEIGHT_MASK) > _variables[VAR_INVENTORY_LIMIT]);
 		break;
 
+	case OPCODE_OBJECT_NOT_PRESENT:
+		item = getItem(instr);
+		func_set_test_result(func_state, !isItemPresent(item));
+		break;
+
+	case OPCODE_OBJECT_PRESENT:
+		item = getItem(instr);
+		func_set_test_result(func_state, item->_room == _currentRoom);
+		break;
+
 	case OPCODE_SET_STRING_REPLACEMENT3:
 		_currentReplaceWord = instr->_operand[0] - 1;
 		break;
@@ -415,18 +433,18 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_MOVE_OBJECT_TO_CURRENT_ROOM:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		move_object(item, _currentRoom);
 		break;
 
 	case OPCODE_OBJECT_IN_ROOM:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		func_set_test_result(func_state,
 			item->_room == instr->_operand[1]);
 		break;
 
 	case OPCODE_OBJECT_NOT_IN_ROOM:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		func_set_test_result(func_state, !item || item->_room != _currentRoom);
 		break;
 
@@ -436,7 +454,7 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_MOVE_OBJECT_TO_ROOM:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		move_object(item, instr->_operand[1]);
 		break;
 
@@ -484,7 +502,7 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_NOT_HAVE_OBJECT:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		func_set_test_result(func_state,
 			item->_room != ROOM_INVENTORY);
 		break;
@@ -513,7 +531,7 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_OBJECT_IS_NOT_NOWHERE:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		func_set_test_result(func_state, item->_room != ROOM_NOWHERE);
 		break;
 
@@ -522,16 +540,6 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		func_set_test_result(func_state, !isItemPresent(item));
 		break;
 
-	case OPCODE_OBJECT_NOT_PRESENT:
-		item = getItem(instr, sentence);
-		func_set_test_result(func_state, !isItemPresent(item));
-		break;
-
-	case OPCODE_REMOVE_OBJECT:
-		item = getItem(instr, sentence);
-		move_object(item, ROOM_NOWHERE);
-		break;
-
 	case OPCODE_REMOVE_CURRENT_OBJECT:
 		item = get_item_by_noun(noun);
 		move_object(item, ROOM_NOWHERE);
@@ -562,7 +570,7 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_DROP_OBJECT:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		move_object(item, _currentRoom);
 		break;
 
@@ -579,22 +587,18 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 			!_flags[instr->_operand[0]]);
 		break;
 
-	case OPCODE_CLEAR_FLAG:
-		_flags[instr->_operand[0]] = false;
-		break;
-
 	case OPCODE_SET_OBJECT_DESCRIPTION:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		item->_stringDesc = (instr->_operand[2] << 8) | instr->_operand[1];
 		break;
 
 	case OPCODE_SET_OBJECT_LONG_DESCRIPTION:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		item->_longString = (instr->_operand[2] << 8) | instr->_operand[1];
 		break;
 
 	case OPCODE_SET_OBJECT_GRAPHIC:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		item->_graphic = instr->_operand[1];
 		if (item->_room == _currentRoom)
 			_updateFlags |= UPDATE_GRAPHICS;
@@ -667,10 +671,6 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 	}
 }
 
-Item *ComprehendGameV1::getItem(const Instruction *instr, const Sentence *sentence) {
-	return get_item(instr->_operand[0] - (_comprehendVersion == 2 ? 0 : 1));
-}
-
 /*-------------------------------------------------------*/
 
 ComprehendGameV2::ComprehendGameV2() {
@@ -687,7 +687,7 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x19] = OPCODE_TEST_FLAG;
 	_opcodeMap[0x1d] = OPCODE_TEST_ROOM_FLAG;
 	_opcodeMap[0x20] = OPCODE_HAVE_CURRENT_OBJECT;
-	_opcodeMap[0x21] = OPCODE_OBJECT_PRESENT;
+	_opcodeMap[0x21] = OPCODE_OBJECT_NOT_PRESENT;
 	_opcodeMap[0x25] = OPCODE_NOT_TAKEABLE;
 	_opcodeMap[0x29] = OPCODE_INVENTORY_FULL;
 	_opcodeMap[0x2d] = OPCODE_OBJECT_CAN_TAKE;
@@ -701,6 +701,7 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x8e] = OPCODE_PRINT;
 	_opcodeMap[0x92] = OPCODE_CALL_FUNC;
 	_opcodeMap[0x99] = OPCODE_SET_FLAG;
+	_opcodeMap[0x9d] = OPCODE_CLEAR_FLAG;
 	_opcodeMap[0xa0] = OPCODE_TAKE_CURRENT_OBJECT;
 	_opcodeMap[0xa1] = OPCODE_CLEAR_FLAG40;
 	_opcodeMap[0xa5] = OPCODE_SET_FLAG40;
@@ -714,6 +715,7 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0xdd] = OPCODE_VAR_INC;
 	_opcodeMap[0xe5] = OPCODE_SET_CAN_TAKE;
 	_opcodeMap[0xe9] = OPCODE_CLEAR_CAN_TAKE;
+	_opcodeMap[0xed] = OPCODE_REMOVE_OBJECT;
 
 #if 0
 	_opcodeMap[0x09] = OPCODE_VAR_GT1;
@@ -728,7 +730,6 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x59] = OPCODE_TEST_NOT_FLAG;
 	_opcodeMap[0x5d] = OPCODE_TEST_NOT_ROOM_FLAG;
 	_opcodeMap[0x60] = OPCODE_NOT_HAVE_CURRENT_OBJECT;
-	_opcodeMap[0x61] = OPCODE_OBJECT_NOT_PRESENT;
 	_opcodeMap[0x70] = OPCODE_CURRENT_OBJECT_NOT_PRESENT;
 	_opcodeMap[0x82] = OPCODE_MOVE_OBJECT_TO_ROOM;
 	_opcodeMap[0x84] = OPCODE_SAVE_ACTION;
@@ -736,9 +737,7 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x8c] = OPCODE_MOVE_DEFAULT;
 	_opcodeMap[0x8f] = OPCODE_SET_OBJECT_LONG_DESCRIPTION;
 	_opcodeMap[0x90] = OPCODE_WAIT_KEY;
-	_opcodeMap[0x95] = OPCODE_REMOVE_OBJECT;
 	_opcodeMap[0x98] = OPCODE_TURN_TICK;
-	_opcodeMap[0x9d] = OPCODE_CLEAR_FLAG;
 	_opcodeMap[0x9e] = OPCODE_INVENTORY_ROOM;
 	_opcodeMap[0xa2] = OPCODE_SET_OBJECT_GRAPHIC;
 	_opcodeMap[0xc2] = OPCODE_SET_ROOM_GRAPHIC;
@@ -746,7 +745,6 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0xd5] = OPCODE_DRAW_ROOM;
 	_opcodeMap[0xd9] = OPCODE_DRAW_OBJECT;
 	_opcodeMap[0xe1] = OPCODE_MOVE_OBJECT_TO_CURRENT_ROOM;
-	_opcodeMap[0xed] = OPCODE_REMOVE_OBJECT;
 	_opcodeMap[0xf0] = OPCODE_DROP_CURRENT_OBJECT;
 	_opcodeMap[0xfc] = OPCODE_REMOVE_CURRENT_OBJECT;
 #endif
@@ -754,10 +752,20 @@ ComprehendGameV2::ComprehendGameV2() {
 
 void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *sentence,
 		FunctionState *func_state) {
+	Instruction instrCopy;
 	byte noun = sentence ? sentence->_formattedWords[2] : 0;
 	Room *room = get_room(_currentRoom);
 	Item *item;
 
+	if ((instr->_opcode & 0x30) == 0x30) {
+		// First operand comes from entered sentence noun, shifting out existing operands
+		instrCopy = *instr;
+		instrCopy._operand[2] = instrCopy._operand[1];
+		instrCopy._operand[1] = instrCopy._operand[0];
+		instrCopy._operand[0] = get_item_id(noun) + 1;
+		instr = &instrCopy;
+	}
+
 	switch (_opcodeMap[getOpcode(instr)]) {
 	case OPCODE_CLEAR_INVISIBLE:
 		item = get_item_by_noun(noun);
@@ -792,15 +800,20 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 		break;
 
 	case OPCODE_NOT_TAKEABLE:
-		item = get_item_by_noun(noun);
+		item = getItem(instr);
 		func_set_test_result(func_state, (item->_flags & ITEMF_WEIGHT_MASK) == ITEMF_WEIGHT_MASK);
 		break;
 
 	case OPCODE_OBJECT_CAN_TAKE:
-		item = getItem(instr, sentence);
+		item = getItem(instr);
 		func_set_test_result(func_state, item->_flags & ITEMF_CAN_TAKE);
 		break;
 
+	case OPCODE_OBJECT_NOT_PRESENT:
+		item = getItem(instr);
+		func_set_test_result(func_state, item->_room != _currentRoom);
+		break;
+
 	case OPCODE_SET_STRING_REPLACEMENT3:
 		warning("TODO: Figure out OPCODE_SET_STRING_REPLACEMENT3 offset");
 		_currentReplaceWord = instr->_operand[0] - 1;
@@ -812,15 +825,6 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 	}
 }
 
-Item *ComprehendGameV2::getItem(const Instruction *instr, const Sentence *sentence) {
-	if ((instr->_opcode & 0x30) == 0x30) {
-		byte noun = sentence ? sentence->_formattedWords[2] : 0;
-		return get_item_by_noun(noun);
-	} else {
-		return get_item(instr->_operand[0]);
-	}
-}
-
 byte ComprehendGameV2::getOpcode(const Instruction *instr) {
 	// Special pre-processing for opcodes
 	byte opcode = instr->_opcode;
diff --git a/engines/glk/comprehend/game_opcodes.h b/engines/glk/comprehend/game_opcodes.h
index 6dcbace6f7..3eb3a2bae2 100644
--- a/engines/glk/comprehend/game_opcodes.h
+++ b/engines/glk/comprehend/game_opcodes.h
@@ -38,7 +38,7 @@ protected:
 
 	void execute_opcode(const Instruction *instr, const Sentence *sentence, FunctionState *func_state) override;
 
-	virtual Item *getItem(const Instruction *instr, const Sentence *sentence) = 0;
+	Item *getItem(const Instruction *instr);
 
 	void func_set_test_result(FunctionState *func_state, bool value);
 	bool isItemPresent(Item *item) const;
@@ -60,7 +60,6 @@ public:
 class ComprehendGameV1 : public ComprehendGameOpcodes {
 protected:
 	void execute_opcode(const Instruction *instr, const Sentence *sentence, FunctionState *func_state) override;
-	Item *getItem(const Instruction *instr, const Sentence *sentence) override;
 public:
 	ComprehendGameV1();
 };
@@ -71,7 +70,6 @@ public:
 class ComprehendGameV2 : public ComprehendGameOpcodes {
 protected:
 	void execute_opcode(const Instruction *instr, const Sentence *sentence, FunctionState *func_state) override;
-	Item *getItem(const Instruction *instr, const Sentence *sentence) override;
 public:
 	ComprehendGameV2();
 


Commit: 0f56a48fe4b3e1e7de404bfbde3cd0328fbb38b1
    https://github.com/scummvm/scummvm/commit/0f56a48fe4b3e1e7de404bfbde3cd0328fbb38b1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-10-21T20:26:00-07:00

Commit Message:
GLK: COMPREHEND: Handling of v2 inverted comparisons

Changed paths:
    engines/glk/comprehend/debugger_dumper.cpp
    engines/glk/comprehend/game.cpp
    engines/glk/comprehend/game_data.cpp
    engines/glk/comprehend/game_data.h
    engines/glk/comprehend/game_opcodes.cpp
    engines/glk/comprehend/game_opcodes.h


diff --git a/engines/glk/comprehend/debugger_dumper.cpp b/engines/glk/comprehend/debugger_dumper.cpp
index cdb60f6c38..e48ad3dcf0 100644
--- a/engines/glk/comprehend/debugger_dumper.cpp
+++ b/engines/glk/comprehend/debugger_dumper.cpp
@@ -35,7 +35,7 @@ DebuggerDumper::DebuggerDumper() : _game(nullptr) {
 
 	_opcodes[OPCODE_OBJECT_IS_NOT_NOWHERE] = "object_is_not_nowhere";
 
-	_opcodes[OPCODE_CURRENT_OBJECT_TAKEABLE] = "current_object_takeable";
+	_opcodes[OPCODE_CURRENT_IS_OBJECT] = "current_is_object";
 	_opcodes[OPCODE_CURRENT_OBJECT_NOT_TAKEABLE] = "current_object_not_takeable";
 
 	_opcodes[OPCODE_CURRENT_OBJECT_NOT_IN_ROOM] = "current_object_not_in_room";
@@ -103,13 +103,12 @@ DebuggerDumper::DebuggerDumper() : _game(nullptr) {
 	_opcodes[OPCODE_SET_STRING_REPLACEMENT2] = "set_string_replacement2";
 	_opcodes[OPCODE_SET_STRING_REPLACEMENT3] = "set_string_replacement3";
 	_opcodes[OPCODE_SET_CURRENT_NOUN_STRING_REPLACEMENT] = "set_current_noun_string_replacement";
-	_opcodes[OPCODE_CURRENT_IS_NOT_OBJECT] = "current_is_not_object";
 	_opcodes[OPCODE_DRAW_ROOM] = "draw_room";
 	_opcodes[OPCODE_DRAW_OBJECT] = "draw_object";
 	_opcodes[OPCODE_WAIT_KEY] = "wait_key";
 	_opcodes[OPCODE_TEST_FALSE] = "test_false";
 	_opcodes[OPCODE_OBJECT_CAN_TAKE] = "object_can_take";
-	_opcodes[OPCODE_NOT_TAKEABLE] = "not_takeable";
+	_opcodes[OPCODE_OBJECT_TAKEABLE] = "object_takeable";
 	_opcodes[OPCODE_CLEAR_INVISIBLE] = "clear_invisible";
 	_opcodes[OPCODE_SET_INVISIBLE] = "set_invisible";
 	_opcodes[OPCODE_CLEAR_CAN_TAKE] = "clear_can_take";
@@ -131,10 +130,13 @@ Common::String DebuggerDumper::dumpInstruction(ComprehendGame *game,
 		                              func_state->_testResult, func_state->_elseResult);
 
 	line += Common::String::format("  [%.2x] ", instr->_opcode);
-	if (_opcodes.contains(opcode))
+	if (_opcodes.contains(opcode)) {
+		if (_game->_comprehendVersion == 2 && (instr->_opcode & 0x40) != 0)
+			line += "!";
 		line += _opcodes[opcode];
-	else
+	} else {
 		line += "unknown";
+	}
 
 	if (instr->_nr_operands) {
 		line += "(";
diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index c10e597795..2489096fa4 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -787,7 +787,8 @@ void ComprehendGame::doBeforeTurn() {
 	beforeTurn();
 
 	// Run the each turn functions
-	eval_function(0, nullptr);
+	// TODO: Re-enable turn processing
+	//	eval_function(0, nullptr);
 
 	update();
 }
diff --git a/engines/glk/comprehend/game_data.cpp b/engines/glk/comprehend/game_data.cpp
index 26cafbd4e1..9f2c4ed679 100644
--- a/engines/glk/comprehend/game_data.cpp
+++ b/engines/glk/comprehend/game_data.cpp
@@ -43,6 +43,7 @@ void FunctionState::clear() {
 	_and = false;
 	_inCommand = false;
 	_executed = false;
+	_notComparison = false;
 }
 
 /*-------------------------------------------------------*/
diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index 9c8525cb64..c7bc837525 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -60,7 +60,7 @@ enum ScriptOpcode {
 	OPCODE_VAR_GT2,
 	OPCODE_VAR_GTE1,
 	OPCODE_VAR_GTE2,
-	OPCODE_CURRENT_OBJECT_TAKEABLE,
+	OPCODE_CURRENT_IS_OBJECT,
 	OPCODE_OBJECT_PRESENT,
 	OPCODE_ELSE,
 	OPCODE_OBJECT_IN_ROOM,
@@ -120,14 +120,13 @@ enum ScriptOpcode {
 	OPCODE_SET_STRING_REPLACEMENT2,
 	OPCODE_SET_STRING_REPLACEMENT3,
 	OPCODE_SET_CURRENT_NOUN_STRING_REPLACEMENT,
-	OPCODE_CURRENT_IS_NOT_OBJECT,
 	OPCODE_DRAW_ROOM,
 	OPCODE_DRAW_OBJECT,
 	OPCODE_WAIT_KEY,
 	OPCODE_TEST_FALSE,
 	OPCODE_CAN_TAKE,
 	OPCODE_TOO_HEAVY,
-	OPCODE_NOT_TAKEABLE,
+	OPCODE_OBJECT_TAKEABLE,
 	OPCODE_OBJECT_CAN_TAKE,
 	OPCODE_CLEAR_INVISIBLE,
 	OPCODE_SET_INVISIBLE,
@@ -200,6 +199,7 @@ struct FunctionState {
 	bool _and;
 	bool _inCommand;
 	bool _executed;
+	bool _notComparison;
 
 	FunctionState() {
 		clear();
diff --git a/engines/glk/comprehend/game_opcodes.cpp b/engines/glk/comprehend/game_opcodes.cpp
index b4408bebe0..02d3a109a6 100644
--- a/engines/glk/comprehend/game_opcodes.cpp
+++ b/engines/glk/comprehend/game_opcodes.cpp
@@ -76,6 +76,11 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		func_set_test_result(func_state, !noun);
 		break;
 
+	case OPCODE_CURRENT_IS_OBJECT:
+		item = get_item_by_noun(noun);
+		func_set_test_result(func_state, item != nullptr);
+		break;
+
 	case OPCODE_ELSE:
 		func_state->_testResult = func_state->_elseResult;
 		break;
@@ -121,6 +126,11 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		func_set_test_result(func_state, item->_room == ROOM_NOWHERE);
 		break;
 
+	case OPCODE_OBJECT_PRESENT:
+		item = getItem(instr);
+		func_set_test_result(func_state, item->_room == _currentRoom);
+		break;
+
 	case OPCODE_OR:
 		if (func_state->_orCount) {
 			func_state->_orCount += 2;
@@ -139,6 +149,19 @@ void ComprehendGameOpcodes::execute_opcode(const Instruction *instr, const Sente
 		move_object(item, ROOM_NOWHERE);
 		break;
 
+	case OPCODE_SAVE_ACTION:
+		/*
+		 * FIXME - This saves the current verb and allows the next
+		 * command to use just the noun. This is used to allow
+		 * responses to ask the player what they meant, e.g:
+		 *
+		 *   > drop
+		 *   I don't understand what you want to drop.
+		 *   > gun
+		 *   Okay.
+		 */
+		break;
+
 	case OPCODE_SET_CAN_TAKE:
 		item = get_item_by_noun(noun);
 		item->_flags |= ITEMF_CAN_TAKE;
@@ -284,7 +307,7 @@ ComprehendGameV1::ComprehendGameV1() {
 	_opcodeMap[0x04] = OPCODE_OR;
 	_opcodeMap[0x05] = OPCODE_IN_ROOM;
 	_opcodeMap[0x06] = OPCODE_VAR_EQ2;
-	_opcodeMap[0x08] = OPCODE_CURRENT_OBJECT_TAKEABLE;
+	_opcodeMap[0x08] = OPCODE_CURRENT_IS_OBJECT;
 	_opcodeMap[0x09] = OPCODE_OBJECT_PRESENT;
 	_opcodeMap[0x0a] = OPCODE_VAR_GTE2;
 	_opcodeMap[0x0c] = OPCODE_ELSE;
@@ -372,11 +395,6 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		func_set_test_result(func_state, !isItemPresent(item));
 		break;
 
-	case OPCODE_OBJECT_PRESENT:
-		item = getItem(instr);
-		func_set_test_result(func_state, item->_room == _currentRoom);
-		break;
-
 	case OPCODE_SET_STRING_REPLACEMENT3:
 		_currentReplaceWord = instr->_operand[0] - 1;
 		break;
@@ -507,15 +525,6 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 			item->_room != ROOM_INVENTORY);
 		break;
 
-	case OPCODE_CURRENT_OBJECT_TAKEABLE:
-		item = get_item_by_noun(noun);
-		if (!item)
-			func_set_test_result(func_state, false);
-		else
-			func_set_test_result(func_state,
-			(item->_flags & ITEMF_CAN_TAKE));
-		break;
-
 	case OPCODE_CURRENT_OBJECT_NOT_TAKEABLE:
 		item = get_item_by_noun(noun);
 		if (!item)
@@ -617,19 +626,6 @@ void ComprehendGameV1::execute_opcode(const Instruction *instr, const Sentence *
 		func_set_test_result(func_state, false);
 		break;
 
-	case OPCODE_SAVE_ACTION:
-		/*
-		 * FIXME - This saves the current verb and allows the next
-		 * command to use just the noun. This is used to allow
-		 * responses to ask the player what they meant, e.g:
-		 *
-		 *   > drop
-		 *   I don't understand what you want to drop.
-		 *   > gun
-		 *   Okay.
-		 */
-		break;
-
 	case OPCODE_SET_CURRENT_NOUN_STRING_REPLACEMENT:
 #if 1
 		error("TODO: OPCODE_SET_CURRENT_NOUN_STRING_REPLACEMENT");
@@ -679,7 +675,7 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x04] = OPCODE_OR;
 	_opcodeMap[0x05] = OPCODE_IN_ROOM;
 	_opcodeMap[0x06] = OPCODE_VAR_EQ2;
-	_opcodeMap[0x08] = OPCODE_CURRENT_IS_NOT_OBJECT;
+	_opcodeMap[0x08] = OPCODE_CURRENT_IS_OBJECT;
 	_opcodeMap[0x0c] = OPCODE_ELSE;
 	_opcodeMap[0x11] = OPCODE_OBJECT_IS_NOWHERE;
 	_opcodeMap[0x14] = OPCODE_CURRENT_OBJECT_NOT_VALID;
@@ -687,12 +683,13 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x19] = OPCODE_TEST_FLAG;
 	_opcodeMap[0x1d] = OPCODE_TEST_ROOM_FLAG;
 	_opcodeMap[0x20] = OPCODE_HAVE_CURRENT_OBJECT;
-	_opcodeMap[0x21] = OPCODE_OBJECT_NOT_PRESENT;
-	_opcodeMap[0x25] = OPCODE_NOT_TAKEABLE;
+	_opcodeMap[0x21] = OPCODE_OBJECT_PRESENT;
+	_opcodeMap[0x25] = OPCODE_OBJECT_TAKEABLE;
 	_opcodeMap[0x29] = OPCODE_INVENTORY_FULL;
 	_opcodeMap[0x2d] = OPCODE_OBJECT_CAN_TAKE;
 	_opcodeMap[0x80] = OPCODE_INVENTORY;
 	_opcodeMap[0x81] = OPCODE_TAKE_OBJECT;
+	_opcodeMap[0x84] = OPCODE_SAVE_ACTION;
 	_opcodeMap[0x85] = OPCODE_MOVE_TO_ROOM;
 	_opcodeMap[0x86] = OPCODE_VAR_ADD;
 	_opcodeMap[0x87] = OPCODE_SET_ROOM_DESCRIPTION;
@@ -732,7 +729,6 @@ ComprehendGameV2::ComprehendGameV2() {
 	_opcodeMap[0x60] = OPCODE_NOT_HAVE_CURRENT_OBJECT;
 	_opcodeMap[0x70] = OPCODE_CURRENT_OBJECT_NOT_PRESENT;
 	_opcodeMap[0x82] = OPCODE_MOVE_OBJECT_TO_ROOM;
-	_opcodeMap[0x84] = OPCODE_SAVE_ACTION;
 	_opcodeMap[0x8b] = OPCODE_SET_OBJECT_DESCRIPTION;
 	_opcodeMap[0x8c] = OPCODE_MOVE_DEFAULT;
 	_opcodeMap[0x8f] = OPCODE_SET_OBJECT_LONG_DESCRIPTION;
@@ -766,16 +762,14 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 		instr = &instrCopy;
 	}
 
+	func_state->_notComparison = (instr->_opcode & 0x40) != 0;
+
 	switch (_opcodeMap[getOpcode(instr)]) {
 	case OPCODE_CLEAR_INVISIBLE:
 		item = get_item_by_noun(noun);
 		item->_flags &= ~ITEMF_INVISIBLE;
 		break;
 
-	case OPCODE_CURRENT_IS_NOT_OBJECT:
-		func_set_test_result(func_state, get_item_by_noun(noun) == nullptr);
-		break;
-
 	case OPCODE_INVENTORY_FULL:
 		item = get_item_by_noun(noun);
 
@@ -799,9 +793,9 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 			console_println(stringLookup(STRING_CANT_GO).c_str());
 		break;
 
-	case OPCODE_NOT_TAKEABLE:
+	case OPCODE_OBJECT_TAKEABLE:
 		item = getItem(instr);
-		func_set_test_result(func_state, (item->_flags & ITEMF_WEIGHT_MASK) == ITEMF_WEIGHT_MASK);
+		func_set_test_result(func_state, (item->_flags & ITEMF_WEIGHT_MASK) != ITEMF_WEIGHT_MASK);
 		break;
 
 	case OPCODE_OBJECT_CAN_TAKE:
@@ -809,11 +803,6 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 		func_set_test_result(func_state, item->_flags & ITEMF_CAN_TAKE);
 		break;
 
-	case OPCODE_OBJECT_NOT_PRESENT:
-		item = getItem(instr);
-		func_set_test_result(func_state, item->_room != _currentRoom);
-		break;
-
 	case OPCODE_SET_STRING_REPLACEMENT3:
 		warning("TODO: Figure out OPCODE_SET_STRING_REPLACEMENT3 offset");
 		_currentReplaceWord = instr->_operand[0] - 1;
@@ -837,5 +826,10 @@ byte ComprehendGameV2::getOpcode(const Instruction *instr) {
 	return opcode;
 }
 
+void ComprehendGameV2::func_set_test_result(FunctionState *func_state, bool value) {
+	ComprehendGameOpcodes::func_set_test_result(func_state, value ^ func_state->_notComparison);
+}
+
+
 } // namespace Comprehend
 } // namespace Glk
diff --git a/engines/glk/comprehend/game_opcodes.h b/engines/glk/comprehend/game_opcodes.h
index 3eb3a2bae2..e8b99c5b1a 100644
--- a/engines/glk/comprehend/game_opcodes.h
+++ b/engines/glk/comprehend/game_opcodes.h
@@ -40,7 +40,7 @@ protected:
 
 	Item *getItem(const Instruction *instr);
 
-	void func_set_test_result(FunctionState *func_state, bool value);
+	virtual void func_set_test_result(FunctionState *func_state, bool value);
 	bool isItemPresent(Item *item) const;
 public:
 	ComprehendGameOpcodes();
@@ -74,6 +74,7 @@ public:
 	ComprehendGameV2();
 
 	byte getOpcode(const Instruction *instr) override;
+	void func_set_test_result(FunctionState *func_state, bool value) override;
 };
 
 } // namespace Comprehend




More information about the Scummvm-git-logs mailing list