aboutsummaryrefslogtreecommitdiff
path: root/queen
diff options
context:
space:
mode:
authorJoost Peters2004-01-24 22:55:09 +0000
committerJoost Peters2004-01-24 22:55:09 +0000
commitd40d9b7f0d2145b231538227b08ba20d8ba890a7 (patch)
tree64d331d2594903d60173c846b4bbf863ae4c729d /queen
parent6c8111bac92db1193489642d4ddbc04b52aafa5e (diff)
downloadscummvm-rg350-d40d9b7f0d2145b231538227b08ba20d8ba890a7.tar.gz
scummvm-rg350-d40d9b7f0d2145b231538227b08ba20d8ba890a7.tar.bz2
scummvm-rg350-d40d9b7f0d2145b231538227b08ba20d8ba890a7.zip
- Added MT32 -> GM mapping, this fixes the wrong sound for the clock in the beginning as well as various tunes.
- Don't try to play invalid music (list probably is incomplete) - Work around annoying notes bug in 2 pieces of Floda music - Stop music when loading savegames svn-id: r12584
Diffstat (limited to 'queen')
-rw-r--r--queen/journal.cpp2
-rw-r--r--queen/music.cpp61
-rw-r--r--queen/music.h2
3 files changed, 59 insertions, 6 deletions
diff --git a/queen/journal.cpp b/queen/journal.cpp
index c4400e08b3..88f70f3cb8 100644
--- a/queen/journal.cpp
+++ b/queen/journal.cpp
@@ -27,6 +27,7 @@
#include "queen/graphics.h"
#include "queen/grid.h"
#include "queen/logic.h"
+#include "queen/music.h"
#include "queen/queen.h"
#include "queen/resource.h"
#include "queen/sound.h"
@@ -284,6 +285,7 @@ void Journal::handleYesNoMode(int16 zoneNum) {
if (_saveDescriptions[currentSlot][0]) {
_vm->graphics()->clearBobs();
_vm->display()->palFadeOut(0, 223, JOURNAL_ROOM);
+ _vm->music()->stopSong();
_vm->loadGameState(currentSlot);
_vm->display()->clearTexts(0, GAME_SCREEN_HEIGHT - 1);
// XXX panelflag=1;
diff --git a/queen/music.cpp b/queen/music.cpp
index 2aab07eb73..bcd4bb8b5b 100644
--- a/queen/music.cpp
+++ b/queen/music.cpp
@@ -29,10 +29,23 @@
namespace Queen {
+// Instrument mapping for MT32 tracks emulated under GM.
+static const byte mt32_to_gm[128] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 1, 0, 2, 4, 4, 5, 3, 16, 17, 18, 16, 16, 19, 20, 21, // 0x
+ 6, 6, 6, 7, 7, 7, 8, 112, 62, 62, 63, 63, 38, 38, 39, 39, // 1x
+ 88, 95, 52, 98, 97, 99, 14, 54, 102, 96, 53, 102, 81, 100, 14, 80, // 2x
+ 48, 48, 49, 45, 41, 40, 42, 42, 43, 46, 45, 24, 25, 28, 27, 104, // 3x
+ 32, 32, 34, 33, 36, 37, 35, 35, 79, 73, 72, 72, 74, 75, 64, 65, // 4x
+ 66, 67, 71, 71, 68, 69, 70, 22, 56, 59, 57, 57, 60, 60, 58, 61, // 5x
+ 61, 11, 11, 98, 14, 9, 14, 13, 12, 107, 107, 77, 78, 78, 76, 76, // 6x
+ 47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117 // 7x
+};
+
MusicPlayer::MusicPlayer(MidiDriver *driver, byte *data, uint32 size) : _driver(driver), _isPlaying(false), _looping(false), _randomLoop(false), _volume(255), _queuePos(0), _musicData(data), _musicDataSize(size) {
memset(_channel, 0, sizeof(_channel));
queueClear();
- _lastSong = 0;
+ _lastSong = _currentSong = 0;
_parser = MidiParser::createParser_SMF();
_parser->setMidiDriver(this);
_parser->setTimerRate(_driver->getBaseTempo());
@@ -100,6 +113,8 @@ namespace Queen {
_channelVolume[channel] = volume;
//volume = volume * _masterVolume / 255;
b = (b & 0xFF00FFFF) | (volume << 16);
+ } else if ((b & 0xF0) == 0xC0) {
+ b = (b & 0xFFFF00FF) | mt32_to_gm[(b >> 8) & 0xFF] << 8;
}
else if ((b & 0xFFF0) == 0x007BB0) {
//Only respond to All Notes Off if this channel
@@ -108,6 +123,11 @@ namespace Queen {
return;
}
+ //Work around annoying loud notes in certain Roland Floda tunes
+ if (channel == 4 && _currentSong == 27)
+ return;
+ if (channel == 5 && _currentSong == 38)
+ return;
if (!_channel[channel])
_channel[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
@@ -164,7 +184,7 @@ namespace Queen {
default:
setLoop(false);
break;
- }
+ }
int i = 0;
while(Sound::_tune[tuneList].tuneNum[i])
@@ -179,6 +199,13 @@ namespace Queen {
debug(5, "MusicPlayer::playMusic - Music queue is empty!");
return;
}
+
+ //Don't play if there's only 1 song in the queue and it's a bad one
+ if (!_songQueue[1] && isBadSong(_songQueue[_queuePos]))
+ return;
+
+ while(isBadSong(_songQueue[_queuePos]))
+ queueUpdatePos();
uint16 songNum = _songQueue[_queuePos];
@@ -196,7 +223,8 @@ namespace Queen {
songNum = _songQueue[_queuePos];
}
}
-
+
+ _currentSong = songNum = isBadSong(songNum) ? 0 : songNum;
_parser->loadMusic(_musicData + songOffset(songNum), songLength(songNum));
_parser->setTrack(0);
//debug(0, "Playing song %d [queue position: %d]", songNum, _queuePos);
@@ -211,7 +239,8 @@ namespace Queen {
if (_queuePos < (MUSIC_QUEUE_SIZE - 1) && _songQueue[_queuePos + 1])
_queuePos++;
else
- _queuePos = 0;
+ if (_looping)
+ _queuePos = 0;
}
}
@@ -220,8 +249,28 @@ namespace Queen {
for (int i = 0; i < MUSIC_QUEUE_SIZE; i++)
if (_songQueue[i])
queueSize++;
-
- return (uint8) _rnd.getRandomNumber(queueSize) & 0xFF;
+
+ if (!queueSize)
+ return 0;
+
+ return (uint8) _rnd.getRandomNumber(queueSize - 1) & 0xFF;
+ }
+
+ bool MusicPlayer::isBadSong(uint16 songNum) {
+ //Songs which are (apparently?) bogus
+ //Atleast they don't contain a valid MThd/MTrk
+ switch(songNum) {
+ case 50:
+ case 51:
+ case 53:
+ case 80:
+ case 176:
+ return true;
+ break;
+ default:
+ return false;
+ break;
+ }
}
void MusicPlayer::stopMusic() {
diff --git a/queen/music.h b/queen/music.h
index f36dffb3b7..dd8a63ca91 100644
--- a/queen/music.h
+++ b/queen/music.h
@@ -66,6 +66,7 @@ protected:
void queueUpdatePos();
uint8 randomQueuePos();
static void onTimer(void *data);
+ bool isBadSong(uint16 songNum);
uint32 songOffset(uint16 songNum);
uint32 songLength(uint16 songNum);
@@ -81,6 +82,7 @@ protected:
bool _randomLoop;
byte _volume;
uint8 _queuePos;
+ int16 _currentSong;
int16 _lastSong; //first song from previous queue
int16 _songQueue[MUSIC_QUEUE_SIZE];