[Scummvm-cvs-logs] SF.net SVN: scummvm:[34885] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon Nov 3 20:51:35 CET 2008


Revision: 34885
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34885&view=rev
Author:   lordhoto
Date:     2008-11-03 19:51:34 +0000 (Mon, 03 Nov 2008)

Log Message:
-----------
Preliminary support for loading via GMM for KYRA engine.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/detection.cpp
    scummvm/trunk/engines/kyra/kyra_lok.cpp
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/engines/kyra/kyra_v1.h
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/lol.h
    scummvm/trunk/engines/kyra/saveload.cpp
    scummvm/trunk/engines/kyra/sound_adlib.cpp

Modified: scummvm/trunk/engines/kyra/detection.cpp
===================================================================
--- scummvm/trunk/engines/kyra/detection.cpp	2008-11-03 19:38:15 UTC (rev 34884)
+++ scummvm/trunk/engines/kyra/detection.cpp	2008-11-03 19:51:34 UTC (rev 34885)
@@ -1078,7 +1078,8 @@
 		(f == kSupportsLoadingDuringStartup) ||
 		(f == kSupportsDeleteSave) ||
 	   	(f == kSavesSupportMetaInfo) ||
-		(f == kSavesSupportThumbnail);
+		(f == kSavesSupportThumbnail) ||
+		(f == kSupportsLoadingDuringRuntime);
 }
 
 bool KyraMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {

Modified: scummvm/trunk/engines/kyra/kyra_lok.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_lok.cpp	2008-11-03 19:38:15 UTC (rev 34884)
+++ scummvm/trunk/engines/kyra/kyra_lok.cpp	2008-11-03 19:51:34 UTC (rev 34885)
@@ -463,7 +463,12 @@
 
 	uint32 start = _system->getMillis();
 	do {
+		if (isMainLoop)
+			_isSaveAllowed = true;
+
 		while (_eventMan->pollEvent(event)) {
+			_isSaveAllowed = false;
+
 			switch (event.type) {
 			case Common::EVENT_KEYDOWN:
 				if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' &&
@@ -513,6 +518,9 @@
 			default:
 				break;
 			}
+
+			if (isMainLoop)
+				_isSaveAllowed = true;
 		}
 
 		if (_debugger->isAttached())

Modified: scummvm/trunk/engines/kyra/kyra_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.cpp	2008-11-03 19:38:15 UTC (rev 34884)
+++ scummvm/trunk/engines/kyra/kyra_v1.cpp	2008-11-03 19:51:34 UTC (rev 34885)
@@ -65,6 +65,8 @@
 
 	memset(_flagsTable, 0, sizeof(_flagsTable));
 
+	_isSaveAllowed = false;
+
 	// sets up all engine specific debug levels
 	Common::addSpecialDebugLevel(kDebugLevelScriptFuncs, "ScriptFuncs", "Script function debug level");
 	Common::addSpecialDebugLevel(kDebugLevelScript, "Script", "Script interpreter debug level");

Modified: scummvm/trunk/engines/kyra/kyra_v1.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.h	2008-11-03 19:38:15 UTC (rev 34884)
+++ scummvm/trunk/engines/kyra/kyra_v1.h	2008-11-03 19:51:34 UTC (rev 34885)
@@ -274,6 +274,11 @@
 	uint32 _lastAutosave;
 	void checkAutosave();
 
+	bool _isSaveAllowed;
+
+	bool canLoadGameStateCurrently() { return _isSaveAllowed; }
+	bool canSaveGameStateCurrently() { return _isSaveAllowed; }
+
 	const char *getSavegameFilename(int num);
 	static Common::String getSavegameFilename(const Common::String &target, int num);
 	bool saveFileLoadable(int slot);
@@ -299,6 +304,8 @@
 
 	static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header);
 
+	int loadGameState(int slot);
+	virtual void loadGame(const char *fileName) = 0;
 	virtual void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail) = 0;
 
 	Common::SeekableReadStream *openSaveForReading(const char *filename, SaveHeader &header);

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-11-03 19:38:15 UTC (rev 34884)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-11-03 19:51:34 UTC (rev 34885)
@@ -164,8 +164,13 @@
 
 int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
 	debugC(9, kDebugLevelMain, "KyraEngine_v2::checkInput(%p, %d)", (const void*)buttonList, mainLoop);
+	if (mainLoop)
+		_isSaveAllowed = true;
+
 	updateInput();
 
+	_isSaveAllowed = false;
+
 	int keys = 0;
 	int8 mouseWheel = 0;
 

Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h	2008-11-03 19:38:15 UTC (rev 34884)
+++ scummvm/trunk/engines/kyra/lol.h	2008-11-03 19:51:34 UTC (rev 34885)
@@ -149,6 +149,7 @@
 	bool lineIsPassable(int, int) { return false; }
 
 	// save
+	void loadGame(const char *fileName) {}
 	void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail) {}
 };
 

Modified: scummvm/trunk/engines/kyra/saveload.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload.cpp	2008-11-03 19:38:15 UTC (rev 34884)
+++ scummvm/trunk/engines/kyra/saveload.cpp	2008-11-03 19:51:34 UTC (rev 34885)
@@ -244,6 +244,16 @@
 	return false;
 }
 
+int KyraEngine_v1::loadGameState(int slot) {
+	if (!_isSaveAllowed)
+		return -1;
+	
+	const char *filename = getSavegameFilename(slot);
+	loadGame(filename);
+
+	return 0;
+}
+
 void KyraEngine_v1::checkAutosave() {
 	if (shouldPerformAutoSave(_lastAutosave)) {
 		saveGame(getSavegameFilename(999), "Autosave", 0);

Modified: scummvm/trunk/engines/kyra/sound_adlib.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_adlib.cpp	2008-11-03 19:38:15 UTC (rev 34884)
+++ scummvm/trunk/engines/kyra/sound_adlib.cpp	2008-11-03 19:51:34 UTC (rev 34885)
@@ -2303,11 +2303,23 @@
 	if ((soundId == 0xFFFF && _v2) || (soundId == 0xFF && !_v2) || !_soundDataPtr)
 		return;
 
+	// HACK: Since we might call this when the engines is paused (on game load via GMM)
+	// we must unpause the engine here, so this will work properly
+
+	int pauseCount = 0;
+	while (_vm->isPaused()) {
+		++pauseCount;
+		_vm->pauseEngine(false);
+	}
+	
 	while ((_driver->callback(16, 0) & 8)) {
 		// We call the system delay and not the game delay to avoid concurrency issues.
 		_vm->_system->delayMillis(10);
 	}
 
+	while (pauseCount--)
+		_vm->pauseEngine(true);
+
 	if (_sfxPlayingSound != -1) {
 		// Restore the sounds's normal values.
 		_driver->callback(10, _sfxPlayingSound, int(1), int(_sfxPriority));


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list