From 6c16673305727022b67f9203a87cc14a014637b6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 2 Jan 2010 15:37:17 +0000 Subject: SCI/new music code: Properly implemented cmdSetSoundHold, with the help of wjp and waltervn svn-id: r46886 --- engines/sci/sfx/midiparser.cpp | 7 +++++-- engines/sci/sfx/music.cpp | 7 ------- engines/sci/sfx/music.h | 1 - engines/sci/sfx/soundcmd.cpp | 10 ++++++---- 4 files changed, 11 insertions(+), 14 deletions(-) (limited to 'engines/sci/sfx') diff --git a/engines/sci/sfx/midiparser.cpp b/engines/sci/sfx/midiparser.cpp index ce8810bbfc..c900d5b1f6 100644 --- a/engines/sci/sfx/midiparser.cpp +++ b/engines/sci/sfx/midiparser.cpp @@ -135,8 +135,11 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) { switch (info.basic.param1) { case 0x50: // set reverb break; - case 0x52: // set hold - _pSnd->hold = info.basic.param2; + case 0x52: // hold ID marker + // Check if the hold ID marker is the same as the hold ID marker set for that song by + // cmdSetSoundHold. If it is, set the loop position + if (info.basic.param2 == _pSnd->hold) + _loopTick = _position._play_tick; break; case 0x60: // update dataInc switch (_soundVersion) { diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp index e1ddc04668..1a98a58a02 100644 --- a/engines/sci/sfx/music.cpp +++ b/engines/sci/sfx/music.cpp @@ -433,13 +433,6 @@ 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 f38987017e..6087202cb0 100644 --- a/engines/sci/sfx/music.h +++ b/engines/sci/sfx/music.h @@ -146,7 +146,6 @@ 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 d308ba0602..b5c79a6f6c 100644 --- a/engines/sci/sfx/soundcmd.cpp +++ b/engines/sci/sfx/soundcmd.cpp @@ -853,10 +853,12 @@ void SoundCommandParser::cmdSetSoundHold(reg_t obj, int16 value) { return; } - // 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); + // Set the special hold marker ID where the song should be looped at. + // If the hold marker is 0, stop the song, as songs with a hold marker + // embedded don't have an end of track signal at the end, so that they + // loop instead of stopping + musicSlot->hold = value; + if (!value) cmdStopSound(obj, 0); #endif -- cgit v1.2.3