[Scummvm-cvs-logs] CVS: scummvm/sword1 animation.cpp,1.8,1.9 animation.h,1.4,1.5

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Thu Feb 12 09:22:04 CET 2004


Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17238

Modified Files:
	animation.cpp animation.h 
Log Message:
Updated the cutscene playback code to use the new "elapsed time" mixer
function.


Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/animation.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- animation.cpp	8 Feb 2004 14:11:11 -0000	1.8
+++ animation.cpp	12 Feb 2004 17:16:38 -0000	1.9
@@ -59,7 +59,7 @@
 
 #ifdef BACKEND_8BIT
 
-	int i, p;
+	uint i, p;
 
 	// Load lookup palettes
 	// TODO: Binary format so we can use File class
@@ -301,29 +301,18 @@
 		case STATE_END:
 			if (info->display_fbuf) {
 				/* simple audio video sync code:
-				 * we calculate the actual frame by taking the delivered audio samples
-				 * we add 2 frames as the number of samples delivered is higher than the
-				 * number actually played due to buffering
-				 *
-				 * we then try to stay inside +- 1 frame of this calculated frame number by
-				 * dropping frames if we run behind and delaying if we are too fast
-				 */
-
-				/* FIXME: We shouldn't use delay_msecs() here.
-				 * We should use something like the delay()
-				 * function in SwordEngine, so that events are
-				 * handled properly. For now, at least call the
-				 * backend's event handler so that redraw
-				 * events are processed.
+				 * we calculate the actual frame by taking the elapsed audio time and try
+				 * to stay inside +- 1 frame of this calculated frame number by dropping
+				 * frames if we run behind and delaying if we are too fast
 				 */
 
 #ifdef BACKEND_8BIT
 				if (checkPaletteSwitch() || (bgSoundStream == NULL) ||
-                                    (bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < (framenum+3)){
+                                    ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum + 1)) {
 					_scr->plotYUV(lut, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
 
 					if (bgSoundStream) {
-						while ((bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < framenum+1)
+						while ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum)
 							_sys->delay_msecs(10);
 					} else {
 						ticks += 83;
@@ -338,11 +327,11 @@
 
 #else
 
-				if ((bgSoundStream == NULL) || (bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < (framenum+3)){
+				if ((bgSoundStream == NULL) || ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum + 1)) {
 					plotYUV(lookup, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
 
 					if (bgSoundStream) {
-						while ((bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < framenum+1)
+						while ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum)
 							_sys->delay_msecs(10);
 					} else {
 						ticks += 83;

Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/animation.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- animation.h	30 Jan 2004 20:57:23 -0000	1.4
+++ animation.h	12 Feb 2004 17:16:38 -0000	1.5
@@ -76,7 +76,7 @@
 	SoundMixer *_snd;
 	OSystem *_sys;
 
-	int framenum;
+	uint framenum;
 	uint32 ticks;
 
 #ifdef USE_MPEG2
@@ -106,8 +106,8 @@
 	int pos;
 
 	struct {
-		int cnt;
-		int end;
+		uint cnt;
+		uint end;
 		byte pal[4 * 256];
 	} palettes[50];
 #else





More information about the Scummvm-git-logs mailing list