[Scummvm-cvs-logs] CVS: scummvm/scumm imuse.cpp,1.10,1.11 sound.cpp,1.4,1.5 sound.h,1.3,1.4 string.cpp,1.9,1.10

Travis Howell kirben at users.sourceforge.net
Wed Sep 11 06:29:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv20703/scumm

Modified Files:
	imuse.cpp sound.cpp sound.h string.cpp 
Log Message:

Commited the following patches
[ 606595 ] Fix for Sam & Max animation glitch
[ 607175 ] Possible fix for bug #590511
[ 607677 ] Partial workaround for bug #566062
[ 607713 ] patch for bug 580350 (MI2 F5 crash)


Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- imuse.cpp	9 Sep 2002 05:03:55 -0000	1.10
+++ imuse.cpp	11 Sep 2002 13:28:33 -0000	1.11
@@ -170,6 +170,7 @@
 	int query_param(int param);
 
 	int fade_vol(byte vol, int time);
+	bool is_fading_out();
 	void sequencer_timer();
 };
 
@@ -185,7 +186,9 @@
 
 	void initialize() {
 		active = false;
-	} void on_timer();
+	}
+	void on_timer(bool probe);
+	byte fading_to();
 };
 
 struct SustainingNotes {
@@ -1134,12 +1137,12 @@
 	for (i = ARRAYSIZE(_volume_fader); i != 0; i--, vf++) {
 		if (vf->active) {
 			_active_volume_faders = true;
-			vf->on_timer();
+			vf->on_timer(false);
 		}
 	}
 }
 
-void VolumeFader::on_timer()
+void VolumeFader::on_timer(bool probe)
 {
 	byte newvol;
 
@@ -1152,13 +1155,15 @@
 	}
 
 	if (curvol != newvol) {
+		curvol = newvol;
 		if (!newvol) {
-			player->clear();
+			if (!probe)
+				player->clear();
 			active = false;
 			return;
 		}
-		curvol = newvol;
-		player->set_vol(newvol);
+		if (!probe)
+			player->set_vol(newvol);
 	}
 
 	if (!--num_steps) {
@@ -1166,14 +1171,53 @@
 	}
 }
 
+byte VolumeFader::fading_to()
+{
+	byte newvol;
+	byte orig_curvol;
+	uint16 orig_speed_lo_counter, orig_num_steps;
+
+	if (!active)
+		return 127;
+
+	// It would be so much easier to just store the fade-to volume in a
+	// variable, but then we'd have to break savegame compatibility. So
+	// instead we do a "dry run" fade.
+
+	orig_speed_lo_counter = speed_lo_counter;
+	orig_num_steps = num_steps;
+	orig_curvol = curvol;
+
+	while (active)
+		on_timer(true);
+
+	active = true;
+	newvol = curvol;
+
+	speed_lo_counter = orig_speed_lo_counter;
+	num_steps = orig_num_steps;
+	curvol = orig_curvol;
+
+	return newvol;
+}
+
 int IMuseInternal::get_sound_status(int sound)
 {
 	int i;
 	Player *player;
 
 	for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) {
-		if (player->_active && player->_id == (uint16)sound)
+		if (player->_active && player->_id == (uint16)sound) {
+			// Assume that anyone asking for the sound status is
+			// really asking "is it ok if I start playing this
+			// sound now?" So if the sound is about to fade out,
+			// shut it down and pretend it wasn't playing.
+			if (player->is_fading_out()) {
+				player->clear();
+				continue;
+			}
 			return 1;
+		}
 	}
 	return get_queue_sound_status(sound);
 }
@@ -1781,6 +1825,18 @@
 	return 0;
 }
 
+bool Player::is_fading_out()
+{
+	VolumeFader *vf = _se->_volume_fader;
+	int i;
+
+	for (i = 0; i < 8; i++, vf++) {
+		if (vf->active && vf->direction < 0 && vf->player == this && vf->fading_to() == 0)
+			return true;
+	}
+	return false;
+}
+
 void Player::clear()
 {
 	uninit_seq();
@@ -3038,6 +3094,18 @@
 			player->set_tempo(player->_tempo);
 			scumm->getResourceAddress(rtSound, player->_id);
 			player->_mt32emulate = isMT32(player->_id);
+			if (scumm->_use_adlib) {
+				// FIXME - This should make sure the right
+				// instruments are loaded, but it does not
+				// even try to move to the right position in
+				// the track. Using scan() gives a marginally
+				// better result, but not good enough.
+				//
+				// The correct fix is probably to store the
+				// Adlib instruments, or information on where
+				// to find them, in the savegame.
+				player->jump(player->_track_index, 0, 0);
+			}
 		}
 	}
 }

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sound.cpp	9 Sep 2002 11:15:44 -0000	1.4
+++ sound.cpp	11 Sep 2002 13:28:34 -0000	1.5
@@ -407,7 +407,11 @@
 					b = isMouthSyncOff(_curSoundPos);
 				if (_mouthSyncMode != b) {
 					_mouthSyncMode = b;
-					a->startAnimActor(b ? a->talkFrame2 : a->talkFrame1);
+					if (_talk_sound_frame != -1) {
+						a->startAnimActor(_talk_sound_frame);
+						_talk_sound_frame = -1;
+					} else
+						a->startAnimActor(b ? a->talkFrame2 : a->talkFrame1);
 				}
 			}
 		}
@@ -618,10 +622,11 @@
 		error("Sound que buffer overflow");
 }
 
-void Sound::talkSound(uint32 a, uint32 b, int mode) {
+void Sound::talkSound(uint32 a, uint32 b, int mode, int frame) {
 	_talk_sound_a = a;
 	_talk_sound_b = b;
 	_talk_sound_mode = mode;
+	_talk_sound_frame = frame;
 }
 
 /* The sound code currently only supports General Midi.

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sound.h	2 Sep 2002 07:53:43 -0000	1.3
+++ sound.h	11 Sep 2002 13:28:34 -0000	1.4
@@ -56,6 +56,7 @@
 	File *_sfxFile;
 	uint32 _talk_sound_a, _talk_sound_b;
 	byte _talk_sound_mode;
+	int _talk_sound_frame;
 	bool _mouthSyncMode;
 	bool _endOfMouthSync;
 	uint16 _mouthSyncTimes[52];
@@ -107,7 +108,7 @@
 	void stopAllSounds();
 	void clearSoundQue();
 	void soundKludge(int16 * list);
-	void talkSound(uint32 a, uint32 b, int mode);
+	void talkSound(uint32 a, uint32 b, int mode, int frame);
 	void setupSound();
 	void pauseSounds(bool pause);
 	int startSfxSound(File *file, int file_size);

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- string.cpp	31 Aug 2002 19:26:04 -0000	1.9
+++ string.cpp	11 Sep 2002 13:28:34 -0000	1.10
@@ -174,7 +174,7 @@
 		a = buffer[2] | (buffer[3] << 8) | (buffer[6] << 16) | (buffer[7] << 24);
 		b = buffer[10] | (buffer[11] << 8) | (buffer[14] << 16) | (buffer[15] << 24);
 //    if (_saveSound != 1)
-		_sound->talkSound(a, b, 1);
+		_sound->talkSound(a, b, 1, -1);
 	}
 //  warning("unkMessage1(\"%s\")", buffer);
 }
@@ -196,10 +196,14 @@
 
 void Scumm::CHARSET_1()
 {
+	uint32 talk_sound_a = 0;
+	uint32 talk_sound_b = 0;
 	int s, i, t, c;
-	int frme;
+	int frme = -1;
 	Actor *a;
 	byte *buffer;
+	bool has_talk_sound = false;
+	bool has_anim = false;
 
 	if (!_haveMsg)
 		return;
@@ -290,7 +294,8 @@
 	}
 
 	if (a && !string[0].no_talk_anim) {
-		a->startAnimActor(a->talkFrame1);
+//		a->startAnimActor(a->talkFrame1);
+		has_anim = true;
 		_useTalkAnims = true;
 	}
 
@@ -397,14 +402,11 @@
 		} else if (c == 9) {
 			frme = *buffer++;
 			frme |= *buffer++ << 8;
-			if (a)
-				a->startAnimActor(frme);
+			has_anim = true;
 		} else if (c == 10) {
-			uint32 tmpA, tmpB;
-
-			tmpA = buffer[0] | (buffer[1] << 8) | (buffer[4] << 16) | (buffer[5] << 24);
-			tmpB = buffer[8] | (buffer[9] << 8) | (buffer[12] << 16) | (buffer[13] << 24);
-			_sound->talkSound(tmpA, tmpB, 2);
+			talk_sound_a = buffer[0] | (buffer[1] << 8) | (buffer[4] << 16) | (buffer[5] << 24);
+			talk_sound_b = buffer[8] | (buffer[9] << 8) | (buffer[12] << 16) | (buffer[13] << 24);
+			has_talk_sound = true;
 			buffer += 14;
 
 			// Set flag that speech variant exist of this msg
@@ -435,6 +437,16 @@
 			warning("CHARSET_1: invalid code %d", c);
 		}
 	} while (1);
+
+	// Even if talkSound() is called, we may still have to call
+	// startAnimActor() since actorTalk() may already have caused the
+	// wrong animation frame to be drawn, and the talkSound() won't be
+	// processed until after the next screen update. Bleah.
+
+	if (has_talk_sound)
+		_sound->talkSound(talk_sound_a, talk_sound_b, 2, frme);
+	if (a && has_anim)
+		a->startAnimActor(frme != -1 ? frme : a->talkFrame1);
 
 	charset._bufPos = buffer - charset._buffer;
 





More information about the Scummvm-git-logs mailing list