aboutsummaryrefslogtreecommitdiff
path: root/queen
diff options
context:
space:
mode:
Diffstat (limited to 'queen')
-rw-r--r--queen/music.cpp20
-rw-r--r--queen/music.h6
-rw-r--r--queen/sound.cpp15
3 files changed, 30 insertions, 11 deletions
diff --git a/queen/music.cpp b/queen/music.cpp
index 82a108cb24..d4f839ea3d 100644
--- a/queen/music.cpp
+++ b/queen/music.cpp
@@ -30,6 +30,7 @@ namespace Queen {
MusicPlayer::MusicPlayer(MidiDriver *driver, byte *data, uint32 size) : _driver(driver), _isPlaying(false), _looping(false), _volume(255), _queuePos(0), _musicData(data), _musicDataSize(size) {
queueClear();
+ _lastSong = 0;
_parser = MidiParser::createParser_SMF();
_parser->setMidiDriver(this);
_parser->setTimerRate(_driver->getBaseTempo());
@@ -59,6 +60,7 @@ namespace Queen {
}
void MusicPlayer::queueClear() {
+ _lastSong = _songQueue[0];
_queuePos = 0;
memset(_songQueue, 0, sizeof(_songQueue));
}
@@ -130,6 +132,15 @@ namespace Queen {
}
uint16 songNum = _songQueue[_queuePos];
+
+ //Special type
+ //2000: (songNum + 1) - repeat music from previous queue
+ if (songNum == 1999) {
+ songNum = _lastSong;
+ queueClear();
+ queueSong(songNum);
+ }
+
_parser->loadMusic(_musicData + songOffset(songNum), songLength(songNum));
_parser->setTrack(0);
//debug(0, "Playing song %d [queue position: %d]", songNum, _queuePos);
@@ -178,6 +189,15 @@ namespace Queen {
delete[] _musicData;
}
+ bool Music::queueSong(uint16 songNum) {
+ // Work around bug in Roland music, note that these numbers are 'one-off'
+ // from the original code
+ if (/*isRoland && */ songNum == 88 || songNum == 89)
+ songNum = 62;
+
+ return _player->queueSong(songNum);
+ }
+
void Music::playSong(uint16 songNum) {
_player->queueClear();
_player->queueSong(songNum);
diff --git a/queen/music.h b/queen/music.h
index b8d3851ce9..9c94c2941c 100644
--- a/queen/music.h
+++ b/queen/music.h
@@ -76,6 +76,7 @@ protected:
bool _looping;
byte _volume;
uint8 _queuePos;
+ int16 _lastSong; //first song from previous queue
int16 _songQueue[MUSIC_QUEUE_SIZE];
uint16 _numSongs;
@@ -88,8 +89,11 @@ public:
Music(MidiDriver *_driver, QueenEngine *vm);
~Music();
void playSong(uint16 songNum);
+ void queueClear() { return _player->queueClear(); }
+ bool queueSong(uint16 songNum);
+ void playMusic() { return _player->playMusic(); }
void stopSong();
- void loop(bool val) { return _player->setLoop(val); }
+ void loop(bool val) { return _player->setLoop(val); }
protected:
byte *_musicData;
diff --git a/queen/sound.cpp b/queen/sound.cpp
index 19f7711f82..d9b3f92bdd 100644
--- a/queen/sound.cpp
+++ b/queen/sound.cpp
@@ -138,16 +138,11 @@ void Sound::playSong(int16 songNum) {
break;
}
- int16 song = _tune[newTune].tuneNum[0] - 1;
-
- // Work around bug in Roland music, note that these numbers are 'one-off' from
- // the original code.
- if (/*isRoland && */ song == 88 || song == 89) {
- warning("Working around Roland music bug");
- song = 62;
- }
-
- _vm->music()->playSong(song);
+ _vm->music()->queueClear();
+ int i = 0;
+ while(_tune[newTune].tuneNum[i])
+ _vm->music()->queueSong(_tune[newTune].tuneNum[i++] - 1);
+ _vm->music()->playMusic();
}
void Sound::saveState(byte *&ptr) {