aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2010-09-07 20:18:30 +0000
committerMatthew Hoops2010-09-07 20:18:30 +0000
commit58139baf3710160c8382db14df26291d176e70cd (patch)
tree88b9e8ef453e7fcda32d94e9268ea5c26c0df131
parent4c107cc97a0d393508d570d7374a3304f564defe (diff)
downloadscummvm-rg350-58139baf3710160c8382db14df26291d176e70cd.tar.gz
scummvm-rg350-58139baf3710160c8382db14df26291d176e70cd.tar.bz2
scummvm-rg350-58139baf3710160c8382db14df26291d176e70cd.zip
MOHAWK: Sound cleanup
Merge the Riven sound file code with the main Riven resource code and remove the mainSoundFile parameter from Sound::playSound(). Reasoning: The sound id's do not collide with the sound id's in the main data files. The sound archives only exist because the original CD version had the ability to choose between low and high quality audio. svn-id: r52631
-rw-r--r--engines/mohawk/console.cpp17
-rw-r--r--engines/mohawk/myst.cpp2
-rw-r--r--engines/mohawk/myst_scripts.cpp2
-rw-r--r--engines/mohawk/riven.cpp5
-rw-r--r--engines/mohawk/riven_external.cpp48
-rw-r--r--engines/mohawk/riven_scripts.cpp2
-rw-r--r--engines/mohawk/sound.cpp37
-rw-r--r--engines/mohawk/sound.h5
8 files changed, 35 insertions, 83 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 0116167df1..3eed08e3c1 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -367,19 +367,13 @@ bool RivenConsole::Cmd_Var(int argc, const char **argv) {
bool RivenConsole::Cmd_PlaySound(int argc, const char **argv) {
if (argc < 2) {
- DebugPrintf("Usage: playSound <value> (<use main sound file, default = true>)\n");
- DebugPrintf("The main sound file is default, but you can use the word \'false\' to make it use the current stack file.\n");
-
+ DebugPrintf("Usage: playSound <value>\n");
return true;
}
_vm->_sound->stopSound();
_vm->_sound->stopAllSLST();
-
- bool mainSoundFile = (argc < 3) || (scumm_stricmp(argv[2], "false") != 0);
-
- _vm->_sound->playSound((uint16)atoi(argv[1]), mainSoundFile);
-
+ _vm->_sound->playSound((uint16)atoi(argv[1]));
return false;
}
@@ -393,13 +387,9 @@ bool RivenConsole::Cmd_PlaySLST(int argc, const char **argv) {
_vm->_sound->stopSound();
_vm->_sound->stopAllSLST();
- uint16 card = _vm->getCurCard();
-
- if (argc == 3)
- card = (uint16)atoi(argv[2]);
+ uint16 card = (argc == 3) ? (uint16)atoi(argv[2]) : _vm->getCurCard();
_vm->_sound->playSLST((uint16)atoi(argv[1]), card);
-
return false;
}
@@ -408,7 +398,6 @@ bool RivenConsole::Cmd_StopSound(int argc, const char **argv) {
_vm->_sound->stopSound();
_vm->_sound->stopAllSLST();
-
return true;
}
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 9ff301c129..4fb6c049d4 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -427,7 +427,7 @@ void MohawkEngine_Myst::changeToCard(uint16 card) {
// NOTE: All sounds are looped when played via the sound section of the
// VIEW resources.
- _sound->playSound(soundAction, true, soundActionVolume, true);
+ _sound->playSound(soundAction, soundActionVolume, true);
} else {
error("Unknown sound action %d", soundAction);
}
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 2f6d178da8..29e9f349c3 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -870,7 +870,7 @@ void MystScriptParser::opcode_30(uint16 op, uint16 var, uint16 argc, uint16 *arg
_vm->_sound->stopSound();
// TODO: Need to keep sound handle and add function to change volume of
// looped running sound for kMystSoundActionChangeVolume type
- _vm->_sound->playSound(soundAction, true, soundVolume);
+ _vm->_sound->playSound(soundAction, soundVolume);
} else {
debugC(kDebugScript, "Unknown");
warning("Unknown sound control value in opcode %d", op);
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index c7428a92fb..bae336b46d 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -251,7 +251,7 @@ void MohawkEngine_Riven::changeToStack(uint16 n) {
// The endings are in reverse order because of the way the 1.02 patch works.
// The only "Data3" file is j_Data3.mhk from that patch. Patch files have higher
// priorities over the regular files and are therefore loaded and checked first.
- static const char *endings[] = { "_Data3.mhk", "_Data2.mhk", "_Data1.mhk", "_Data.mhk" };
+ static const char *endings[] = { "_Data3.mhk", "_Data2.mhk", "_Data1.mhk", "_Data.mhk", "_Sounds.mhk" };
// Don't change stack to the current stack (if the files are loaded)
if (_curStack == n && !_mhk.empty())
@@ -285,9 +285,8 @@ void MohawkEngine_Riven::changeToStack(uint16 n) {
if (_mhk.empty())
error("Could not load stack %s", getStackName(_curStack).c_str());
- // Stop any currently playing sounds and load the new sound file too
+ // Stop any currently playing sounds
_sound->stopAllSLST();
- _sound->loadRivenSounds(_curStack);
}
// Riven uses some hacks to change stacks for linking books
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 302901a86c..4feb1c1ea4 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -277,7 +277,7 @@ void RivenExternal::resetDomeSliders(uint16 bitmapId, uint16 soundId, uint16 sta
// If we have at least one found slider, it has now moved
// so we should redraw and play a tick sound
if (slidersFound) {
- _vm->_sound->playSound(soundId, false);
+ _vm->_sound->playSound(soundId);
drawDomeSliders(bitmapId, startHotspot);
_vm->_system->delayMillis(10);
}
@@ -350,7 +350,7 @@ void RivenExternal::dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 reset
_sliderState |= 1 << (24 - foundSlider);
// Now play a click sound and redraw
- _vm->_sound->playSound(soundId, false);
+ _vm->_sound->playSound(soundId);
drawDomeSliders(bitmapId, startHotspot);
} else if (foundSlider > 0 && !(_sliderState & (1 << (25 - foundSlider))) && _vm->_hotspots[foundSlider + startHotspot - 1].rect.contains(event.mouse)) {
// We've moved the slider left one space
@@ -359,7 +359,7 @@ void RivenExternal::dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 reset
_sliderState |= 1 << (24 - foundSlider);
// Now play a click sound and redraw
- _vm->_sound->playSound(soundId, false);
+ _vm->_sound->playSound(soundId);
drawDomeSliders(bitmapId, startHotspot);
} else
_vm->_system->updateScreen(); // A normal update for the cursor
@@ -453,9 +453,9 @@ void RivenExternal::xaatrusbookprevpage(uint16 argc, uint16 *argv) {
// Play the page turning sound
if (_vm->getFeatures() & GF_DEMO)
- _vm->_sound->playSound(4, false);
+ _vm->_sound->playSound(4);
else
- _vm->_sound->playSound(3, false);
+ _vm->_sound->playSound(3);
// Now update the screen :)
_vm->_gfx->scheduleTransition(1);
@@ -473,9 +473,9 @@ void RivenExternal::xaatrusbooknextpage(uint16 argc, uint16 *argv) {
// Play the page turning sound
if (_vm->getFeatures() & GF_DEMO)
- _vm->_sound->playSound(5, false);
+ _vm->_sound->playSound(5);
else
- _vm->_sound->playSound(4, false);
+ _vm->_sound->playSound(4);
// Now update the screen :)
_vm->_gfx->scheduleTransition(0);
@@ -541,7 +541,7 @@ void RivenExternal::xacathbookprevpage(uint16 argc, uint16 *argv) {
(*page)--;
// Play the page turning sound
- _vm->_sound->playSound(5, false);
+ _vm->_sound->playSound(5);
// Now update the screen :)
_vm->_gfx->scheduleTransition(3);
@@ -558,7 +558,7 @@ void RivenExternal::xacathbooknextpage(uint16 argc, uint16 *argv) {
(*page)++;
// Play the page turning sound
- _vm->_sound->playSound(6, false);
+ _vm->_sound->playSound(6);
// Now update the screen :)
_vm->_gfx->scheduleTransition(2);
@@ -577,7 +577,7 @@ void RivenExternal::xatrapbookclose(uint16 argc, uint16 *argv) {
*_vm->getVar("atrap") = 0;
// Play the page turning sound
- _vm->_sound->playSound(8, false);
+ _vm->_sound->playSound(8);
_vm->refreshCard();
}
@@ -587,7 +587,7 @@ void RivenExternal::xatrapbookopen(uint16 argc, uint16 *argv) {
*_vm->getVar("atrap") = 1;
// Play the page turning sound
- _vm->_sound->playSound(9, false);
+ _vm->_sound->playSound(9);
_vm->refreshCard();
}
@@ -698,7 +698,7 @@ void RivenExternal::xblabbookprevpage(uint16 argc, uint16 *argv) {
(*page)--;
// Play the page turning sound
- _vm->_sound->playSound(22, false);
+ _vm->_sound->playSound(22);
// Now update the screen :)
_vm->_gfx->scheduleTransition(1);
@@ -715,7 +715,7 @@ void RivenExternal::xblabbooknextpage(uint16 argc, uint16 *argv) {
(*page)++;
// Play the page turning sound
- _vm->_sound->playSound(23, false);
+ _vm->_sound->playSound(23);
// Now update the screen :)
_vm->_gfx->scheduleTransition(0);
@@ -1149,7 +1149,7 @@ void RivenExternal::xcheckicons(uint16 argc, uint16 *argv) {
if (countDepressedIcons(*iconOrderVar) == 5) {
*iconOrderVar = 0;
*_vm->getVar("jicons") = 0;
- _vm->_sound->playSound(46, false);
+ _vm->_sound->playSound(46);
}
}
@@ -1569,12 +1569,12 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) {
_vm->_gfx->changeCursor(kRivenHideCursor); // Hide the cursor
_vm->_gfx->drawPLST(3); // Black out the screen
_vm->_gfx->updateScreen(); // Update the screen
- _vm->_sound->playSound(0, false); // Play the link sound
+ _vm->_sound->playSound(0); // Play the link sound
_vm->_video->activateMLST(7, _vm->getCurCard()); // Activate Gehn Link Video
_vm->_video->playMovieBlocking(1); // Play Gehn Link Video
- *_vm->getVar("agehn") = 4; // Set Gehn to the trapped state
- *_vm->getVar("atrapbook") = 1; // We've got the trap book again
- _vm->_sound->playSound(0, false); // Play the link sound again
+ *_vm->getVar("agehn") = 4; // Set Gehn to the trapped state
+ *_vm->getVar("atrapbook") = 1; // We've got the trap book again
+ _vm->_sound->playSound(0); // Play the link sound again
_vm->changeToCard(_vm->matchRMAPToCard(0x2885)); // Link out! (TODO: Shouldn't this card change?)
return;
}
@@ -1661,7 +1661,7 @@ void RivenExternal::xogehnbookprevpage(uint16 argc, uint16 *argv) {
(*page)--;
// Play the page turning sound
- _vm->_sound->playSound(12, false);
+ _vm->_sound->playSound(12);
// Now update the screen :)
_vm->_gfx->scheduleTransition(1);
@@ -1678,7 +1678,7 @@ void RivenExternal::xogehnbooknextpage(uint16 argc, uint16 *argv) {
(*page)++;
// Play the page turning sound
- _vm->_sound->playSound(13, false);
+ _vm->_sound->playSound(13);
// Now update the screen :)
_vm->_gfx->scheduleTransition(0);
@@ -1704,7 +1704,7 @@ void RivenExternal::xgwatch(uint16 argc, uint16 *argv) {
if (curSound == 5) // Break out after the last sound is done
break;
- _vm->_sound->playSound(getComboDigit(*prisonCombo, curSound) + 13, !(_vm->getFeatures() & GF_DVD));
+ _vm->_sound->playSound(getComboDigit(*prisonCombo, curSound) + 13);
curSound++;
soundTime = _vm->_system->getMillis();
}
@@ -1731,7 +1731,7 @@ void RivenExternal::xgwatch(uint16 argc, uint16 *argv) {
void RivenExternal::xpisland990_elevcombo(uint16 argc, uint16 *argv) {
// Play button sound based on argv[0]
- _vm->_sound->playSound(argv[0] + 5, false);
+ _vm->_sound->playSound(argv[0] + 5);
// It is impossible to get here if Gehn is not trapped. However,
// the original also disallows brute forcing the ending if you have
@@ -1853,7 +1853,7 @@ void RivenExternal::xtexterior300_telescopedown(uint16 argc, uint16 *argv) {
} else {
// ...the telescope can't move down anymore.
// Play the sound of not being able to move
- _vm->_sound->playSound(13, false);
+ _vm->_sound->playSound(13);
}
} else {
// We're not at the bottom, and we can move down again
@@ -1879,7 +1879,7 @@ void RivenExternal::xtexterior300_telescopeup(uint16 argc, uint16 *argv) {
// Check if we can't move up anymore
if (*telescopePos == 5) {
// Play the sound of not being able to move
- _vm->_sound->playSound(13, false);
+ _vm->_sound->playSound(13);
return;
}
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index 2b91dce35a..151df9f147 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -348,7 +348,7 @@ void RivenScript::playScriptSLST(uint16 op, uint16 argc, uint16 *argv) {
// Command 4: play local tWAV resource (twav_id, volume, u1)
void RivenScript::playSound(uint16 op, uint16 argc, uint16 *argv) {
- _vm->_sound->playSound(argv[0], false);
+ _vm->_sound->playSound(argv[0]);
}
// Command 7: set variable value (variable, value)
diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp
index 091bd68021..50a7d016f5 100644
--- a/engines/mohawk/sound.cpp
+++ b/engines/mohawk/sound.cpp
@@ -36,7 +36,6 @@
namespace Mohawk {
Sound::Sound(MohawkEngine* vm) : _vm(vm) {
- _rivenSoundFile = NULL;
_midiDriver = NULL;
_midiParser = NULL;
@@ -51,7 +50,6 @@ Sound::Sound(MohawkEngine* vm) : _vm(vm) {
Sound::~Sound() {
stopSound();
stopAllSLST();
- delete _rivenSoundFile;
if (_midiDriver) {
_midiDriver->close();
@@ -64,15 +62,6 @@ Sound::~Sound() {
}
}
-void Sound::loadRivenSounds(uint16 stack) {
- static const char prefixes[] = { 'a', 'b', 'g', 'j', 'o', 'p', 'r', 't' };
-
- if (!_rivenSoundFile)
- _rivenSoundFile = new MohawkArchive();
-
- _rivenSoundFile->open(Common::String(prefixes[stack]) + "_Sounds.mhk");
-}
-
void Sound::initMidi() {
if (!(_vm->getFeatures() & GF_HASMIDI))
return;
@@ -87,7 +76,7 @@ void Sound::initMidi() {
_midiParser->setTimerRate(_midiDriver->getBaseTempo());
}
-Audio::SoundHandle *Sound::playSound(uint16 id, bool mainSoundFile, byte volume, bool loop) {
+Audio::SoundHandle *Sound::playSound(uint16 id, byte volume, bool loop) {
debug (0, "Playing sound %d", id);
SndHandle *handle = getHandle();
@@ -113,21 +102,9 @@ Audio::SoundHandle *Sound::playSound(uint16 id, bool mainSoundFile, byte volume,
} else
audStream = makeMohawkWaveStream(_vm->getRawData(ID_MSND, id));
break;
- case GType_RIVEN:
- if (mainSoundFile)
- audStream = makeMohawkWaveStream(_rivenSoundFile->getRawData(ID_TWAV, id));
- else
- audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id));
- break;
case GType_ZOOMBINI:
audStream = makeMohawkWaveStream(_vm->getRawData(ID_SND, id));
break;
- case GType_CSAMTRAK:
- if (mainSoundFile)
- audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id));
- else
- audStream = getCSAmtrakMusic(id);
- break;
case GType_LIVINGBOOKSV1:
audStream = makeOldMohawkWaveStream(_vm->getRawData(ID_WAV, id));
break;
@@ -304,7 +281,7 @@ void Sound::playSLSTSound(uint16 id, bool fade, bool loop, uint16 volume, int16
sndHandle.id = id;
_currentSLSTSounds.push_back(sndHandle);
- Audio::AudioStream *audStream = makeMohawkWaveStream(_rivenSoundFile->getRawData(ID_TWAV, id));
+ Audio::AudioStream *audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id));
// Loop here if necessary
if (loop)
@@ -336,16 +313,6 @@ void Sound::resumeSLST() {
_vm->_mixer->pauseHandle(*_currentSLSTSounds[i].handle, false);
}
-Audio::AudioStream *Sound::getCSAmtrakMusic(uint16 id) {
- char filename[18];
- sprintf(filename, "MUSIC/MUSIC%02d.MHK", id);
- MohawkArchive *file = new MohawkArchive();
- file->open(filename);
- Audio::AudioStream *audStream = makeMohawkWaveStream(file->getRawData(ID_TWAV, 2000 + id));
- delete file;
- return audStream;
-}
-
Audio::AudioStream *Sound::makeMohawkWaveStream(Common::SeekableReadStream *stream) {
uint32 tag = 0;
ADPC_Chunk adpc;
diff --git a/engines/mohawk/sound.h b/engines/mohawk/sound.h
index 0e3ecd3c51..05c713304d 100644
--- a/engines/mohawk/sound.h
+++ b/engines/mohawk/sound.h
@@ -118,8 +118,7 @@ public:
Sound(MohawkEngine*);
~Sound();
- void loadRivenSounds(uint16 stack);
- Audio::SoundHandle *playSound(uint16 id, bool mainSoundFile = true, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false);
+ Audio::SoundHandle *playSound(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false);
void playMidi(uint16 id);
void stopSound();
void pauseSound();
@@ -132,11 +131,9 @@ public:
private:
MohawkEngine *_vm;
- MohawkArchive *_rivenSoundFile;
MidiDriver *_midiDriver;
MidiParser *_midiParser;
- static Audio::AudioStream *getCSAmtrakMusic(uint16 id);
static Audio::AudioStream *makeMohawkWaveStream(Common::SeekableReadStream *stream);
static Audio::AudioStream *makeOldMohawkWaveStream(Common::SeekableReadStream *stream);
void initMidi();