[Scummvm-cvs-logs] scummvm master -> 4b7d49dcff2377a6fe95af634bd5a0de5bf78326

m-kiewitz m_kiewitz at users.sourceforge.net
Thu Feb 4 22:53:35 CET 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:
4b7d49dcff AGI: Fix Hold-Key-Mode implementation


Commit: 4b7d49dcff2377a6fe95af634bd5a0de5bf78326
    https://github.com/scummvm/scummvm/commit/4b7d49dcff2377a6fe95af634bd5a0de5bf78326
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2016-02-04T22:53:15+01:00

Commit Message:
AGI: Fix Hold-Key-Mode implementation

Hold-Key-Mode got introduced v2.425, it was simply not possible
to disable it until 3.098.
Now creating a AGI_KEY_STATIONARY event, so that it works properly

Fixes Mixed Up Mother Goose

Changed paths:
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/keyboard.cpp
    engines/agi/op_cmd.cpp
    engines/agi/saveload.cpp



diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 79047b0..933aa50 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -173,7 +173,7 @@ int AgiEngine::agiInit() {
 	// GUI Predictive Dialog, but DS Word Completion is probably broken due to this...
 #endif
 
-	_egoHoldKey = false;
+	_keyHoldMode = false;
 
 	_game.mouseFence.setWidth(0); // Reset
 
@@ -403,7 +403,7 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
 	_systemUI = nullptr;
 	_inventory = nullptr;
 
-	_egoHoldKey = false;
+	_keyHoldMode = false;
 }
 
 void AgiEngine::initialize() {
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index ea70127..93017af 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -907,7 +907,7 @@ public:
 	void updatePosition();
 	int getDirection(int16 objX, int16 objY, int16 destX, int16 destY, int16 stepSize);
 
-	bool _egoHoldKey;
+	bool _keyHoldMode;
 
 	// Keyboard
 	int doPollKeyboard();
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index 5ef6dd2..5a73afe 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -252,8 +252,13 @@ void AgiEngine::processScummVMEvents() {
 			break;
 
 		case Common::EVENT_KEYUP:
-			if (_egoHoldKey)
-				_game.screenObjTable[SCREENOBJECTS_EGO_ENTRY].direction = 0;
+			if (_keyHoldMode) {
+				// Original AGI actually created direction events in here
+				// We don't do that, that's why we create a stationary event instead, which will
+				// result in a direction change to 0 in handleController().
+				keyEnqueue(AGI_KEY_STATIONARY);
+			}
+			break;
 
 		default:
 			break;
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 7d4b759..edbbb4e 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -934,12 +934,6 @@ void cmdPopScript(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
 	}
 }
 
-void cmdHoldKey(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
-	if (getVersion() >= 0x3098) {
-		state->_vm->_egoHoldKey = true;
-	}
-}
-
 void cmdDiscardSound(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
 	if (getVersion() >= 0x2936) {
 		debug(0, "discard.sound");
@@ -993,9 +987,17 @@ void cmdFenceMouse(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
 	state->mouseFence.setHeight(varNr4 - varNr1);
 }
 
+// HoldKey was added in 2.425
+// There was no way to disable this mode until 3.098 though
+void cmdHoldKey(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
+	if (getVersion() >= 0x2425) {
+		vm->_keyHoldMode = true;
+	}
+}
+
 void cmdReleaseKey(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
 	if (getVersion() >= 0x3098) {
-		state->_vm->_egoHoldKey = false;
+		vm->_keyHoldMode = false;
 	}
 }
 
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index c2d9de8..1bf0dbc 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -45,7 +45,7 @@
 #include "agi/systemui.h"
 #include "agi/words.h"
 
-#define SAVEGAME_CURRENT_VERSION 7
+#define SAVEGAME_CURRENT_VERSION 8
 
 //
 // Version 0 (Sarien): view table has 64 entries
@@ -59,7 +59,9 @@
 //                       required for some games for quick-loading from ScummVM main menu
 //                       for games, that do not set all key mappings right at the start
 //                      Added automatic save data (for command SetSimple)
-//
+// Version 8 (ScummVM): Added Hold-Key-Mode boolean
+//                       required for at least Mixed Up Mother Goose
+//                       gets set at the start of the game only
 
 namespace Agi {
 
@@ -195,6 +197,10 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de
 		out->writeByte(_game.controllerKeyMapping[i].controllerSlot);
 	}
 
+	// Version 8+: hold-key-mode
+	//  required for at least Mixed Up Mother Goose
+	out->writeByte(_keyHoldMode);
+
 	// game.ev_keyp
 	for (i = 0; i < MAX_STRINGS; i++)
 		out->write(_game.strings[i], MAX_STRINGLEN);
@@ -521,6 +527,15 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
 		}
 	}
 
+	if (saveVersion >= 8) {
+		// Version 8+: hold-key-mode
+		if (in->readByte()) {
+			_keyHoldMode = true;
+		} else {
+			_keyHoldMode = false;
+		}
+	}
+
 	for (i = 0; i < MAX_STRINGS; i++)
 		in->read(_game.strings[i], MAX_STRINGLEN);
 






More information about the Scummvm-git-logs mailing list