[Scummvm-cvs-logs] SF.net SVN: scummvm:[40142] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Apr 25 10:50:42 CEST 2009


Revision: 40142
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40142&view=rev
Author:   thebluegr
Date:     2009-04-25 08:50:42 +0000 (Sat, 25 Apr 2009)

Log Message:
-----------
WIP (still non-working) code for speech sync in CD talkie games (like e.g. KQ5 CD and SQ4 CD), taken from Greg's SCI implementation.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/ksound.cpp
    scummvm/trunk/engines/sci/scicore/resource.cpp
    scummvm/trunk/engines/sci/scicore/resource.h
    scummvm/trunk/engines/sci/sfx/core.cpp
    scummvm/trunk/engines/sci/sfx/core.h

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-04-25 06:42:01 UTC (rev 40141)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-04-25 08:50:42 UTC (rev 40142)
@@ -203,8 +203,8 @@
 	DEFUN("Message", kMessage, ".*"),
 	DEFUN("GetMessage", kGetMessage, ".*"),
 	DEFUN("DoAudio", kDoAudio, ".*"),
+	DEFUN("DoSync", kDoSync, ".*"),
 
-
 	// Special and NOP stuff
 	{KF_NEW, NULL, k_Unknown, NULL},
 

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-04-25 06:42:01 UTC (rev 40141)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-04-25 08:50:42 UTC (rev 40142)
@@ -452,6 +452,7 @@
 reg_t kMessage(EngineState *s, int funct_nr, int argc, reg_t *argv);
 reg_t kGetMessage(EngineState *s, int funct_nr, int argc, reg_t *argv);
 reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv);
+reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv);
 reg_t k_Unknown(EngineState *s, int funct_nr, int argc, reg_t *argv);
 
 // The Unknown/Unnamed kernel function

Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp	2009-04-25 06:42:01 UTC (rev 40141)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp	2009-04-25 08:50:42 UTC (rev 40142)
@@ -26,6 +26,7 @@
 #include "sci/engine/state.h"
 #include "sci/sfx/player.h"
 #include "sci/engine/kernel.h"
+#include "sci/engine/vm.h"		// for Object
 
 namespace Sci {
 
@@ -989,4 +990,46 @@
 	return s->r_acc;
 }
 
+reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
+	switch (UKPV(0)) {
+	case 0:	// start sync
+		//printf("kDoSync: start sync\n");
+		if (s->sound.soundSync) {
+			s->resmgr->unlockResource(s->sound.soundSync, s->sound.soundSync->number, kResourceTypeSync);
+		}
+
+		// Load sound sync resource and lock it
+		s->sound.soundSync = (ResourceSync *)s->resmgr->findResource(kResourceTypeSync, UKPV(2), 1);
+
+		if (s->sound.soundSync) {
+			Object *obj = obj_get(s, argv[1]);
+			s->sound.soundSync->startSync(obj);
+		} else {
+			// Notify the scripts to stop sound sync
+			//Object *obj = obj_get(s, argv[1]);
+			// TODO: Convert the following from Greg's code to SCI's code
+			//obj.setPropertyN(_objOfs[0x33], 0xFFFF);	// Greg's
+			//obj->variables[s->game_obj.offset[0x33]] = 0xFFFF;	// something like this?
+		}
+		break;
+	case 1:	// next sync
+		//printf("kDoSync: next sync\n");
+		if (s->sound.soundSync) {
+			Object *obj = obj_get(s, argv[1]);
+			s->sound.soundSync->nextSync(obj);
+		}
+		break;
+	case 2:	// stop sync
+		//printf("kDoSync: stop sync\n");
+		if (s->sound.soundSync) {
+			s->sound.soundSync->stopSync();
+			s->resmgr->unlockResource(s->sound.soundSync, s->sound.soundSync->number, kResourceTypeSync);
+			s->sound.soundSync = NULL;
+		}
+		break;
+	}
+
+	return s->r_acc;
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/scicore/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource.cpp	2009-04-25 06:42:01 UTC (rev 40141)
+++ scummvm/trunk/engines/sci/scicore/resource.cpp	2009-04-25 08:50:42 UTC (rev 40142)
@@ -1167,4 +1167,36 @@
 	return error;
 }
 
+void ResourceSync::startSync(Object *obj) {
+	_syncTime = _syncCue = 0xFFFF;
+	// TODO: Convert the following from Greg's code to SCI's code
+	//obj.setPropertyN(g_sci->_objOfs[0x33], 0);	// Greg's
+	//obj->variables[s->game_obj.offset[0x33]] = 0;	// something like this?
+	_ptr = (uint16 *)data;
+	//syncStarted = true;	// not used
+}
+
+void ResourceSync::nextSync(Object *obj) {
+	if (_ptr) {
+		_syncTime = READ_LE_UINT16(_ptr);
+		if (_syncTime == 0xFFFF) {
+			stopSync();
+		} else {
+			_syncCue = READ_LE_UINT16(_ptr + 1);
+			_ptr += 2;
+		}
+		// TODO: Convert the following from Greg's code to SCI's code
+		//obj.setPropertyN(g_sci->_objOfs[0x32], _syncTime);	// Greg's
+		//obj->variables[s->game_obj.offset[0x32]] = _syncTime;	// something like this?
+		//obj.setPropertyN(g_sci->_objOfs[0x33], _syncCue);		// Greg's
+		//obj->variables[s->game_obj.offset[0x33]] = _syncCue;	// something like this?
+	}
+}
+//--------------------------------
+void ResourceSync::stopSync() {
+	_ptr = 0;
+	_syncCue = 0xFFFF;
+	//syncStarted = false;	// not used
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/scicore/resource.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource.h	2009-04-25 06:42:01 UTC (rev 40141)
+++ scummvm/trunk/engines/sci/scicore/resource.h	2009-04-25 08:50:42 UTC (rev 40142)
@@ -30,6 +30,7 @@
 #include "common/file.h"
 #include "common/archive.h"
 
+#include "sci/engine/vm.h"          // for Object
 #include "sci/scicore/decompressor.h"
 
 namespace Common {
@@ -301,6 +302,21 @@
 	void removeFromLRU(Resource *res);
 };
 
+class ResourceSync : public Resource {
+public:
+	ResourceSync() {}
+	~ResourceSync() {}
+
+	void startSync(Object *obj);
+	void nextSync(Object *obj);
+	void stopSync();
+
+protected:
+	uint16 *_ptr;
+	uint16 _syncTime, _syncCue;
+	//bool _syncStarted;	// not used
+};
+
 } // End of namespace Sci
 
 #endif // SCI_SCICORE_RESOURCE_H

Modified: scummvm/trunk/engines/sci/sfx/core.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/core.cpp	2009-04-25 06:42:01 UTC (rev 40141)
+++ scummvm/trunk/engines/sci/sfx/core.cpp	2009-04-25 08:50:42 UTC (rev 40142)
@@ -367,6 +367,7 @@
 	self->song = NULL;
 	self->flags = flags;
 	self->debug = 0; /* Disable all debugging by default */
+	self->soundSync = NULL;
 
 	if (flags & SFX_STATE_FLAG_NOSOUND) {
 		player = NULL;

Modified: scummvm/trunk/engines/sci/sfx/core.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/core.h	2009-04-25 06:42:01 UTC (rev 40141)
+++ scummvm/trunk/engines/sci/sfx/core.h	2009-04-25 08:50:42 UTC (rev 40142)
@@ -55,7 +55,7 @@
 	song_t *song; /* Active song, or start of active song chain */
 	int suspended; /* Whether we are suspended */
 	unsigned int debug; /* Debug flags */
-
+	ResourceSync *soundSync; /* Used by kDoSync for speech syncing in talkie games */
 };
 
 /***********/


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