aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2010-06-19 20:23:55 +0000
committerMartin Kiewitz2010-06-19 20:23:55 +0000
commitf3b8a5927d16da3a35a55069a9fe9d9e6500a2f8 (patch)
tree72328ed2030c5a770f8d471928f79c05adaadfba /engines/sci
parent089f5bba1491be81cebc495a7e5245fe045da323 (diff)
downloadscummvm-rg350-f3b8a5927d16da3a35a55069a9fe9d9e6500a2f8.tar.gz
scummvm-rg350-f3b8a5927d16da3a35a55069a9fe9d9e6500a2f8.tar.bz2
scummvm-rg350-f3b8a5927d16da3a35a55069a9fe9d9e6500a2f8.zip
SCI: fixing another uninitialized variable usage issue - also limiting reset velocity to used channels only, same is true for setting voice count
svn-id: r50062
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/sound/midiparser_sci.cpp28
-rw-r--r--engines/sci/sound/midiparser_sci.h1
-rw-r--r--engines/sci/sound/music.cpp5
3 files changed, 18 insertions, 16 deletions
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp
index 1cfaadd36d..61e9d81392 100644
--- a/engines/sci/sound/midiparser_sci.cpp
+++ b/engines/sci/sound/midiparser_sci.cpp
@@ -81,10 +81,6 @@ bool MidiParser_SCI::loadMusic(SoundResource::Track *track, MusicEntry *psnd, in
_channelRemap[9] = 9; // never map channel 9, because that's used for percussion
_channelRemap[15] = 15; // never map channel 15, because thats used by sierra internally
- // we can't do this later, because otherwise we really send to unmapped channels
- if (_pSnd)
- setVolume(_pSnd->volume);
-
if (channelFilterMask) {
// SCI0 only has 1 data stream, but we need to filter out channels depending on music hardware selection
midiFilterChannels(channelFilterMask);
@@ -98,24 +94,28 @@ bool MidiParser_SCI::loadMusic(SoundResource::Track *track, MusicEntry *psnd, in
setTrack(0);
_loopTick = 0;
+ return true;
+}
+
+void MidiParser_SCI::sendInitCommands() {
if (_pSnd) {
if (_soundVersion <= SCI_VERSION_0_LATE) {
// Set initial voice count
- for (int i = 0; i < 16; ++i) {
+ for (int i = 0; i < 15; ++i) {
byte voiceCount = 0;
- if (channelFilterMask & (1 << i))
- voiceCount = psnd->soundRes->getInitialVoiceCount(i);
- _driver->send(0xB0 | i, 0x4B, voiceCount);
+ if (_channelUsed[i]) {
+ voiceCount = _pSnd->soundRes->getInitialVoiceCount(i);
+ _driver->send(0xB0 | i, 0x4B, voiceCount);
+ }
}
}
-
- // Send a velocity off signal to all channels
- for (int i = 0; i < 16; ++i) {
- _driver->send(0xB0 | i, 0x4E, 0); // Reset velocity
- }
}
- return true;
+ // Send a velocity off signal to all channels
+ for (int i = 0; i < 15; ++i) {
+ if (_channelUsed[i])
+ sendToDriver(0xB0 | i, 0x4E, 0); // Reset velocity
+ }
}
void MidiParser_SCI::unloadMusic() {
diff --git a/engines/sci/sound/midiparser_sci.h b/engines/sci/sound/midiparser_sci.h
index 31a3b923fb..48de44555d 100644
--- a/engines/sci/sound/midiparser_sci.h
+++ b/engines/sci/sound/midiparser_sci.h
@@ -59,6 +59,7 @@ public:
bool loadMusic(byte *, uint32) {
return false;
}
+ void sendInitCommands();
void unloadMusic();
void setVolume(byte volume);
void stop() {
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 8499b6da59..8da0557a31 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -326,9 +326,10 @@ void SciMusic::soundPlay(MusicEntry *pSnd) {
if (pSnd->pMidiParser) {
pSnd->pMidiParser->tryToOwnChannels();
pSnd->pMidiParser->setVolume(pSnd->volume);
- if (pSnd->status == kSoundStopped)
+ if (pSnd->status == kSoundStopped) {
+ pSnd->pMidiParser->sendInitCommands();
pSnd->pMidiParser->jumpToTick(0);
- else
+ } else
// Fast forward to the last position and perform associated events when loading
pSnd->pMidiParser->jumpToTick(pSnd->ticker, true);
}