aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorEugene Sandulenko2004-05-29 21:04:44 +0000
committerEugene Sandulenko2004-05-29 21:04:44 +0000
commit4ceb84c6430c2fa016259dc0717cce8f5e4b2bc9 (patch)
tree1dfd2c48c60349a8f1fd3a5aaea0fc275af017f7 /saga
parentb3feb1107e746aae5f9d5e9b6636d5ac92283787 (diff)
downloadscummvm-rg350-4ceb84c6430c2fa016259dc0717cce8f5e4b2bc9.tar.gz
scummvm-rg350-4ceb84c6430c2fa016259dc0717cce8f5e4b2bc9.tar.bz2
scummvm-rg350-4ceb84c6430c2fa016259dc0717cce8f5e4b2bc9.zip
Extend midi music table.
Implement music looping. svn-id: r13899
Diffstat (limited to 'saga')
-rw-r--r--saga/music.cpp71
-rw-r--r--saga/music.h7
2 files changed, 45 insertions, 33 deletions
diff --git a/saga/music.cpp b/saga/music.cpp
index 713ff0eaec..bb45607ffb 100644
--- a/saga/music.cpp
+++ b/saga/music.cpp
@@ -158,38 +158,37 @@ Music::~Music() {
}
// 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.
-
-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
+// reset.mid seems to be unused.
+
+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 @@ int Music::play(uint32 music_rn, uint16 flags) {
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 @@ int Music::play(uint32 music_rn, uint16 flags) {
_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 @@ int Music::play(uint32 music_rn, uint16 flags) {
_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;
}
diff --git a/saga/music.h b/saga/music.h
index cf2018bb81..612cd264d8 100644
--- a/saga/music.h
+++ b/saga/music.h
@@ -37,6 +37,11 @@ enum MUSIC_FLAGS {
R_MUSIC_LOOP = 0x01
};
+struct MUSIC_MIDITABLE {
+ const char *filename;
+ int flags;
+};
+
class MusicPlayer : public MidiDriver {
public:
MusicPlayer(MidiDriver *driver);
@@ -106,7 +111,7 @@ private:
MusicPlayer *_player;
- static const char *_midiTableITECD[26];
+ static const MUSIC_MIDITABLE _midiTableITECD[26];
int _musicInitialized;
int _enabled;