Skip to content

Commit

Permalink
SCI: revert fix music start code
Browse files Browse the repository at this point in the history
add workaround for eq2
the issue is known, but can't be properly fixed without rewriting the midiparser into a channel specific parser
previous commit caused issues in kq5/french and others
  • Loading branch information
Martin Kiewitz committed Sep 22, 2013
1 parent f1b0a77 commit 551e263
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 35 deletions.
57 changes: 42 additions & 15 deletions engines/sci/sound/midiparser_sci.cpp
Expand Up @@ -20,6 +20,9 @@
*
*/

#include "sci/sci.h"
#include "sci/engine/state.h"

#include "sci/engine/kernel.h"
#include "sci/engine/state.h"
#include "sci/sound/midiparser_sci.h"
Expand Down Expand Up @@ -103,18 +106,6 @@ bool MidiParser_SCI::loadMusic(SoundResource::Track *track, MusicEntry *psnd, in
return true;
}

bool MidiParser_SCI::jumpToOffset(uint32 offset) {
if (_activeTrack >= _numTracks)
return false;

assert(!_jumpingToTick); // This function must not be called while within MidiParser::jumpToTick()

resetTracking();
_position._playPos = _tracks[_activeTrack] + offset;
parseNextEvent(_nextEvent);
return true;
}

byte MidiParser_SCI::midiGetNextChannel(long ticker) {
byte curr = 0xFF;
long closest = ticker + 1000000, next = 0;
Expand Down Expand Up @@ -543,9 +534,45 @@ void MidiParser_SCI::processEvent(const EventInfo &info, bool fireEvents) {
case 0xC:
if (info.channel() == 0xF) {// SCI special case
if (info.basic.param1 != kSetSignalLoop) {
if (!_jumpingToTick) {
_pSnd->setSignal(info.basic.param1);
debugC(4, kDebugLevelSound, "signal %04x", info.basic.param1);
// At least in kq5/french&mac the first scene in the intro has
// a song that sets signal to 4 immediately on tick 0. Signal
// isn't set at that point by sierra sci and it would cause the
// castle daventry text to get immediately removed, so we
// currently filter it. Sierra SCI ignores them as well at that
// time. However, this filtering should only be performed for
// SCI1 and newer games. Signalling is done differently in SCI0
// though, so ignoring these signals in SCI0 games will result
// in glitches (e.g. the intro of LB1 Amiga gets stuck - bug
// #3297883). Refer to MusicEntry::setSignal() in sound/music.cpp.
// FIXME: SSCI doesn't start playing at the very beginning
// of the stream, but at a fixed location a few commands later.
// That is probably why this signal isn't triggered
// immediately there.
bool skipSignal = false;
if (_soundVersion >= SCI_VERSION_1_EARLY) {
if (!_position._playTick) {
skipSignal = true;
switch (g_sci->getGameId()) {
case GID_ECOQUEST2:
// In Eco Quest 2 room 530 - gonzales is supposed to dance
// WORKAROUND: we need to signal in this case on tick 0
// this whole issue is complicated and can only be properly fixed by
// changing the whole parser to a per-channel parser. SSCI seems to
// start each channel at offset 13 (may be 10 for us) and only
// starting at offset 0 when the music loops to the initial position.
if (g_sci->getEngineState()->currentRoomNumber() == 530)
skipSignal = false;
break;
default:
break;
}
}
}
if (!skipSignal) {
if (!_jumpingToTick) {
_pSnd->setSignal(info.basic.param1);
debugC(4, kDebugLevelSound, "signal %04x", info.basic.param1);
}
}
} else {
_loopTick = _position._playTick;
Expand Down
1 change: 0 additions & 1 deletion engines/sci/sound/midiparser_sci.h
Expand Up @@ -60,7 +60,6 @@ class MidiParser_SCI : public MidiParser {
bool loadMusic(byte *, uint32) {
return false;
}
bool jumpToOffset(uint32 offset);
void sendInitCommands();
void unloadMusic();
void setMasterVolume(byte masterVolume);
Expand Down
20 changes: 1 addition & 19 deletions engines/sci/sound/music.cpp
Expand Up @@ -518,25 +518,7 @@ void SciMusic::soundPlay(MusicEntry *pSnd) {
pSnd->hold = -1;

if (pSnd->status == kSoundStopped)
if (_soundVersion <= SCI_VERSION_0_LATE) {
// SCI0 sound subsystem seems to start at offset 0
// Not starting at offset 0 for SCI0 games will result
// in glitches (e.g. the intro of LB1 Amiga gets stuck - bug
// #3297883). Refer to MusicEntry::setSignal() in sound/music.cpp.
pSnd->pMidiParser->jumpToOffset(0);
} else {
// SCI1 sound subsystem starts at offset 10 (and also sets loop offset to 0)
// At least in kq5/french&mac the first scene in the intro has
// a song that sets signal to 4 immediately on tick 0. Signal
// isn't set at that point by sierra sci and it would cause the
// castle daventry text to get immediately removed.
// Also Eco Quest 2 Gonzales Dances music (room 530) requires a signal
// to get set exactly at tick 0. We previously didn't handle signals
// on tick 0 for SCI1. Which then resulted in broken dance animations.
// See bug #3037267
// FIXME: maybe also change looping logic to use offset instead of ticks
pSnd->pMidiParser->jumpToOffset(10);
}
pSnd->pMidiParser->jumpToTick(0);
else {
// Fast forward to the last position and perform associated events when loading
pSnd->pMidiParser->jumpToTick(pSnd->ticker, true, true, true);
Expand Down

0 comments on commit 551e263

Please sign in to comment.