[Scummvm-cvs-logs] CVS: scummvm/simon vga.cpp,1.46,1.47 items.cpp,1.66,1.67 simon.cpp,1.195,1.196

Jamieson Christian jamieson630 at users.sourceforge.net
Tue May 20 17:45:10 CEST 2003


Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv28616/scummvm/simon

Modified Files:
	vga.cpp items.cpp simon.cpp 
Log Message:
Various cleanup of Simon music code

Index: vga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/vga.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- vga.cpp	20 May 2003 17:11:39 -0000	1.46
+++ vga.cpp	21 May 2003 00:44:36 -0000	1.47
@@ -1804,21 +1804,46 @@
 
 void SimonState::vc_69() {
 	// Simon2
-	uint16 a = vc_read_next_word();
-	uint16 b = vc_read_next_word();
+	int16 track = vc_read_next_word();
+	int16 paused = vc_read_next_word();
 
 	if (_debugMode)
-		warning("vc_69(%d,%d): music stuff?", a, b);
+		warning("vc_69(%d,%d): music stuff", track, paused);
 
+	// Jamieson630:
+	// This is a "play or queue track". The original
+	// design stored the track to play if one was
+	// already in progress, so that the next time a
+	// "fill MIDI stream" event occured, the MIDI
+	// player would find the change and switch
+	// tracks. We use a different architecture that
+	// allows for an immediate response here, but
+	// we'll simulate the variable changes so other
+	// scripts don't get thrown off.
+	// NOTE: This opcode looks very similar in function
+	// to vc_72(), except that vc_72() may allow for
+	// specifying a non-valid track number (999 or -1)
+	// as a means of stopping what music is currently
+	// playing.
+	if (_vc72_var1 != track) {
+		midi_play (track);
+		if (paused)
+			midi.pause (true);
+		_vc72_var1 = track;
+		_vc72_var2 = -1; // (a & 0xFF) << 8 | (a >> 8);
+		_vc72_var3 = -1;
+	}
+/*
+	// ORIGINAL TRANSLATION FROM DISASSEMBLY
 	if (_vc72_var1 == 999 || _vc72_var1 == -1) {
-		_vc70_var2 = b;
-		midi_play (a);
-		_vc72_var1 = a;
-	} else if (_vc72_var1 != a) {
-		_vc72_var3 = a;
-		_vc72_var2 = (a & 0xFF) << 8 | (a >> 8);
+		_vc70_var2 = paused;
+		midi_play (track);
+		_vc72_var1 = track;
+	} else if (_vc72_var1 != track) {
+		_vc72_var3 = track;
+		_vc72_var2 = paused; // (a & 0xFF) << 8 | (a >> 8);
 	}
-
+*/
 }
 
 void SimonState::vc_70() {
@@ -1841,14 +1866,48 @@
 
 void SimonState::vc_72() {
 	// Simon2
+	// Jamieson630:
+	// This is a "queue or stop track". The original
+	// design stored the track to play if one was
+	// already in progress, so that the next time a
+	// "fill MIDI stream" event occured, the MIDI
+	// player would find the change and switch
+	// tracks. We use a different architecture that
+	// allows for an immediate response here, but
+	// we'll simulate the variable changes so other
+	// scripts don't get thrown off.
+	// NOTE: This opcode looks very similar in function
+	// to vc_72(), except that this opcode may allow
+	// for specifying a track of 999 or -1 in order to
+	// stop the music. We'll code it that way for now.
+	int16 track = vc_read_next_word();
+	int16 paused = !vc_read_next_word();
+
+	if (_debugMode)
+		warning ("vc_72 (%d, %d): music stuff?", track, paused);
+
+	if (track != _vc72_var1) {
+		if (track == -1 || track == 999) {
+			midi.stop();
+			_vc72_var1 = -1;
+		} else {
+			midi_play (track);
+			if (paused)
+				midi.pause (true);
+			_vc72_var1 = track;
+			_vc72_var2 = paused;
+		}
+		_vc72_var3 = -1;
+	}
+/*
+	// ORIGINAL TRANSLATION FROM DISASSEMBLY
 	uint16 a = vc_read_next_word();
 	uint16 b = vc_read_next_word();
 	if (a != _vc72_var1) {
 		_vc72_var2 = b;
 		_vc72_var3 = a;
 	}
-
-	midi.jump (a, b);
+*/
 }
 
 void SimonState::vc_73_set_op189_flag() {

Index: items.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/items.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- items.cpp	20 May 2003 16:43:53 -0000	1.66
+++ items.cpp	21 May 2003 00:44:37 -0000	1.67
@@ -1432,68 +1432,52 @@
 }
 
 void SimonState::o_unk_127() {
-	int a = getVarOrWord();
-	int b = getVarOrWord();
+	int music = getVarOrWord();
+	int track = getVarOrWord();
 
+	// Jamieson630:
+	// This appears to be a "load or play music" command.
+	// The music resource is specified, and optionally
+	// a track as well. Normally we see two calls being
+	// made, one to load the resource and another to
+	// actually start a track (so the resource is
+	// effectively preloaded so there's no latency when
+	// starting playback).
 	if (_game & GF_SIMON2) {
-		uint c = getVarOrByte();
+		int play = getVarOrByte();
 
-		if (_debugMode)
-			warning("o_unk_127(%d,%d,%d) not implemented properly", a, b, c);
+		if (_debugMod)
+			debug (0, "o_unk_127 (%d, %d, %d);", music, track, play);
 
-		if (_last_music_played != a) {
-			if (b == 999) {
-//				_next_music_to_play = a;
-				playMusic (a);
-				_last_music_played = a;
-				// midi_play (0);
-			}
+		if (_last_music_played != music) {
+			playMusic (music);
+			_last_music_played = music;
+			_next_music_to_play = -1;
+			_vc72_var1 = _vc72_var2 = _vc72_var3 = -1;
 		}
 
-		if (b == _vc72_var1 || b == 999)
+		if (track == _vc72_var1 || track == 999)
 			return;
 
-		if (_vc72_var1 == -1 || _vc72_var1 == 999) {
-			_vc70_var2 = c;
-			_vc70_var1 = -1;
-			_vc72_var3 = -1;
-			midi_play (b);
-			_vc72_var1 = b;
-		} else {
-			midi_play (b);
-//			_vc72_var3 = b;
-//			_vc72_var2 = c;
-		}
-/*
-		if (_last_music_played == a) {
-			if (b == _vc72_var1 || b == 999) 
-				return;
+		_vc72_var1 = track;
+		_vc70_var2 = -1;
+		_vc72_var3 = -1;
+		midi_play (track);
 
-			//FIXME Changed if to allow midi jumping to work for now.
-			if (b != 1)  {
-				_vc70_var2 = c;
-				_vc70_var1 = -1;
-				_vc72_var3 = -1;
-				_next_music_to_play = -1;
-				midi_play(b);
-				_vc72_var1 = b;
-			} else {
-				//FIXME This is another midi jump, not sure if variable order is correct.
-				_vc72_var3 = b;
-				_vc72_var2 = c;
-				midi.jump (b, c);
-			}
-		} else if (b == 999) {
-			// _next_music_to_play = a;
-			playMusic (a);
-			midi_play (b);
-		}
-*/
+		// FIXME: This doesn't seem to actually be a pause
+		// indicator. If it's interpreted as such, it spoils
+		// the music when Simon is exiting Calypso's shop
+		// during the opening cutscene. Let's see if it
+		// ever goes to anything besides 0 or 1.
+//		if (play == 0)
+//			midi.pause (true);
+		if (play != 0 && play != 1)
+			warning ("o_unk_127: play mode %d encountered!", play);
 	} else {
-		if (a != _last_music_played) {
-			_last_music_played = a;
-			playMusic(a);
-			midi_play (b);
+		if (music != _last_music_played) {
+			_last_music_played = music;
+			playMusic (music);
+			midi_play (track);
 		}
 	}
 }

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -d -r1.195 -r1.196
--- simon.cpp	20 May 2003 16:43:53 -0000	1.195
+++ simon.cpp	21 May 2003 00:44:37 -0000	1.196
@@ -5280,12 +5280,7 @@
 void SimonState::midi_play (uint track) {
 	if (track == 999)
 		return;
-
-	if (_vc72_var1 == 999) {
-//		_midi_var11 = 0;
-		midi.jump (track, 0);
-//		_midi_var12 = 1;
-	}
+	midi.jump (track, 0);
 }
 
 





More information about the Scummvm-git-logs mailing list