From d4dda4df831e3772d2ed5c134bafb2ae07c3eb47 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 2 Jan 2010 13:04:36 +0000 Subject: SCI/new music code: Implemented cmdSetSoundHold. Larry now exits the limo normally in LSL5 svn-id: r46880 --- engines/sci/sfx/midiparser.h | 6 ++++++ engines/sci/sfx/music.cpp | 7 +++++++ engines/sci/sfx/music.h | 1 + engines/sci/sfx/soundcmd.cpp | 9 ++++++--- 4 files changed, 20 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/sci/sfx/midiparser.h b/engines/sci/sfx/midiparser.h index 7f4945fdcf..3491ec0ea6 100644 --- a/engines/sci/sfx/midiparser.h +++ b/engines/sci/sfx/midiparser.h @@ -63,6 +63,12 @@ public: allNotesOff(); } + void hangAllnotes(byte value) { + if (value) + hangAllActiveNotes(); + else + allNotesOff(); + } protected: void parseNextEvent(EventInfo &info); byte *midiMixChannels(); diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp index 1a98a58a02..e1ddc04668 100644 --- a/engines/sci/sfx/music.cpp +++ b/engines/sci/sfx/music.cpp @@ -433,6 +433,13 @@ void SciMusic::soundSetPriority(MusicEntry *pSnd, byte prio) { sortPlayList(); } +void SciMusic::soundSetHold(MusicEntry *pSnd, byte hold) { + Common::StackLock lock(_mutex); + + pSnd->hold = hold; + pSnd->pMidiParser->hangAllnotes(hold); +} + void SciMusic::soundKill(MusicEntry *pSnd) { pSnd->status = kSoundStopped; diff --git a/engines/sci/sfx/music.h b/engines/sci/sfx/music.h index 6087202cb0..f38987017e 100644 --- a/engines/sci/sfx/music.h +++ b/engines/sci/sfx/music.h @@ -146,6 +146,7 @@ public: void soundResume(MusicEntry *pSnd); void soundSetVolume(MusicEntry *pSnd, byte volume); void soundSetPriority(MusicEntry *pSnd, byte prio); + void soundSetHold(MusicEntry *pSnd, byte hold); uint16 soundGetMasterVolume(); void soundSetMasterVolume(uint16 vol); uint16 soundGetSoundOn() const { return _soundOn; } diff --git a/engines/sci/sfx/soundcmd.cpp b/engines/sci/sfx/soundcmd.cpp index beddedef8c..76b7e68e00 100644 --- a/engines/sci/sfx/soundcmd.cpp +++ b/engines/sci/sfx/soundcmd.cpp @@ -857,9 +857,12 @@ void SoundCommandParser::cmdSetSoundHold(reg_t obj, int16 value) { return; } - musicSlot->hold = value; - - // TODO: actually handle channel hold! + // Hold the sound before it ends for the specified amount of time. The + // engine will signal when to stop it, by setting hold to 0, in which + // case stop the sound + _music->soundSetHold(musicSlot, value); + if (!value) + cmdStopSound(obj, 0); #endif } -- cgit v1.2.3