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

waltervn walter at vanniftrik-it.nl
Wed Dec 28 22:42:24 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:
cfaf749c60 ADL: Implement hires5 game loop


Commit: cfaf749c60c4c641f11142bde53ce6b183847895
    https://github.com/scummvm/scummvm/commit/cfaf749c60c4c641f11142bde53ce6b183847895
Author: Walter van Niftrik (walter at scummvm.org)
Date: 2016-12-28T22:13:34+01:00

Commit Message:
ADL: Implement hires5 game loop

Changed paths:
    engines/adl/adl.cpp
    engines/adl/adl.h
    engines/adl/adl_v4.cpp
    engines/adl/adl_v4.h


diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 3cf68c5..c1c3820 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -586,6 +586,60 @@ void AdlEngine::dropItem(byte noun) {
 	printMessage(_messageIds.dontUnderstand);
 }
 
+void AdlEngine::gameLoop() {
+	uint verb = 0, noun = 0;
+	_isRestarting = false;
+
+	// When restoring from the launcher, we don't read
+	// input on the first iteration. This is needed to
+	// ensure that restoring from the launcher and
+	// restoring in-game brings us to the same game state.
+	// (Also see comment below.)
+	if (!_isRestoring) {
+		showRoom();
+
+		if (_isRestarting)
+			return;
+
+		_canSaveNow = _canRestoreNow = true;
+		getInput(verb, noun);
+		_canSaveNow = _canRestoreNow = false;
+
+		if (shouldQuit())
+			return;
+
+		// If we just restored from the GMM, we skip this command
+		// set, as no command has been input by the user
+		if (!_isRestoring)
+			checkInput(verb, noun);
+	}
+
+	if (_isRestoring) {
+		// We restored from the GMM or launcher. As restoring
+		// with "RESTORE GAME" does not end command processing,
+		// we don't break it off here either. This essentially
+		// means that restoring a game will always run through
+		// the global commands and increase the move counter
+		// before the first user input.
+		_display->printAsciiString("\r");
+		_isRestoring = false;
+		verb = _restoreVerb;
+		noun = _restoreNoun;
+	}
+
+	// Restarting does end command processing
+	if (_isRestarting)
+		return;
+
+	doAllCommands(_globalCommands, verb, noun);
+
+	if (_isRestarting)
+		return;
+
+	advanceClock();
+	_state.moves++;
+}
+
 Common::Error AdlEngine::run() {
 	initGraphics(DISPLAY_WIDTH * 2, DISPLAY_HEIGHT * 2, true);
 
@@ -611,59 +665,8 @@ Common::Error AdlEngine::run() {
 
 	_display->setMode(DISPLAY_MODE_MIXED);
 
-	while (!_isQuitting) {
-		uint verb = 0, noun = 0;
-		_isRestarting = false;
-
-		// When restoring from the launcher, we don't read
-		// input on the first iteration. This is needed to
-		// ensure that restoring from the launcher and
-		// restoring in-game brings us to the same game state.
-		// (Also see comment below.)
-		if (!_isRestoring) {
-			showRoom();
-
-			if (_isRestarting)
-				continue;
-
-			_canSaveNow = _canRestoreNow = true;
-			getInput(verb, noun);
-			_canSaveNow = _canRestoreNow = false;
-
-			if (shouldQuit())
-				break;
-
-			// If we just restored from the GMM, we skip this command
-			// set, as no command has been input by the user
-			if (!_isRestoring)
-				checkInput(verb, noun);
-		}
-
-		if (_isRestoring) {
-			// We restored from the GMM or launcher. As restoring
-			// with "RESTORE GAME" does not end command processing,
-			// we don't break it off here either. This essentially
-			// means that restoring a game will always run through
-			// the global commands and increase the move counter
-			// before the first user input.
-			_display->printAsciiString("\r");
-			_isRestoring = false;
-			verb = _restoreVerb;
-			noun = _restoreNoun;
-		}
-
-		// Restarting does end command processing
-		if (_isRestarting)
-			continue;
-
-		doAllCommands(_globalCommands, verb, noun);
-
-		if (_isRestarting)
-			continue;
-
-		advanceClock();
-		_state.moves++;
-	}
+	while (!(_isQuitting || shouldQuit()))
+		gameLoop();
 
 	return Common::kNoError;
 }
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index 2b336c9..62c5ea1 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -239,6 +239,7 @@ protected:
 	Common::Error loadGameState(int slot);
 	Common::Error saveGameState(int slot, const Common::String &desc);
 
+	virtual void gameLoop();
 	virtual void loadState(Common::ReadStream &stream);
 	virtual void saveState(Common::WriteStream &stream);
 	Common::String readString(Common::ReadStream &stream, byte until = 0) const;
@@ -253,6 +254,7 @@ protected:
 
 	Common::String inputString(byte prompt = 0) const;
 	byte inputKey(bool showCursor = true) const;
+	void getInput(uint &verb, uint &noun);
 
 	virtual Common::String formatVerbError(const Common::String &verb) const;
 	virtual Common::String formatNounError(const Common::String &verb, const Common::String &noun) const;
@@ -388,6 +390,7 @@ protected:
 	State _state;
 
 	bool _isRestarting, _isRestoring, _isQuitting;
+	bool _canSaveNow, _canRestoreNow;
 	bool _skipOneCommand;
 
 	const AdlGameDescription *_gameDescription;
@@ -412,12 +415,10 @@ private:
 	byte convertKey(uint16 ascii) const;
 	Common::String getLine() const;
 	Common::String getWord(const Common::String &line, uint &index) const;
-	void getInput(uint &verb, uint &noun);
 
 	Console *_console;
 	GUI::Debugger *getDebugger() { return _console; }
 	byte _saveVerb, _saveNoun, _restoreVerb, _restoreNoun;
-	bool _canSaveNow, _canRestoreNow;
 };
 
 } // End of namespace Adl
diff --git a/engines/adl/adl_v4.cpp b/engines/adl/adl_v4.cpp
index c979f83..dcf0f99 100644
--- a/engines/adl/adl_v4.cpp
+++ b/engines/adl/adl_v4.cpp
@@ -37,6 +37,51 @@ AdlEngine_v4::~AdlEngine_v4() {
 	delete _itemPicIndex;
 }
 
+void AdlEngine_v4::gameLoop() {
+	uint verb = 0, noun = 0;
+	_isRestarting = false;
+
+	if (_isRestoring) {
+		// Game restored from launcher. As this version of ADL long jumps to
+		// the game loop after restoring, no special action is required.
+		_isRestoring = false;
+	}
+
+	showRoom();
+
+	if (_isRestarting || shouldQuit())
+		return;
+
+	_canSaveNow = _canRestoreNow = true;
+	getInput(verb, noun);
+	_canSaveNow = _canRestoreNow = false;
+
+	if (_isRestoring) {
+		// Game restored from GMM. Move cursor to next line and jump to
+		// start of game loop.
+		_display->printAsciiString("\r");
+		_isRestoring = false;
+		return;
+	}
+
+	if (_isRestarting || shouldQuit())
+		return;
+
+	_linesPrinted = 0;
+
+	checkInput(verb, noun);
+
+	if (_isRestarting || shouldQuit())
+		return;
+
+	doAllCommands(_globalCommands, verb, noun);
+
+	if (_isRestarting || shouldQuit())
+		return;
+
+	_state.moves++;
+}
+
 void AdlEngine_v4::loadState(Common::ReadStream &stream) {
 	_state.room = stream.readByte();
 	_state.region = stream.readByte();
diff --git a/engines/adl/adl_v4.h b/engines/adl/adl_v4.h
index caf2b3f..4e87530 100644
--- a/engines/adl/adl_v4.h
+++ b/engines/adl/adl_v4.h
@@ -49,6 +49,7 @@ protected:
 	AdlEngine_v4(OSystem *syst, const AdlGameDescription *gd);
 
 	// AdlEngine
+	virtual void gameLoop();
 	virtual void loadState(Common::ReadStream &stream);
 	virtual void saveState(Common::WriteStream &stream);
 	virtual Common::String loadMessage(uint idx) const;





More information about the Scummvm-git-logs mailing list