[Scummvm-git-logs] scummvm master -> 43d25b567aec1a4be73f41d031b807112d5e5393

dreammaster paulfgilbert at gmail.com
Mon Oct 26 04:38:39 UTC 2020


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:
43d25b567a GLK: COMPREHEND: Fix looking at 4-d mirror in OO-Topos


Commit: 43d25b567aec1a4be73f41d031b807112d5e5393
    https://github.com/scummvm/scummvm/commit/43d25b567aec1a4be73f41d031b807112d5e5393
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-10-25T21:38:28-07:00

Commit Message:
GLK: COMPREHEND: Fix looking at 4-d mirror in OO-Topos

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


diff --git a/engines/glk/comprehend/debugger_dumper.cpp b/engines/glk/comprehend/debugger_dumper.cpp
index 656c585d74..87a2be610c 100644
--- a/engines/glk/comprehend/debugger_dumper.cpp
+++ b/engines/glk/comprehend/debugger_dumper.cpp
@@ -169,7 +169,11 @@ Common::String DebuggerDumper::dumpInstruction(ComprehendGame *game,
 	case OPCODE_SET_STRING_REPLACEMENT1:
 	case OPCODE_SET_STRING_REPLACEMENT2:
 	case OPCODE_SET_STRING_REPLACEMENT3:
-		line += Common::String::format(" %s", game->_replaceWords[instr->_operand[0] - 1].c_str());
+		str_index = instr->_operand[0] - 1;
+		if (str_index < 0 || str_index >= (int)game->_replaceWords.size())
+			warning("invalid string replacement index - %d", str_index);
+		else
+			line += Common::String::format(" %s", game->_replaceWords[str_index].c_str());
 		break;
 
 	default:
diff --git a/engines/glk/comprehend/game_data.cpp b/engines/glk/comprehend/game_data.cpp
index ed01b1edd1..1777f3e6e2 100644
--- a/engines/glk/comprehend/game_data.cpp
+++ b/engines/glk/comprehend/game_data.cpp
@@ -94,8 +94,12 @@ void Word::load(FileBuffer *fb) {
 
 	// Decode
 	for (int j = 0; j < 6; j++)
-		_word[j] ^= 0x8a;
+		_word[j] = tolower((char)(_word[j] ^ 0xaa));
+
+	// Strip off trailing spaces
 	_word[6] = '\0';
+	for (int j = 5; j > 0 && _word[j] == ' '; --j)
+		_word[j] = '\0';
 
 	_index = fb->readByte();
 	_type = fb->readByte();
@@ -157,6 +161,7 @@ void GameData::clearGame() {
 	_startRoom = 0;
 	_currentRoom = 0;
 	_currentReplaceWord = 0;
+	_wordFlags = 0;
 	_updateFlags = 0;
 	_colorTable = 0;
 	_itemCount = 0;
diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index cc6c6ed8fc..11fadd46c4 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -396,6 +396,7 @@ public:
 	uint16 _variables[MAX_VARIABLES];
 
 	uint8 _currentReplaceWord;
+	uint8 _wordFlags;
 	uint _updateFlags;
 
 	Common::Array<WordMap> _wordMaps;
diff --git a/engines/glk/comprehend/game_opcodes.cpp b/engines/glk/comprehend/game_opcodes.cpp
index f3c61198c5..ea5b9fdeac 100644
--- a/engines/glk/comprehend/game_opcodes.cpp
+++ b/engines/glk/comprehend/game_opcodes.cpp
@@ -823,10 +823,18 @@ void ComprehendGameV2::execute_opcode(const Instruction *instr, const Sentence *
 		item->_longString = (instr->_operand[2] << 8) | instr->_operand[1];
 		break;
 
-	case OPCODE_SET_STRING_REPLACEMENT3:
-		warning("TODO: Figure out OPCODE_SET_STRING_REPLACEMENT3 offset");
-		_currentReplaceWord = instr->_operand[0] - 1;
+	case OPCODE_SET_STRING_REPLACEMENT3: {
+		int articleNum, bits = _wordFlags;
+		for (articleNum = 3; articleNum >= 0; --articleNum, bits <<= 1) {
+			if (bits >= 0x100)
+				break;
+		}
+		if (articleNum == -1)
+			articleNum = 2;
+
+		_currentReplaceWord = instr->_operand[0] + articleNum - 1;
 		break;
+	}
 
 	default:
 		ComprehendGameOpcodes::execute_opcode(instr, sentence, func_state);




More information about the Scummvm-git-logs mailing list