[Scummvm-cvs-logs] CVS: scummvm/simon midi.cpp,1.9,1.10 midi.h,1.3,1.4 simon.cpp,1.70,1.71

Travis Howell kirben at users.sourceforge.net
Tue Nov 12 20:35:03 CET 2002


Update of /cvsroot/scummvm/scummvm/simon
In directory usw-pr-cvs1:/tmp/cvs-serv14240/simon

Modified Files:
	midi.cpp midi.h simon.cpp 
Log Message:

An ugly hack to allow music looping in simon1talkie
Most likely better wat to do this...


Index: midi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- midi.cpp	13 Nov 2002 00:24:47 -0000	1.9
+++ midi.cpp	13 Nov 2002 04:34:45 -0000	1.10
@@ -31,7 +31,7 @@
 // FIXME: This is a horrible place to put this, but for now....
 #include "sound/midistreamer.cpp"
 
-void MidiPlayer::read_all_songs(File *in)
+void MidiPlayer::read_all_songs(File *in, uint music)
 {
 	uint i, num;
 
@@ -40,11 +40,11 @@
 	num = in->readByte();
 
 	for (i = 0; i != num; i++) {
-		read_one_song(in, &_songs[i]);
+		read_one_song(in, &_songs[i], music);
 	}
 }
 
-void MidiPlayer::read_all_songs_old(File *in)
+void MidiPlayer::read_all_songs_old(File *in, uint music)
 {
 	uint i, num;
 
@@ -53,11 +53,11 @@
 	num = 1;
 
 	for (i = 0; i != num; i++) {
-		read_one_song(in, &_songs[i]);
+		read_one_song(in, &_songs[i], music);
 	}
 }
 
-void MidiPlayer::read_mthd(File *in, Song *s, bool old)
+void MidiPlayer::read_mthd(File *in, Song *s, bool old, uint music)
 {
 	Track *t;
 	uint i;
@@ -88,11 +88,81 @@
 
 			t->data_size = in->readUint32BE();
 		} else {
-			uint32 pos = in->pos();
-			in->seek(0, SEEK_END);
-			uint32 end = in->pos();
-			in->seek(pos, SEEK_SET);
-			t->data_size = end - pos;
+			//FIXME We currently don't know how to find out music track size for GMF midi format
+			// So we use music files sizes minues header for now to allow looping
+			if (music == 0)
+				t->data_size = 8900;
+			if (music == 1)
+				t->data_size = 12166;
+			if (music == 2)
+				t->data_size = 2848;
+			if (music == 3)
+				t->data_size = 3442;
+			if (music == 4) 
+				t->data_size = 4034;
+			if (music == 5)
+				t->data_size = 4508;
+			if (music == 6)
+				t->data_size = 7064;
+			if (music == 7)
+				t->data_size = 9730;
+			if (music == 8)
+				t->data_size = 6014;
+			if (music == 9)
+				t->data_size = 4742;
+			if (music == 10) 
+				t->data_size = 3138;
+			if (music == 11) 
+				t->data_size = 6570;
+			if (music == 12) 
+				t->data_size = 5384;
+			if (music == 13) 
+				t->data_size = 8909;
+			if (music == 14) 
+				t->data_size = 6457;
+			if (music == 15) 
+				t->data_size = 16321;
+			if (music == 16) 
+				t->data_size = 2742;
+			if (music == 17) 
+				t->data_size = 8968;
+			if (music == 18) 
+				t->data_size = 4804;
+			if (music == 19) 
+				t->data_size = 8442;
+			if (music == 20) 
+				t->data_size = 7717;
+			if (music == 21)
+				t->data_size =  9444;
+			if (music == 22)
+				t->data_size = 5800;
+			if (music == 23)
+				t->data_size = 1381;
+			if (music == 24)
+				t->data_size = 5660;
+			if (music == 25)
+				t->data_size = 6684;
+			if (music == 26)
+				t->data_size = 2456;
+			if (music == 27)
+				t->data_size = 4744;
+			if (music == 28)
+				t->data_size = 2455;
+			if (music == 29)
+				t->data_size = 1177;
+			if (music == 30)
+				t->data_size = 1232;
+			if (music == 31)
+				t->data_size = 17256;
+			if (music == 32)
+				t->data_size = 5103;
+			if (music == 33)
+				t->data_size = 8794;
+			if (music == 34)
+				t->data_size = 4884;
+			if (music == 35)
+				t->data_size = 16;
+			t->data_size = t->data_size - 8;
 		}
 
 		t->data_ptr = (byte *)calloc(t->data_size, 1);
@@ -117,7 +187,7 @@
 	}
 }
 
-void MidiPlayer::read_one_song(File *in, Song *s)
+void MidiPlayer::read_one_song(File *in, Song *s, uint music)
 {
 	_lastDelay = 0;
 
@@ -130,12 +200,12 @@
 
 	switch (id) {
 	case 'MThd':
-		read_mthd(in, s, false);
+		read_mthd(in, s, false, music);
 		break;
 
 	case 'GMF\x1':
 		warning("Old style songs not properly supported yet");
-		read_mthd(in, s, true);
+		read_mthd(in, s, true, music);
 		break;
 
 	default:

Index: midi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- midi.h	21 Oct 2002 12:57:15 -0000	1.3
+++ midi.h	13 Nov 2002 04:34:45 -0000	1.4
@@ -28,8 +28,8 @@
 
 class MidiPlayer {
 public:
-	void read_all_songs(File *in);
-	void read_all_songs_old(File *in);
+	void read_all_songs(File *in, uint music);
+	void read_all_songs_old(File *in, uint music);
 	void initialize();
 	void shutdown();
 	void play();
@@ -69,9 +69,9 @@
 	uint32 _volumeTable[16];
 
 
-	void read_mthd(File *in, Song *s, bool old);
+	void read_mthd(File *in, Song *s, bool old, uint music);
 
-	void read_one_song(File *in, Song *s);
+	void read_one_song(File *in, Song *s, uint music);
 
 	static uint32 track_read_gamma(Track *t);
 	static byte track_read_byte(Track *t);

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- simon.cpp	11 Nov 2002 15:25:30 -0000	1.70
+++ simon.cpp	13 Nov 2002 04:34:45 -0000	1.71
@@ -4991,14 +4991,12 @@
 
 void SimonState::playMusic(uint music)
 {
-	/* FIXME: not properly implemented */
-	/* Simon 1 dos talkie music doesn't detect correct size of music data */
-	/* Simon 2 dos talkie music isn't supported */
-	/* Simon 2 dos music isn't supported */
+	/* TODO */
+	/* Simon 2 dos / talkie music requires xmi midi format support */
 	if (_game & GAME_WIN) {	
 		midi.shutdown();
 		_game_file->seek(_game_offsets_ptr[gss->MUSIC_INDEX_BASE + music], SEEK_SET);
-		midi.read_all_songs(_game_file);
+		midi.read_all_songs(_game_file, music);
 	
 		midi.initialize();
 		midi.play();
@@ -5007,7 +5005,7 @@
 
 		if (_game & GAME_TALKIE) {
 			_game_file->seek(_game_offsets_ptr[gss->MUSIC_INDEX_BASE + music], SEEK_SET);
-			midi.read_all_songs_old(_game_file);
+			midi.read_all_songs_old(_game_file, music);
 		} else {
 			char buf[50];
 			File *f = new File();
@@ -5017,7 +5015,7 @@
 				warning("Cannot load music from '%s'", buf);
 				return;
 			}
-			midi.read_all_songs_old(f);
+			midi.read_all_songs_old(f, music);
 			delete f;
 		}
 





More information about the Scummvm-git-logs mailing list