[Scummvm-cvs-logs] CVS: scummvm/scumm saveload.cpp,1.60,1.61 script_v5.cpp,1.56,1.57 scumm.h,1.175,1.176 scummvm.cpp,2.117,2.118 sound.cpp,1.106,1.107 sound.h,1.28,1.29 vars.cpp,1.44,1.45

Max Horn fingolfin at users.sourceforge.net
Wed Apr 30 17:05:04 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv15665

Modified Files:
	saveload.cpp script_v5.cpp scumm.h scummvm.cpp sound.cpp 
	sound.h vars.cpp 
Log Message:
various music related changes and cleanup; also modified MonkeyVGA music sync, at least the intro is much better synced now; not sure about other parts of it / other games

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- saveload.cpp	30 Apr 2003 13:23:29 -0000	1.60
+++ saveload.cpp	1 May 2003 00:04:05 -0000	1.61
@@ -188,7 +188,7 @@
 
 	initBGBuffers(_scrHeight);
 
-	if ((_features & GF_AUDIOTRACKS) && _vars[VAR_MI1_TIMER] > 0)
+	if ((_features & GF_AUDIOTRACKS) && _vars[VAR_MUSIC_TIMER] > 0)
 		_sound->startCDTimer();
 
 	CHECK_HEAP debug(1, "State loaded from '%s'", filename);

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- script_v5.cpp	30 Apr 2003 11:15:09 -0000	1.56
+++ script_v5.cpp	1 May 2003 00:04:05 -0000	1.57
@@ -2053,7 +2053,7 @@
 }
 
 void Scumm_v5::o5_startSound() {
-	_vars[VAR_MUSIC_FLAG] = 0;
+	_vars[VAR_MUSIC_TIMER] = 0;
 	_sound->addSoundToQueue(getVarOrDirectByte(0x80));
 }
 
@@ -2474,7 +2474,7 @@
 				int delay = (uint16)getVarOrDirectWord(0x40);
 
 				if (_gameId == GID_LOOM256) {
-					_vars[VAR_MI1_TIMER] = 0;
+					_vars[VAR_MUSIC_TIMER] = 0;
 					if (offset == 0 && delay == 0) {
 						_sound->stopCD();
 					} else {

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- scumm.h	30 Apr 2003 21:30:57 -0000	1.175
+++ scumm.h	1 May 2003 00:04:05 -0000	1.176
@@ -1056,7 +1056,7 @@
 	byte VAR_TMR_1;
 	byte VAR_TMR_2;
 	byte VAR_TMR_3;
-	byte VAR_MUSIC_FLAG;
+	byte VAR_MUSIC_TIMER;
 	byte VAR_ACTOR_RANGE_MIN;
 	byte VAR_ACTOR_RANGE_MAX;
 	byte VAR_CAMERA_MIN_X;
@@ -1111,9 +1111,7 @@
 	byte VAR_NEW_ROOM;
 	byte VAR_VERSION;
 
-	byte VAR_MI1_TIMER;
 	byte VAR_V5_TALK_STRING_Y;
-	byte VAR_V5_CHARFLAG;
 
 	byte VAR_V6_SCREEN_WIDTH;
 	byte VAR_V6_SCREEN_HEIGHT;

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.117
retrieving revision 2.118
diff -u -d -r2.117 -r2.118
--- scummvm.cpp	30 Apr 2003 21:30:57 -0000	2.117
+++ scummvm.cpp	1 May 2003 00:04:05 -0000	2.118
@@ -699,7 +699,7 @@
 		// Setup light
 		_vars[VAR_CURRENT_LIGHTS] = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen;
 	} else {
-			_vars[VAR_V6_EMSSPACE] = 10000;
+		_vars[VAR_V6_EMSSPACE] = 10000;
 	}
 
 	if (_features & GF_AFTER_V8) {	// Fixme: How do we deal with non-cd installs?
@@ -725,8 +725,6 @@
 }
 
 int Scumm::scummLoop(int delta) {
-	static int counter = 0;
-
 #ifndef _WIN32_WCE
 	if (_debugger)
 		_debugger->on_frame();
@@ -771,23 +769,30 @@
 	_vars[VAR_MOUSE_Y] = mouse.y;
 	_vars[VAR_DEBUGMODE] = _debugMode;
 
-	if (_gameId == GID_MONKEY_VGA) {
-		// FIXME: Is all this really necessary now?
-		if (delta == 1)
-			_vars[VAR_MI1_TIMER]++;
-		else if (++counter != 2)
-			_vars[VAR_MI1_TIMER] += 5;
-		else {
-			counter = 0;
-			_vars[VAR_MI1_TIMER] += 6;
-		}
-	} else if (_features & GF_AUDIOTRACKS) {
-		_vars[VAR_MI1_TIMER] = _sound->readCDTimer();
-	} else if ((_features & GF_OLD256) || (_features & GF_16COLOR)) {
-
-		if(tempMusic == 3) {
+	if (_features & GF_AUDIOTRACKS) {
+		// Covered automatically by the Sound class
+	} else if ((_features & GF_OLD256) || (_features & GF_16COLOR) || (_gameId == GID_MONKEY_VGA)) {
+		// Original values:
+		//const int ITERATIONS = 4;
+		//const int INCREMENT = 1;
+		
+		// This function (scummLoop) is invoked roughly every delta*15 milliseconds.
+		// In GID_MONKEY_VGA, delta usually is 5 or 6, hence this function is called
+		// every 75-90 ms. 
+		// With the original values, we incremented VAR_MUSIC_TIMER every fourth
+		// iteration by 1. That corresponds to a time interval of 18.75 / 22.5 ms.
+		//
+		// With the new values, we have a ratio of 3/11 = 0.272727... which makes
+		// the GID_MONKEY_VGA intro synced quite perfectly on my system. But I am not sure
+		// which impact this might have on other games, or on other parts in MI.
+		// However, even with the 4/1 values this seems much better than the old code
+		// for handling GID_MONKEY_VGA...
+		const int ITERATIONS = 11;
+		const int INCREMENT = 3;
+		
+		if (tempMusic == ITERATIONS-1) {
 			tempMusic = 0;
-			_vars[VAR_MUSIC_FLAG]++;
+			_vars[VAR_MUSIC_TIMER] += INCREMENT;
 		} else {
 			tempMusic++;
 		}

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- sound.cpp	30 Apr 2003 13:23:31 -0000	1.106
+++ sound.cpp	1 May 2003 00:04:05 -0000	1.107
@@ -185,7 +185,7 @@
 		}
 		else if (READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
 			ptr += 8;
-			_scumm->_vars[_scumm->VAR_MI1_TIMER] = 0;
+			_scumm->_vars[_scumm->VAR_MUSIC_TIMER] = 0;
 			playCDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
 							(ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0);
 
@@ -782,7 +782,7 @@
 		_scumm->_imuseDigital->pause(pause);
 	}
 
-	if ((_scumm->_features & GF_AUDIOTRACKS) && _scumm->_vars[_scumm->VAR_MI1_TIMER] > 0) {
+	if ((_scumm->_features & GF_AUDIOTRACKS) && _scumm->_vars[_scumm->VAR_MUSIC_TIMER] > 0) {
 		if (pause)
 			stopCDTimer();
 		else
@@ -1388,20 +1388,11 @@
 static void cd_timer_handler(void *ptr) {
 	Scumm *scumm = (Scumm *) ptr;
 
-	// Maybe I could simply update _vars[VAR_MI1_TIMER] directly here, but
-	// I don't feel comfortable just doing that from what might be a
-	// separate thread. If someone tells me it's safe, I'll make the
-	// change right away.
-	
 	// FIXME: Turn off the timer when it's no longer needed. In theory, it
 	// should be possible to check with pollCD(), but since CD sound isn't
 	// properly restarted when reloading a saved game, I don't dare to.
 
-	scumm->_sound->_cd_timer_value += 6;
-}
-
-int Sound::readCDTimer() {
-	return _cd_timer_value;
+	scumm->_vars[scumm->VAR_MUSIC_TIMER] += 6;
 }
 
 void Sound::startCDTimer() {
@@ -1418,7 +1409,6 @@
 		timer_interval = 101;
 
 	_scumm->_timer->releaseProcedure(&cd_timer_handler);
-	_cd_timer_value = _scumm->_vars[_scumm->VAR_MI1_TIMER];
 	_scumm->_timer->installProcedure(&cd_timer_handler, 1000 * timer_interval);
 }
 
@@ -1518,7 +1508,7 @@
 
 int Sound::playMP3CDTrack(int track, int num_loops, int start, int delay) {
 	int index;
-	_scumm->_vars[_scumm->VAR_MI1_TIMER] = 0;
+	_scumm->_vars[_scumm->VAR_MUSIC_TIMER] = 0;
 
 	if (_soundsPaused)
 		return 0;

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- sound.h	6 Mar 2003 21:46:27 -0000	1.28
+++ sound.h	1 May 2003 00:04:05 -0000	1.29
@@ -133,7 +133,6 @@
 	int32 _bundleMusicPosition;
 
 	int _talkChannel;	/* Mixer channel actor is talking on */
-	int _cd_timer_value;
 	bool _soundsPaused;
 	int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx;
 	byte _sfxMode;
@@ -173,7 +172,6 @@
 	int playSfxSound_MP3(void *sound, uint32 size);
 	int playSfxSound_Vorbis(void *sound, uint32 size);
 
-	int readCDTimer();
 	void startCDTimer();
 	void stopCDTimer();
 

Index: vars.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/vars.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- vars.cpp	30 Apr 2003 21:30:59 -0000	1.44
+++ vars.cpp	1 May 2003 00:04:05 -0000	1.45
@@ -40,7 +40,7 @@
 	VAR_TMR_1 = 11;
 	VAR_TMR_2 = 12;
 	VAR_TMR_3 = 13;
-	VAR_MUSIC_FLAG = 14;
+	VAR_MUSIC_TIMER = 14;
 	VAR_ACTOR_RANGE_MIN = 15;
 	VAR_ACTOR_RANGE_MAX = 16;
 	VAR_CAMERA_MIN_X = 17;
@@ -94,10 +94,12 @@
 	VAR_NEW_ROOM = 72;	// Zak256 Note: Cashcard for Leslie
 	VAR_VERSION = 75;
 
-	VAR_MI1_TIMER = 14;
-
 	VAR_V5_TALK_STRING_Y = 54;
-	VAR_V5_CHARFLAG = 60;
+}
+
+void Scumm_v6::setupScummVars() {
+	// Many vars are the same as in V5 games, so just call the inherited method first
+	Scumm::setupScummVars();
 
 	VAR_V6_SCREEN_WIDTH = 41;
 	VAR_V6_SCREEN_HEIGHT = 54;
@@ -105,11 +107,6 @@
 	VAR_V6_RANDOM_NR = 118;
 	
 	VAR_V6_SOUNDMODE = 9;
-}
-
-void Scumm_v6::setupScummVars() {
-	// Many vars are the same as in V5 games, so just call the inherited method first
-	Scumm::setupScummVars();
 
 	VAR_TIMEDATE_YEAR = 119;
 	VAR_TIMEDATE_MONTH = 129;
@@ -142,6 +139,7 @@
 	VAR_PERFORMANCE_1 = 26;
 	VAR_PERFORMANCE_2 = 27;
 	VAR_GAME_LOADED = 29;
+	VAR_V6_EMSSPACE = 32;
 	VAR_V6_RANDOM_NR = 34;
 	VAR_NEW_ROOM = 35;
 	VAR_WALKTO_OBJ = 36;
@@ -198,11 +196,6 @@
 	VAR_VIDEONAME = 123;
 	VAR_CUSTOMSCALETABLE = 131;
 
-	VAR_MI1_TIMER = 14;
-	VAR_V5_TALK_STRING_Y = 54;
-	VAR_V5_CHARFLAG = 60;
-
-	VAR_V6_EMSSPACE = 32;
 	VAR_STRING2DRAW = 130;
 }
 
@@ -303,7 +296,7 @@
 	VAR_NUM_ACTOR = 11;
 	VAR_CURRENT_LIGHTS = 12;
 	VAR_CURRENTDRIVE = 13;
-	VAR_MUSIC_FLAG = 17;
+	VAR_MUSIC_TIMER = 17;
 	VAR_ACTOR_RANGE_MIN = 19;
 	VAR_ACTOR_RANGE_MAX = 20;
 	VAR_CAMERA_MIN_X = 23;





More information about the Scummvm-git-logs mailing list