[Scummvm-cvs-logs] SF.net SVN: scummvm:[52643] scummvm/trunk/engines/mohawk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Wed Sep 8 22:50:56 CEST 2010
Revision: 52643
http://scummvm.svn.sourceforge.net/scummvm/?rev=52643&view=rev
Author: mthreepwood
Date: 2010-09-08 20:50:56 +0000 (Wed, 08 Sep 2010)
Log Message:
-----------
MOHAWK: Implement blocking sound in Riven
Sounds that set the third argument of the playSound opcode to 1 (wherever they may be) will now block. The volume parameter of playSound is also now honored. Merge the Myst sound blocking code with this too.
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/myst_scripts.cpp
scummvm/trunk/engines/mohawk/riven_external.cpp
scummvm/trunk/engines/mohawk/riven_scripts.cpp
scummvm/trunk/engines/mohawk/sound.cpp
scummvm/trunk/engines/mohawk/sound.h
Modified: scummvm/trunk/engines/mohawk/myst_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts.cpp 2010-09-08 20:11:11 UTC (rev 52642)
+++ scummvm/trunk/engines/mohawk/myst_scripts.cpp 2010-09-08 20:50:56 UTC (rev 52643)
@@ -709,10 +709,7 @@
debugC(kDebugScript, "Opcode %d: playSoundBlocking", op);
debugC(kDebugScript, "\tsoundId: %d", soundId);
- Audio::SoundHandle *handle = _vm->_sound->playSound(soundId);
-
- while (_vm->_mixer->isSoundHandleActive(*handle))
- _vm->_system->delayMillis(10);
+ _vm->_sound->playSoundBlocking(soundId);
} else
unknown(op, var, argc, argv);
}
Modified: scummvm/trunk/engines/mohawk/riven_external.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_external.cpp 2010-09-08 20:11:11 UTC (rev 52642)
+++ scummvm/trunk/engines/mohawk/riven_external.cpp 2010-09-08 20:50:56 UTC (rev 52643)
@@ -1853,7 +1853,8 @@
} else {
// ...the telescope can't move down anymore.
// Play the sound of not being able to move
- _vm->_sound->playSound(13);
+ _vm->_gfx->changeCursor(kRivenHideCursor);
+ _vm->_sound->playSoundBlocking(13);
}
} else {
// We're not at the bottom, and we can move down again
@@ -1879,7 +1880,8 @@
// Check if we can't move up anymore
if (*telescopePos == 5) {
// Play the sound of not being able to move
- _vm->_sound->playSound(13);
+ _vm->_gfx->changeCursor(kRivenHideCursor);
+ _vm->_sound->playSoundBlocking(13);
return;
}
Modified: scummvm/trunk/engines/mohawk/riven_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_scripts.cpp 2010-09-08 20:11:11 UTC (rev 52642)
+++ scummvm/trunk/engines/mohawk/riven_scripts.cpp 2010-09-08 20:50:56 UTC (rev 52643)
@@ -346,9 +346,14 @@
_vm->_activatedSLST = true;
}
-// Command 4: play local tWAV resource (twav_id, volume, u1)
+// Command 4: play local tWAV resource (twav_id, volume, block)
void RivenScript::playSound(uint16 op, uint16 argc, uint16 *argv) {
- _vm->_sound->playSound(argv[0]);
+ byte volume = Sound::convertRivenVolume(argv[1]);
+
+ if (argv[2] == 1)
+ _vm->_sound->playSoundBlocking(argv[0], volume);
+ else
+ _vm->_sound->playSound(argv[0], volume);
}
// Command 7: set variable value (variable, value)
@@ -572,7 +577,8 @@
for (uint16 i = 0; i < recordCount; i++) {
uint16 index = flst->readUint16BE();
uint16 sfxeID = flst->readUint16BE();
- if(flst->readUint16BE() != 0)
+
+ if (flst->readUint16BE() != 0)
warning("FLST u0 non-zero");
if (index == argv[0]) {
Modified: scummvm/trunk/engines/mohawk/sound.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/sound.cpp 2010-09-08 20:11:11 UTC (rev 52642)
+++ scummvm/trunk/engines/mohawk/sound.cpp 2010-09-08 20:50:56 UTC (rev 52643)
@@ -124,6 +124,13 @@
return NULL;
}
+void Sound::playSoundBlocking(uint16 id, byte volume) {
+ Audio::SoundHandle *handle = playSound(id, volume);
+
+ while (_vm->_mixer->isSoundHandleActive(*handle))
+ _vm->_system->delayMillis(10);
+}
+
void Sound::playMidi(uint16 id) {
uint32 idTag;
if (!(_vm->getFeatures() & GF_HASMIDI)) {
@@ -165,6 +172,10 @@
_midiDriver->setTimerCallback(_midiParser, MidiParser::timerCallback);
}
+byte Sound::convertRivenVolume(uint16 volume) {
+ return (volume == 256) ? 255 : volume;
+}
+
void Sound::playSLST(uint16 index, uint16 card) {
Common::SeekableReadStream *slstStream = _vm->getRawData(ID_SLST, card);
SLSTRecord slstRecord;
@@ -287,13 +298,9 @@
if (loop)
audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream *)audStream, 0);
- // The max mixer volume is 255 and the max Riven volume is 256. Just change it to 255.
- if (volume == 256)
- volume = 255;
-
// TODO: Handle fading, possibly just raise the volume of the channel in increments?
- _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, sndHandle.handle, audStream, -1, volume, convertBalance(balance));
+ _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, sndHandle.handle, audStream, -1, convertRivenVolume(volume), convertBalance(balance));
}
void Sound::stopSLSTSound(uint16 index, bool fade) {
Modified: scummvm/trunk/engines/mohawk/sound.h
===================================================================
--- scummvm/trunk/engines/mohawk/sound.h 2010-09-08 20:11:11 UTC (rev 52642)
+++ scummvm/trunk/engines/mohawk/sound.h 2010-09-08 20:50:56 UTC (rev 52643)
@@ -115,19 +115,23 @@
class Sound {
public:
- Sound(MohawkEngine*);
+ Sound(MohawkEngine *vm);
~Sound();
Audio::SoundHandle *playSound(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false);
+ void playSoundBlocking(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume);
void playMidi(uint16 id);
void stopSound();
void pauseSound();
void resumeSound();
+
+ // Riven-specific
void playSLST(uint16 index, uint16 card);
void playSLST(SLSTRecord slstRecord);
void pauseSLST();
void resumeSLST();
void stopAllSLST();
+ static byte convertRivenVolume(uint16 volume);
private:
MohawkEngine *_vm;
@@ -141,7 +145,7 @@
Common::Array<SndHandle> _handles;
SndHandle *getHandle();
- // Riven specific
+ // Riven-specific
void playSLSTSound(uint16 index, bool fade, bool loop, uint16 volume, int16 balance);
void stopSLSTSound(uint16 id, bool fade);
Common::Array<SLSTSndHandle> _currentSLSTSounds;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list