[Scummvm-git-logs] scummvm master -> e549d95c898a95e1e49f89a509c8434605088210

dreammaster paulfgilbert at gmail.com
Sat Nov 7 05:22:28 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:
80e7e7244a GLK: COMPREHEND: Beginnings of per-turn OO-Topos logic
f46bd199dd GLK: COMPREHEND: Added fuelCheck method
efefe7538a GLK: COMPREHEND: Add shipDepartCheck method
e549d95c89 GLK: COMPREHEND: Added checkShipWorking method


Commit: 80e7e7244ad3b6fc7d7649db99c834d318646a6c
    https://github.com/scummvm/scummvm/commit/80e7e7244ad3b6fc7d7649db99c834d318646a6c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-11-06T20:42:53-08:00

Commit Message:
GLK: COMPREHEND: Beginnings of per-turn OO-Topos logic

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


diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index e7a2e64bc1..26dc3e237a 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -39,7 +39,8 @@ static const GameStrings OO_STRINGS = {
 	EXTRA_STRING_TABLE(154)
 };
 
-OOToposGame::OOToposGame() : ComprehendGameV2(), _restartMode(RESTART_IMMEDIATE) {
+OOToposGame::OOToposGame() : ComprehendGameV2(), _restartMode(RESTART_IMMEDIATE),
+		_wearingGoggles(false), _lightOn(false) {
 	_gameDataFile = "g0";
 
 	// Extra strings are (annoyingly) stored in the game binary
@@ -99,17 +100,15 @@ int OOToposGame::roomIsSpecial(unsigned room_index,
 }
 
 void OOToposGame::beforeTurn() {
-	// FIXME: Probably doesn't work correctly with restored games
-	static bool flashlight_was_on = false, googles_were_worn = false;
 	Room *room = &_rooms[_currentRoom];
 
 	/*
 	 * Check if the room needs to be redrawn because the flashlight
 	 * was switch off or on.
 	 */
-	if (_flags[OO_FLAG_FLASHLIGHT_ON] != flashlight_was_on &&
+	if (_flags[OO_FLAG_FLASHLIGHT_ON] != _lightOn &&
 	        (room->_flags & OO_ROOM_FLAG_DARK)) {
-		flashlight_was_on = _flags[OO_FLAG_FLASHLIGHT_ON];
+		_lightOn = _flags[OO_FLAG_FLASHLIGHT_ON];
 		_updateFlags |= UPDATE_GRAPHICS | UPDATE_ROOM_DESC;
 	}
 
@@ -117,13 +116,22 @@ void OOToposGame::beforeTurn() {
 	 * Check if the room needs to be redrawn because the goggles were
 	 * put on or removed.
 	 */
-	if (_flags[OO_FLAG_WEARING_GOGGLES] != googles_were_worn &&
+	if (_flags[OO_FLAG_WEARING_GOGGLES] != _wearingGoggles &&
 	        _currentRoom == OO_BRIGHT_ROOM) {
-		googles_were_worn = _flags[OO_FLAG_WEARING_GOGGLES];
+		_wearingGoggles = _flags[OO_FLAG_WEARING_GOGGLES];
 		_updateFlags |= UPDATE_GRAPHICS | UPDATE_ROOM_DESC;
 	}
 }
 
+bool OOToposGame::afterTurn() {
+	if (_flags[55])
+		_currentRoom = 55;
+	else if (_flags[56])
+		_currentRoom = 54;
+
+	return true;
+}
+
 void OOToposGame::handleSpecialOpcode(uint8 operand) {
 	switch (operand) {
 	case 1:
diff --git a/engines/glk/comprehend/game_oo.h b/engines/glk/comprehend/game_oo.h
index 77809e262a..2d08561d0a 100644
--- a/engines/glk/comprehend/game_oo.h
+++ b/engines/glk/comprehend/game_oo.h
@@ -33,6 +33,7 @@ enum RestartMode { RESTART_IMMEDIATE, RESTART_WITH_MSG, RESTART_WITHOUT_MSG };
 class OOToposGame : public ComprehendGameV2 {
 private:
 	RestartMode _restartMode;
+	bool _wearingGoggles, _lightOn;
 
 	void randomizeGuardLocation();
 	void computerResponse();
@@ -42,6 +43,7 @@ public:
 
 	void beforeGame() override;
 	void beforeTurn() override;
+	bool afterTurn() override;
 	int roomIsSpecial(unsigned room_index, unsigned *room_desc_string) override;
 	void handleSpecialOpcode(uint8 operand) override;
 	bool handle_restart() override;


Commit: f46bd199ddf18b110f84642ee05c35d788a93a48
    https://github.com/scummvm/scummvm/commit/f46bd199ddf18b110f84642ee05c35d788a93a48
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-11-06T20:42:53-08:00

Commit Message:
GLK: COMPREHEND: Added fuelCheck method

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


diff --git a/engines/glk/comprehend/game_data.cpp b/engines/glk/comprehend/game_data.cpp
index 1777f3e6e2..13a80e5e31 100644
--- a/engines/glk/comprehend/game_data.cpp
+++ b/engines/glk/comprehend/game_data.cpp
@@ -123,6 +123,12 @@ void Action::clear() {
 
 /*-------------------------------------------------------*/
 
+Instruction::Instruction(byte opcode, byte op1, byte op2, byte op3) : _opcode(opcode) {
+	_operand[0] = op1;
+	_operand[1] = op2;
+	_operand[2] = op3;
+}
+
 void Instruction::clear() {
 	_opcode = 0;
 	_nr_operands = 0;
diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index 0eee066adb..7a8f929a52 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -311,6 +311,8 @@ struct Instruction {
 		clear();
 	}
 
+	Instruction(byte opcode, byte op1 = 0, byte op2 = 0, byte op3 = 0);
+
 	void clear();
 };
 
diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index 26dc3e237a..93e8dfd328 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -28,19 +28,25 @@
 namespace Glk {
 namespace Comprehend {
 
-#define OO_ROOM_FLAG_DARK 0x02
-
-#define OO_BRIGHT_ROOM 0x19
+enum OOToposRoomFlag {
+	OO_ROOM_FLAG_FUEL = 1,
+	OO_ROOM_FLAG_DARK = 2
+};
 
-#define OO_FLAG_WEARING_GOGGLES 0x1b
-#define OO_FLAG_FLASHLIGHT_ON 0x27
+enum OOToposFlag {
+	OO_BRIGHT_ROOM = 25,
+	OO_FLAG_WEARING_GOGGLES = 27,
+	OO_FLAG_FLASHLIGHT_ON = 39,
+	OO_FLAG_SUFFICIENT_FUEL = 51
+};
 
 static const GameStrings OO_STRINGS = {
 	EXTRA_STRING_TABLE(154)
 };
 
 OOToposGame::OOToposGame() : ComprehendGameV2(), _restartMode(RESTART_IMMEDIATE),
-		_wearingGoggles(false), _lightOn(false) {
+		_wearingGoggles(false), _lightOn(false), _stringVal1(0), _stringVal2(0),
+		_addStringFlag(true) {
 	_gameDataFile = "g0";
 
 	// Extra strings are (annoyingly) stored in the game binary
@@ -220,5 +226,49 @@ void OOToposGame::computerResponse() {
 		console_println(_strings2[152].c_str());
 }
 
+void OOToposGame::addBulkMessage() {
+
+}
+
+void OOToposGame::fuelCheck() {
+	const byte ITEMS[7] = { 24, 27, 28, 29, 30, 31, 32 };
+	_variables[0x4b] = 0;
+	_stringVal1 = 68;
+	_stringVal2 = 0;
+
+	for (int idx = 168; idx < 175; ++idx, ++_stringVal1, ++_stringVal2) {
+		if (_flags[idx]) {
+			Item *item = get_item(ITEMS[_stringVal2]);
+			if (item->_room == ROOM_INVENTORY || (get_room(item->_room)->_flags & 1) == 1) {
+				Instruction varAdd(0x86, 0x4B, _stringVal1);
+				execute_opcode(&varAdd, nullptr, nullptr);
+			}
+		}
+	}
+
+	// Computer: "Our current evaluation...
+	Instruction strReplace(0xC9, 0x4B);
+	execute_opcode(&strReplace, nullptr, nullptr);
+	console_cond_println(_strings2[146].c_str());
+
+	FunctionState funcState;
+	Instruction test(2, 75, 76);
+	execute_opcode(&test, nullptr, nullptr);
+
+	if (funcState._testResult) {
+		// Computer: "We should now have enough
+		_flags[OO_FLAG_SUFFICIENT_FUEL] = true;
+		console_cond_println(_strings2[151].c_str());
+	} else {
+		_flags[OO_FLAG_SUFFICIENT_FUEL] = false;
+	}
+}
+
+void OOToposGame::console_cond_println(const char *str) {
+	if (_addStringFlag)
+		console_println(str);
+}
+
+
 } // namespace Comprehend
 } // namespace Glk
diff --git a/engines/glk/comprehend/game_oo.h b/engines/glk/comprehend/game_oo.h
index 2d08561d0a..391097ffe1 100644
--- a/engines/glk/comprehend/game_oo.h
+++ b/engines/glk/comprehend/game_oo.h
@@ -34,9 +34,19 @@ class OOToposGame : public ComprehendGameV2 {
 private:
 	RestartMode _restartMode;
 	bool _wearingGoggles, _lightOn;
+	int _stringVal1, _stringVal2;
+	bool _addStringFlag;
 
 	void randomizeGuardLocation();
 	void computerResponse();
+	void addBulkMessage();
+
+	/**
+	 * Tests if the player has enough to purchase needed ship fuel
+	 */
+	void fuelCheck();
+
+	void console_cond_println(const char *str);
 public:
 	OOToposGame();
 	~OOToposGame() override {}


Commit: efefe7538a3e2ff7b4848aacb75716a3734051a7
    https://github.com/scummvm/scummvm/commit/efefe7538a3e2ff7b4848aacb75716a3734051a7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-11-06T20:42:53-08:00

Commit Message:
GLK: COMPREHEND: Add shipDepartCheck method

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


diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index 93e8dfd328..a4a8550b90 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -34,10 +34,17 @@ enum OOToposRoomFlag {
 };
 
 enum OOToposFlag {
+	OO_FLAG_22 = 22,
 	OO_BRIGHT_ROOM = 25,
 	OO_FLAG_WEARING_GOGGLES = 27,
 	OO_FLAG_FLASHLIGHT_ON = 39,
-	OO_FLAG_SUFFICIENT_FUEL = 51
+	OO_FLAG_SUFFICIENT_FUEL = 51,
+	OO_FLAG_READY_TO_DEPART = 60,
+	OO_TRACTOR_BEAM = 71
+};
+
+enum OOToposItem {
+	ITEM_SERUM_VIAL = 39
 };
 
 static const GameStrings OO_STRINGS = {
@@ -46,7 +53,7 @@ static const GameStrings OO_STRINGS = {
 
 OOToposGame::OOToposGame() : ComprehendGameV2(), _restartMode(RESTART_IMMEDIATE),
 		_wearingGoggles(false), _lightOn(false), _stringVal1(0), _stringVal2(0),
-		_addStringFlag(true) {
+		_addStringFlag(true), _bulkFlag(false) {
 	_gameDataFile = "g0";
 
 	// Extra strings are (annoyingly) stored in the game binary
@@ -238,8 +245,8 @@ void OOToposGame::fuelCheck() {
 
 	for (int idx = 168; idx < 175; ++idx, ++_stringVal1, ++_stringVal2) {
 		if (_flags[idx]) {
-			Item *item = get_item(ITEMS[_stringVal2]);
-			if (item->_room == ROOM_INVENTORY || (get_room(item->_room)->_flags & 1) == 1) {
+			Item *item = get_item(ITEMS[_stringVal2] - 1);
+			if (item->_room == ROOM_INVENTORY || (get_room(item->_room)->_flags & OO_ROOM_FLAG_FUEL) != 0) {
 				Instruction varAdd(0x86, 0x4B, _stringVal1);
 				execute_opcode(&varAdd, nullptr, nullptr);
 			}
@@ -264,6 +271,33 @@ void OOToposGame::fuelCheck() {
 	}
 }
 
+void OOToposGame::shipDepartCheck() {
+	_addStringFlag = false;
+	addBulkMessage();
+	fuelCheck();
+	_addStringFlag = true;
+
+	if (!_bulkFlag && _flags[OO_FLAG_SUFFICIENT_FUEL]) {
+		Item *item = get_item(ITEM_SERUM_VIAL - 1);
+		if (item->_room == ROOM_INVENTORY || (get_room(item->_room)->_flags & OO_ROOM_FLAG_FUEL) != 0) {
+			if (!_flags[OO_TRACTOR_BEAM]) {
+				// I detect a tractor beam
+				console_println(_strings2[77].c_str());
+			} else if (!_flags[OO_FLAG_READY_TO_DEPART]) {
+				// All systems check. Ready to depart
+				_flags[OO_FLAG_22] = true;
+				console_println(_strings2[79].c_str());
+			} else {
+				// Please close the airlock
+				console_println(_strings2[76].c_str());
+			}
+		} else {
+			// The serum vial is not aboard the ship
+			console_println(_strings2[78].c_str());
+		}
+	}
+}
+
 void OOToposGame::console_cond_println(const char *str) {
 	if (_addStringFlag)
 		console_println(str);
diff --git a/engines/glk/comprehend/game_oo.h b/engines/glk/comprehend/game_oo.h
index 391097ffe1..945432461c 100644
--- a/engines/glk/comprehend/game_oo.h
+++ b/engines/glk/comprehend/game_oo.h
@@ -35,7 +35,7 @@ private:
 	RestartMode _restartMode;
 	bool _wearingGoggles, _lightOn;
 	int _stringVal1, _stringVal2;
-	bool _addStringFlag;
+	bool _addStringFlag, _bulkFlag;
 
 	void randomizeGuardLocation();
 	void computerResponse();
@@ -46,6 +46,15 @@ private:
 	 */
 	void fuelCheck();
 
+	/**
+	 * Checks whether the ship can depart, printing out the computer's response
+	 */
+	void shipDepartCheck();
+
+	/**
+	 * A wrapped version of console_println that only prints the passed string
+	 * if the _addStringFlag is set
+	 */
 	void console_cond_println(const char *str);
 public:
 	OOToposGame();


Commit: e549d95c898a95e1e49f89a509c8434605088210
    https://github.com/scummvm/scummvm/commit/e549d95c898a95e1e49f89a509c8434605088210
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-11-06T20:42:53-08:00

Commit Message:
GLK: COMPREHEND: Added checkShipWorking method

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


diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index a4a8550b90..d8aacc8168 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -53,7 +53,7 @@ static const GameStrings OO_STRINGS = {
 
 OOToposGame::OOToposGame() : ComprehendGameV2(), _restartMode(RESTART_IMMEDIATE),
 		_wearingGoggles(false), _lightOn(false), _stringVal1(0), _stringVal2(0),
-		_addStringFlag(true), _bulkFlag(false) {
+		_addStringFlag(true), _shipNotWorking(false) {
 	_gameDataFile = "g0";
 
 	// Extra strings are (annoyingly) stored in the game binary
@@ -233,11 +233,31 @@ void OOToposGame::computerResponse() {
 		console_println(_strings2[152].c_str());
 }
 
-void OOToposGame::addBulkMessage() {
+void OOToposGame::checkShipWorking() {
+	_stringVal1 = 164;
+	_stringVal2 = 0;
+
+	// Iterate through the ship's flags
+	for (int idx = 42; idx < 51; ++idx, ++_stringVal1) {
+		if (!_flags[idx]) {
+			if (!_stringVal2) {
+				// The following components are not installed
+				console_cond_println(_strings2[132].c_str());
+				_stringVal2 = 1;
+			}
+
+			// Power Cylinder
+			console_cond_println(_strings[_stringVal1].c_str());
+		}
+	}
 
+	_shipNotWorking = _stringVal2 != 0;
+	if (!_shipNotWorking)
+		// The ship is in working order
+		console_cond_println(_strings2[153].c_str());
 }
 
-void OOToposGame::fuelCheck() {
+void OOToposGame::checkShipFuel() {
 	const byte ITEMS[7] = { 24, 27, 28, 29, 30, 31, 32 };
 	_variables[0x4b] = 0;
 	_stringVal1 = 68;
@@ -273,11 +293,11 @@ void OOToposGame::fuelCheck() {
 
 void OOToposGame::shipDepartCheck() {
 	_addStringFlag = false;
-	addBulkMessage();
-	fuelCheck();
+	checkShipWorking();
+	checkShipFuel();
 	_addStringFlag = true;
 
-	if (!_bulkFlag && _flags[OO_FLAG_SUFFICIENT_FUEL]) {
+	if (!_shipNotWorking && _flags[OO_FLAG_SUFFICIENT_FUEL]) {
 		Item *item = get_item(ITEM_SERUM_VIAL - 1);
 		if (item->_room == ROOM_INVENTORY || (get_room(item->_room)->_flags & OO_ROOM_FLAG_FUEL) != 0) {
 			if (!_flags[OO_TRACTOR_BEAM]) {
diff --git a/engines/glk/comprehend/game_oo.h b/engines/glk/comprehend/game_oo.h
index 945432461c..f76fc5cef5 100644
--- a/engines/glk/comprehend/game_oo.h
+++ b/engines/glk/comprehend/game_oo.h
@@ -35,16 +35,20 @@ private:
 	RestartMode _restartMode;
 	bool _wearingGoggles, _lightOn;
 	int _stringVal1, _stringVal2;
-	bool _addStringFlag, _bulkFlag;
+	bool _addStringFlag, _shipNotWorking;
 
 	void randomizeGuardLocation();
 	void computerResponse();
-	void addBulkMessage();
+
+	/**
+	 * Checks whether the ship is in working order
+	 */
+	void checkShipWorking();
 
 	/**
 	 * Tests if the player has enough to purchase needed ship fuel
 	 */
-	void fuelCheck();
+	void checkShipFuel();
 
 	/**
 	 * Checks whether the ship can depart, printing out the computer's response




More information about the Scummvm-git-logs mailing list