[Scummvm-cvs-logs] CVS: scummvm/saga music.cpp,1.15,1.16 music.h,1.6,1.7

Eugene Sandulenko sev at users.sourceforge.net
Sat May 29 14:05:06 CEST 2004


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

Modified Files:
	music.cpp music.h 
Log Message:
Extend midi music table.
Implement music looping.


Index: music.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/music.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- music.cpp	16 May 2004 12:57:49 -0000	1.15
+++ music.cpp	29 May 2004 21:04:44 -0000	1.16
@@ -158,38 +158,37 @@
 }
 
 // The Wyrmkeep release of Inherit The Earth features external MIDI files, so
-// we need a mapping from resource number to filename. This lookup table is
-// based on experimenting and guessing, so it may very well contain errors.
+// we need a mapping from resource number to filename.
 //
-// There is also a reset.mid, but I don't think we'll ever need that one.
+// reset.mid seems to be unused.
 
-const char *Music::_midiTableITECD[26] = {
-	"cave",		// 9
-	"intro",	// 10
-	"fvillage",	// 11
-	"elkhall",	// 12
-	"mouse",	// 13
-	"darkclaw",	// 14
-	"birdchrp",	// 15
-	"orbtempl",	// 16
-	"spooky",	// 17
-	"catfest",	// 18
-	"elkfanfare",	// 19
-	"bcexpl",	// 20
-	"boargtnt",	// 21
-	"boarking",	// 22
-	"explorea",	// 23
-	"exploreb",	// 24
-	"explorec",	// 25
-	"sunstatm",	// 26
-	"nitstrlm",	// 27
-	"humruinm",	// 28
-	"damexplm",	// 29
-	"tychom",	// 30
-	"kitten",	// 31
-	"sweet",	// 32
-	"brutalmt",	// 33
-	"shiala",	// 34
+const MUSIC_MIDITABLE Music::_midiTableITECD[26] = {
+	{"cave", R_MUSIC_LOOP},		// 9
+	{"intro", R_MUSIC_LOOP},	// 10
+	{"fvillage", R_MUSIC_LOOP},	// 11
+	{"elkhall", R_MUSIC_LOOP},	// 12
+	{"mouse", 0},				// 13
+	{"darkclaw", R_MUSIC_LOOP},	// 14
+	{"birdchrp", R_MUSIC_LOOP},	// 15
+	{"orbtempl", R_MUSIC_LOOP},	// 16
+	{"spooky", R_MUSIC_LOOP},	// 17
+	{"catfest", R_MUSIC_LOOP},	// 18
+	{"elkfanfare", 0},			// 19
+	{"bcexpl", R_MUSIC_LOOP},	// 20
+	{"boargtnt", R_MUSIC_LOOP},	// 21
+	{"boarking", R_MUSIC_LOOP},	// 22
+	{"explorea", R_MUSIC_LOOP},	// 23
+	{"exploreb", R_MUSIC_LOOP},	// 24
+	{"explorec", R_MUSIC_LOOP},	// 25
+	{"sunstatm", R_MUSIC_LOOP},	// 26
+	{"nitstrlm", R_MUSIC_LOOP},	// 27
+	{"humruinm", R_MUSIC_LOOP},	// 28
+	{"damexplm", R_MUSIC_LOOP},	// 29
+	{"tychom", R_MUSIC_LOOP},	// 30
+	{"kitten", R_MUSIC_LOOP},	// 31
+	{"sweet", R_MUSIC_LOOP},	// 32
+	{"brutalmt", R_MUSIC_LOOP},	// 33
+	{"shiala", R_MUSIC_LOOP}	// 34
 };
 
 int Music::play(uint32 music_rn, uint16 flags) {
@@ -212,7 +211,7 @@
 	if (GAME_GetGameType() == R_GAMETYPE_ITE) {
 		if (music_rn >= 9 && music_rn <= 34) {
 			char file_name[20];
-			sprintf(file_name, "music/%s.mid", _midiTableITECD[music_rn - 9]);
+			sprintf(file_name, "music/%s.mid", _midiTableITECD[music_rn - 9].filename);
 			f_midi.open(file_name);
 		}
 	}
@@ -228,6 +227,9 @@
 
 		_player->setGM(true);
 		parser = MidiParser::createParser_SMF();
+
+		// FIXME: Is this really the case or we receive correct parameter?
+		flags = _midiTableITECD[music_rn - 9].flags;
 	} else {
 		/* Load XMI resource data */
 		GAME_GetFileContext(&rsc_ctxt, R_GAME_RESOURCEFILE, 0);
@@ -256,6 +258,11 @@
 
 	_player->_parser = parser;
 	_player->setVolume(ConfMan.getInt("music_volume") * ConfMan.getInt("master_volume") / 255);
+	if (flags & R_MUSIC_LOOP)
+		_player->setLoop(true);
+	else
+		_player->setLoop(false);
+
 	_player->playMusic();
 	return R_SUCCESS;
 }

Index: music.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/music.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- music.h	16 May 2004 12:57:49 -0000	1.6
+++ music.h	29 May 2004 21:04:44 -0000	1.7
@@ -37,6 +37,11 @@
 	R_MUSIC_LOOP = 0x01
 };
 
+struct MUSIC_MIDITABLE {
+	const char *filename;
+	int flags;
+};
+
 class MusicPlayer : public MidiDriver {
 public:
 	MusicPlayer(MidiDriver *driver);
@@ -106,7 +111,7 @@
 
 	MusicPlayer *_player;
 
-	static const char *_midiTableITECD[26];
+	static const MUSIC_MIDITABLE _midiTableITECD[26];
 
 	int _musicInitialized;
 	int _enabled;





More information about the Scummvm-git-logs mailing list