aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorColin Snover2017-06-16 16:32:16 -0500
committerColin Snover2017-06-18 21:42:58 -0500
commitd556dcc57bf50a03d81ab7a1ef59a9e5758465bf (patch)
tree977a4935fdff18a022860871475a40af25c01e95 /engines/sci
parent733eaeb499bb39f75e7dd218df4c71b06b7e1610 (diff)
downloadscummvm-rg350-d556dcc57bf50a03d81ab7a1ef59a9e5758465bf.tar.gz
scummvm-rg350-d556dcc57bf50a03d81ab7a1ef59a9e5758465bf.tar.bz2
scummvm-rg350-d556dcc57bf50a03d81ab7a1ef59a9e5758465bf.zip
SCI: Switch SCI2 games to use Audio32
Upon investigation of Sound code across SCI32 games, it was determined that there are actually (at least) 3 different revisions, not just a single SCI2.1 version. This patch only changes the parts of Sound code that are relevant to the correct use of Audio32. Fixes Trac#9736, Trac#9756, Trac#9767, Trac#9791.
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/features.cpp9
-rw-r--r--engines/sci/engine/features.h5
-rw-r--r--engines/sci/engine/kernel_tables.h57
-rw-r--r--engines/sci/engine/savegame.cpp9
-rw-r--r--engines/sci/resource_audio.cpp17
-rw-r--r--engines/sci/sci.cpp2
-rw-r--r--engines/sci/sound/audio32.cpp21
-rw-r--r--engines/sci/sound/midiparser_sci.cpp47
-rw-r--r--engines/sci/sound/music.cpp12
-rw-r--r--engines/sci/sound/soundcmd.cpp37
10 files changed, 95 insertions, 121 deletions
diff --git a/engines/sci/engine/features.cpp b/engines/sci/engine/features.cpp
index 9251ac69e1..76f3c358d4 100644
--- a/engines/sci/engine/features.cpp
+++ b/engines/sci/engine/features.cpp
@@ -143,8 +143,17 @@ SciVersion GameFeatures::detectDoSoundType() {
// SCI0LATE. Although the last SCI0EARLY game (lsl2) uses SCI0LATE resources
_doSoundType = g_sci->getResMan()->detectEarlySound() ? SCI_VERSION_0_EARLY : SCI_VERSION_0_LATE;
#ifdef ENABLE_SCI32
+ } else if (getSciVersion() >= SCI_VERSION_2_1_MIDDLE &&
+ g_sci->getGameId() != GID_SQ6 &&
+ // Assuming MGDX uses SCI2.1early sound mode since SQ6 does
+ // and it was released earlier, but not verified (Phar Lap
+ // Windows-only release)
+ g_sci->getGameId() != GID_MOTHERGOOSEHIRES) {
+ _doSoundType = SCI_VERSION_2_1_MIDDLE;
} else if (getSciVersion() >= SCI_VERSION_2_1_EARLY) {
_doSoundType = SCI_VERSION_2_1_EARLY;
+ } else if (getSciVersion() >= SCI_VERSION_2) {
+ _doSoundType = SCI_VERSION_2;
#endif
} else if (SELECTOR(nodePtr) == -1) {
// No nodePtr selector, so this game is definitely using newer
diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h
index 08611981cf..4a5b9ebb22 100644
--- a/engines/sci/engine/features.h
+++ b/engines/sci/engine/features.h
@@ -102,11 +102,8 @@ public:
case GID_SQ6:
return true;
case GID_KQ7:
- case GID_QFG4:
- // (1) KQ7 1.51 (SCI2.1early) uses the non-standard attenuation, but
+ // KQ7 1.51 (SCI2.1early) uses the non-standard attenuation, but
// 2.00b (SCI2.1mid) does not
- // (2) QFG4 CD is SCI2.1early; QFG4 floppy is SCI2 and does not use
- // the SCI2.1 audio system
return getSciVersion() == SCI_VERSION_2_1_EARLY;
default:
return false;
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index a0e7ccfef6..e077668df8 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -81,7 +81,6 @@ struct SciKernelMapSubEntry {
#define SIG_SOUNDSCI0 SCI_VERSION_0_EARLY, SCI_VERSION_0_LATE
#define SIG_SOUNDSCI1EARLY SCI_VERSION_1_EARLY, SCI_VERSION_1_EARLY
#define SIG_SOUNDSCI1LATE SCI_VERSION_1_LATE, SCI_VERSION_1_LATE
-#define SIG_SOUNDSCI21 SCI_VERSION_2_1_EARLY, SCI_VERSION_3
#define SIGFOR_ALL 0x3f
#define SIGFOR_DOS 1 << 0
@@ -152,32 +151,27 @@ static const SciKernelMapSubEntry kDoSound_subops[] = {
{ SIG_SOUNDSCI1LATE, 19, MAP_CALL(DoSoundGlobalReverb), NULL, NULL },
{ SIG_SOUNDSCI1LATE, 20, MAP_CALL(DoSoundUpdate), NULL, NULL },
#ifdef ENABLE_SCI32
- { SIG_SOUNDSCI21, 0, MAP_CALL(DoSoundMasterVolume), "(i)", NULL },
- { SIG_SOUNDSCI21, 1, MAP_CALL(DoSoundMute), "(i)", NULL },
- { SIG_SOUNDSCI21, 2, MAP_EMPTY(DoSoundRestore), NULL, NULL },
- { SIG_SOUNDSCI21, 3, MAP_CALL(DoSoundGetPolyphony), "", NULL },
- { SIG_SOUNDSCI21, 4, MAP_CALL(DoSoundGetAudioCapability), "", NULL },
- { SIG_SOUNDSCI21, 5, MAP_CALL(DoSoundSuspend), "i", NULL },
- { SIG_SOUNDSCI21, 6, MAP_CALL(DoSoundInit), "o", NULL },
- { SIG_SOUNDSCI21, 7, MAP_CALL(DoSoundDispose), "o", NULL },
- { SIG_SOUNDSCI21, 8, MAP_CALL(DoSoundPlay), "o", kDoSoundPlay_workarounds },
- // ^^ TODO: if this is really the only change between SCI1LATE AND SCI21, we could rename the
- // SIG_SOUNDSCI1LATE #define to SIG_SINCE_SOUNDSCI1LATE and make it being SCI1LATE+. Although
- // I guess there are many more changes somewhere
- // TODO: Quest for Glory 4 (SCI2.1) uses the old scheme, we need to detect it accordingly
- // signature for SCI21 should be "o"
- { SIG_SOUNDSCI21, 9, MAP_CALL(DoSoundStop), "o", NULL },
- { SIG_SOUNDSCI21, 10, MAP_CALL(DoSoundPause), "[o0]i", NULL },
- { SIG_SOUNDSCI21, 11, MAP_CALL(DoSoundFade), "oiiii", kDoSoundFade_workarounds },
- { SIG_SOUNDSCI21, 12, MAP_CALL(DoSoundSetHold), "oi", NULL },
- { SIG_SOUNDSCI21, 13, MAP_EMPTY(DoSoundDummy), NULL, NULL },
- { SIG_SOUNDSCI21, 14, MAP_CALL(DoSoundSetVolume), "oi", NULL },
- { SIG_SOUNDSCI21, 15, MAP_CALL(DoSoundSetPriority), "oi", NULL },
- { SIG_SOUNDSCI21, 16, MAP_CALL(DoSoundSetLoop), "oi", NULL },
- { SIG_SOUNDSCI21, 17, MAP_CALL(DoSoundUpdateCues), "o", NULL },
- { SIG_SOUNDSCI21, 18, MAP_CALL(DoSoundSendMidi), "oiiii", NULL },
- { SIG_SOUNDSCI21, 19, MAP_CALL(DoSoundGlobalReverb), "(i)", NULL },
- { SIG_SOUNDSCI21, 20, MAP_CALL(DoSoundUpdate), "o", NULL },
+ { SIG_SCI32, 0, MAP_CALL(DoSoundMasterVolume), "(i)", NULL },
+ { SIG_SCI32, 1, MAP_CALL(DoSoundMute), "(i)", NULL },
+ { SIG_SCI32, 2, MAP_EMPTY(DoSoundRestore), NULL, NULL },
+ { SIG_SCI32, 3, MAP_CALL(DoSoundGetPolyphony), "", NULL },
+ { SIG_SCI32, 4, MAP_CALL(DoSoundGetAudioCapability), "", NULL },
+ { SIG_SCI32, 5, MAP_CALL(DoSoundSuspend), "i", NULL },
+ { SIG_SCI32, 6, MAP_CALL(DoSoundInit), "o", NULL },
+ { SIG_SCI32, 7, MAP_CALL(DoSoundDispose), "o", NULL },
+ { SIG_SCI32, 8, MAP_CALL(DoSoundPlay), "o", kDoSoundPlay_workarounds },
+ { SIG_SCI32, 9, MAP_CALL(DoSoundStop), "o", NULL },
+ { SIG_SCI32, 10, MAP_CALL(DoSoundPause), "[o0]i", NULL },
+ { SIG_SCI32, 11, MAP_CALL(DoSoundFade), "oiiii", kDoSoundFade_workarounds },
+ { SIG_SCI32, 12, MAP_CALL(DoSoundSetHold), "oi", NULL },
+ { SIG_SCI32, 13, MAP_EMPTY(DoSoundDummy), NULL, NULL },
+ { SIG_SCI32, 14, MAP_CALL(DoSoundSetVolume), "oi", NULL },
+ { SIG_SCI32, 15, MAP_CALL(DoSoundSetPriority), "oi", NULL },
+ { SIG_SCI32, 16, MAP_CALL(DoSoundSetLoop), "oi", NULL },
+ { SIG_SCI32, 17, MAP_CALL(DoSoundUpdateCues), "o", NULL },
+ { SIG_SCI32, 18, MAP_CALL(DoSoundSendMidi), "oiiii", NULL },
+ { SIG_SCI32, 19, MAP_CALL(DoSoundGlobalReverb), "(i)", NULL },
+ { SIG_SCI32, 20, MAP_CALL(DoSoundUpdate), "o", NULL },
#endif
SCI_SUBOPENTRY_TERMINATOR
};
@@ -233,8 +227,9 @@ static const SciKernelMapSubEntry kDoAudio_subops[] = {
{ SIG_SCI32, 10, MAP_CALL(DoAudioBitDepth), "(i)", NULL },
{ SIG_SCI32, 11, MAP_DUMMY(DoAudioDistort), "(i)", NULL },
{ SIG_SCI32, 12, MAP_CALL(DoAudioMixing), "(i)", NULL },
- { SIG_SCI32, 13, MAP_CALL(DoAudioChannels), "(i)", NULL },
- { SIG_SCI32, 14, MAP_CALL(DoAudioPreload), "(i)", NULL },
+ { SIG_SCI2, 13, MAP_EMPTY(DoAudioSetBufferSize), "i", NULL },
+ { SIG_SINCE_SCI21, 13, MAP_CALL(DoAudioChannels), "(i)", NULL },
+ { SIG_SINCE_SCI21, 14, MAP_CALL(DoAudioPreload), "(i)", NULL },
{ SIG_SINCE_SCI21MID, 15, MAP_CALL(DoAudioFade), "(iiii)(i)(i)", NULL },
{ SIG_SINCE_SCI21MID, 16, MAP_DUMMY(DoAudioFade36), "iiiii(iii)(i)", NULL },
{ SIG_SINCE_SCI21MID, 17, MAP_CALL(DoAudioHasSignal), "", NULL },
@@ -670,9 +665,9 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(DisposeList), SIG_EVERYWHERE, "l", NULL, NULL },
{ MAP_CALL(DisposeScript), SIG_EVERYWHERE, "i(i*)", NULL, kDisposeScript_workarounds },
{ MAP_CALL(DisposeWindow), SIG_EVERYWHERE, "i(i)", NULL, NULL },
- { MAP_CALL(DoAudio), SCI_VERSION_NONE, SCI_VERSION_2, SIGFOR_ALL, "i(.*)", NULL, NULL }, // subop
+ { MAP_CALL(DoAudio), SIG_SCI16, SIGFOR_ALL, "i(.*)", NULL, NULL }, // subop
#ifdef ENABLE_SCI32
- { "DoAudio", kDoAudio32, SIG_SINCE_SCI21, SIGFOR_ALL, "(.*)", kDoAudio_subops, NULL },
+ { "DoAudio", kDoAudio32, SIG_SCI32, SIGFOR_ALL, "(.*)", kDoAudio_subops, NULL },
#endif
{ MAP_CALL(DoAvoider), SIG_EVERYWHERE, "o(i)", NULL, NULL },
{ MAP_CALL(DoBresen), SIG_EVERYWHERE, "o", NULL, NULL },
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index e0f9ec34db..995d7319c9 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -435,10 +435,7 @@ void EngineState::saveLoadWithSerializer(Common::Serializer &s) {
g_sci->_gfxPalette32->saveLoadWithSerializer(s);
g_sci->_gfxRemap32->saveLoadWithSerializer(s);
g_sci->_gfxCursor32->saveLoadWithSerializer(s);
- // TODO: SCI2 should be using Audio32 too, but is not yet.
- if (g_sci->_audio32) {
- g_sci->_audio32->saveLoadWithSerializer(s);
- }
+ g_sci->_audio32->saveLoadWithSerializer(s);
g_sci->_video32->saveLoadWithSerializer(s);
} else
#endif
@@ -714,10 +711,10 @@ void SoundCommandParser::reconstructPlayList() {
initSoundResource(entry);
#ifdef ENABLE_SCI32
- if (_soundVersion >= SCI_VERSION_2_1_EARLY && entry->isSample) {
+ if (_soundVersion >= SCI_VERSION_2 && entry->isSample) {
const reg_t &soundObj = entry->soundObj;
- if ((int)readSelectorValue(_segMan, soundObj, SELECTOR(loop)) != -1 &&
+ if (readSelectorValue(_segMan, soundObj, SELECTOR(loop)) == 0xFFFF &&
readSelector(_segMan, soundObj, SELECTOR(handle)) != NULL_REG) {
writeSelector(_segMan, soundObj, SELECTOR(handle), NULL_REG);
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 7766ed6a39..92761cae39 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -651,9 +651,7 @@ SoundResource::SoundResource(uint32 resourceNr, ResourceManager *resMan, SciVers
Channel *channel, *sampleChannel;
- switch (_soundVersion) {
- case SCI_VERSION_0_EARLY:
- case SCI_VERSION_0_LATE:
+ if (_soundVersion <= SCI_VERSION_0_LATE) {
// SCI0 only has a header of 0x11/0x21 byte length and the actual midi track follows afterwards
_trackCount = 1;
_tracks = new Track[_trackCount];
@@ -693,11 +691,7 @@ SoundResource::SoundResource(uint32 resourceNr, ResourceManager *resMan, SciVers
_tracks->digitalSampleEnd = 0;
sampleChannel->data += 44; // Skip over header
}
- break;
-
- case SCI_VERSION_1_EARLY:
- case SCI_VERSION_1_LATE:
- case SCI_VERSION_2_1_EARLY: {
+ } else if (_soundVersion >= SCI_VERSION_1_EARLY && _soundVersion <= SCI_VERSION_2_1_MIDDLE) {
SciSpan<const byte> data = *resource;
// Count # of tracks
_trackCount = 0;
@@ -799,11 +793,8 @@ SoundResource::SoundResource(uint32 resourceNr, ResourceManager *resMan, SciVers
}
++data; // Skipping 0xFF that closes channels list
}
- break;
- }
-
- default:
- error("SoundResource: SCI version %d is unsupported", _soundVersion);
+ } else {
+ error("SoundResource: SCI version %s is unsupported", getSciVersionDesc(_soundVersion));
}
}
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index f200bf64a4..a84f50ea2b 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -315,7 +315,7 @@ Common::Error SciEngine::run() {
_guestAdditions = new GuestAdditions(_gamestate, _features, _kernel);
_eventMan = new EventManager(_resMan->detectFontExtended());
#ifdef ENABLE_SCI32
- if (getSciVersion() >= SCI_VERSION_2_1_EARLY) {
+ if (getSciVersion() >= SCI_VERSION_2) {
_audio32 = new Audio32(_resMan);
} else
#endif
diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp
index 5e75095e5a..cfbab8b055 100644
--- a/engines/sci/sound/audio32.cpp
+++ b/engines/sci/sound/audio32.cpp
@@ -114,7 +114,9 @@ Audio32::Audio32(ResourceManager *resMan) :
_monitoredBufferSize(0),
_numMonitoredSamples(0) {
- if (getSciVersion() < SCI_VERSION_3) {
+ if (getSciVersion() < SCI_VERSION_2_1_EARLY) {
+ _channels.resize(10);
+ } else if (getSciVersion() < SCI_VERSION_3) {
_channels.resize(5);
} else {
_channels.resize(8);
@@ -311,7 +313,22 @@ int Audio32::readBuffer(Audio::st_sample_t *const buffer, const int numSamples)
Audio::st_volume_t leftVolume, rightVolume;
if (channel.pan == -1 || !isStereo()) {
- leftVolume = rightVolume = channel.volume * Audio::Mixer::kMaxChannelVolume / kMaxVolume;
+ int volume = channel.volume;
+ if (getSciVersion() == SCI_VERSION_2) {
+ // NOTE: In SSCI, audio is decompressed into a temporary
+ // buffer, then the samples in that buffer are looped over,
+ // shifting each sample right 3, 2, or 1 bits to reduce the
+ // volume.
+ if (volume > 0 && volume <= 42) {
+ volume = 15;
+ } else if (volume > 42 && volume <= 84) {
+ volume = 31;
+ } else if (volume > 84 && volume < kMaxVolume) {
+ volume = 63;
+ }
+ }
+
+ leftVolume = rightVolume = volume * Audio::Mixer::kMaxChannelVolume / kMaxVolume;
} else {
// TODO: This should match the SCI3 algorithm,
// which seems to halve the volume of each
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp
index a25ce2887b..bdd0d1b36e 100644
--- a/engines/sci/sound/midiparser_sci.cpp
+++ b/engines/sci/sound/midiparser_sci.cpp
@@ -752,18 +752,12 @@ bool MidiParser_SCI::processEvent(const EventInfo &info, bool fireEvents) {
case kUpdateCue:
if (!_jumpingToTick) {
int inc;
- switch (_soundVersion) {
- case SCI_VERSION_0_EARLY:
- case SCI_VERSION_0_LATE:
+ if (_soundVersion <= SCI_VERSION_0_LATE) {
inc = info.basic.param2;
- break;
- case SCI_VERSION_1_EARLY:
- case SCI_VERSION_1_LATE:
- case SCI_VERSION_2_1_EARLY:
+ } else if (_soundVersion >= SCI_VERSION_1_EARLY && _soundVersion <= SCI_VERSION_2_1_MIDDLE) {
inc = 1;
- break;
- default:
- error("unsupported _soundVersion");
+ } else {
+ error("Unsupported _soundVersion %s", getSciVersionDesc(_soundVersion));
}
_pSnd->dataInc += inc;
debugC(4, kDebugLevelSound, "datainc %04x", inc);
@@ -895,22 +889,14 @@ void MidiParser_SCI::allNotesOff() {
void MidiParser_SCI::setMasterVolume(byte masterVolume) {
assert(masterVolume <= MUSIC_MASTERVOLUME_MAX);
_masterVolume = masterVolume;
- switch (_soundVersion) {
- case SCI_VERSION_0_EARLY:
- case SCI_VERSION_0_LATE:
+ if (_soundVersion <= SCI_VERSION_0_LATE) {
// update driver master volume
setVolume(_volume);
- break;
-
- case SCI_VERSION_1_EARLY:
- case SCI_VERSION_1_LATE:
- case SCI_VERSION_2_1_EARLY:
+ } else if (_soundVersion >= SCI_VERSION_1_EARLY && _soundVersion <= SCI_VERSION_2_1_MIDDLE) {
// directly set master volume (global volume is merged with channel volumes)
((MidiPlayer *)_driver)->setVolume(masterVolume);
- break;
-
- default:
- error("MidiParser_SCI::setVolume: Unsupported soundVersion");
+ } else {
+ error("MidiParser_SCI::setVolume: Unsupported soundVersion %s", getSciVersionDesc(_soundVersion));
}
}
@@ -918,26 +904,17 @@ void MidiParser_SCI::setVolume(byte volume) {
assert(volume <= MUSIC_VOLUME_MAX);
_volume = volume;
- switch (_soundVersion) {
- case SCI_VERSION_0_EARLY:
- case SCI_VERSION_0_LATE: {
+ if (_soundVersion <= SCI_VERSION_0_LATE) {
// SCI0 adlib driver doesn't support channel volumes, so we need to go this way
int16 globalVolume = _volume * _masterVolume / MUSIC_VOLUME_MAX;
((MidiPlayer *)_driver)->setVolume(globalVolume);
- break;
- }
-
- case SCI_VERSION_1_EARLY:
- case SCI_VERSION_1_LATE:
- case SCI_VERSION_2_1_EARLY:
+ } else if (_soundVersion >= SCI_VERSION_1_EARLY && _soundVersion <= SCI_VERSION_2_1_MIDDLE) {
// Send previous channel volumes again to actually update the volume
for (int i = 0; i < 15; i++)
if (_channelRemap[i] != -1)
sendToDriver(0xB0 + i, 7, _channelVolume[i]);
- break;
-
- default:
- error("MidiParser_SCI::setVolume: Unsupported soundVersion");
+ } else {
+ error("MidiParser_SCI::setVolume: Unsupported soundVersion %s", getSciVersionDesc(_soundVersion));
}
}
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 987983a7f9..ae89ee832b 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -215,7 +215,7 @@ void SciMusic::pauseAll(bool pause) {
#ifdef ENABLE_SCI32
// The entire DAC will have been paused by the caller;
// do not pause the individual samples too
- if (_soundVersion >= SCI_VERSION_2_1_EARLY && (*i)->isSample) {
+ if (_soundVersion >= SCI_VERSION_2 && (*i)->isSample) {
continue;
}
#endif
@@ -483,7 +483,11 @@ void SciMusic::soundPlay(MusicEntry *pSnd) {
if (pSnd->isSample) {
#ifdef ENABLE_SCI32
- if (_soundVersion >= SCI_VERSION_2_1_EARLY) {
+ if (_soundVersion >= SCI_VERSION_2) {
+ // TODO: Sound number, loop state, and volume come from soundObj
+ // in SSCI. Getting them from MusicEntry could cause a bug if the
+ // soundObj was updated by a game script and not copied back to
+ // MusicEntry.
g_sci->_audio32->restart(ResourceId(kResourceTypeAudio, pSnd->resourceId), true, pSnd->loop != 0 && pSnd->loop != 1, pSnd->volume, pSnd->soundObj, false);
return;
} else
@@ -567,7 +571,7 @@ void SciMusic::soundStop(MusicEntry *pSnd) {
pSnd->isQueued = false;
if (pSnd->isSample) {
#ifdef ENABLE_SCI32
- if (_soundVersion >= SCI_VERSION_2_1_EARLY) {
+ if (_soundVersion >= SCI_VERSION_2) {
g_sci->_audio32->stop(ResourceId(kResourceTypeAudio, pSnd->resourceId), pSnd->soundObj);
} else {
#endif
@@ -642,7 +646,7 @@ void SciMusic::soundKill(MusicEntry *pSnd) {
if (pSnd->isSample) {
#ifdef ENABLE_SCI32
- if (_soundVersion >= SCI_VERSION_2_1_EARLY) {
+ if (_soundVersion >= SCI_VERSION_2) {
g_sci->_audio32->stop(ResourceId(kResourceTypeAudio, pSnd->resourceId), pSnd->soundObj);
} else {
#endif
diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp
index 07e01fb759..f7cb6cda5c 100644
--- a/engines/sci/sound/soundcmd.cpp
+++ b/engines/sci/sound/soundcmd.cpp
@@ -48,7 +48,7 @@ SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segM
// resource number, but it's totally unrelated to the menu music).
// The GK1 demo (very late SCI1.1) does the same thing
// TODO: Check the QFG4 demo
- _useDigitalSFX = (getSciVersion() >= SCI_VERSION_2 || g_sci->getGameId() == GID_GK1DEMO || ConfMan.getBool("prefer_digitalsfx"));
+ _useDigitalSFX = (_soundVersion >= SCI_VERSION_2 || g_sci->getGameId() == GID_GK1DEMO || ConfMan.getBool("prefer_digitalsfx"));
_music = new SciMusic(_soundVersion, _useDigitalSFX);
_music->init();
@@ -100,8 +100,8 @@ void SoundCommandParser::initSoundResource(MusicEntry *newSound) {
if (_useDigitalSFX || !newSound->soundRes) {
int sampleLen;
#ifdef ENABLE_SCI32
- if (_soundVersion >= SCI_VERSION_2_1_EARLY) {
- newSound->isSample = g_sci->getResMan()->testResource(ResourceId(kResourceTypeAudio, newSound->resourceId));
+ if (_soundVersion >= SCI_VERSION_2) {
+ newSound->isSample = g_sci->getResMan()->testResource(ResourceId(kResourceTypeAudio, newSound->resourceId)) != nullptr;
} else {
#endif
newSound->pStreamAud = _audio->getAudioStream(newSound->resourceId, 65535, &sampleLen);
@@ -316,8 +316,8 @@ reg_t SoundCommandParser::kDoSoundPause(EngineState *s, int argc, reg_t *argv) {
reg_t obj = argv[0];
const bool shouldPause = argc > 1 ? argv[1].toUint16() : false;
if (
- (_soundVersion < SCI_VERSION_2_1_EARLY && !obj.getSegment()) ||
- (_soundVersion >= SCI_VERSION_2_1_EARLY && obj.isNull())
+ (_soundVersion < SCI_VERSION_2 && !obj.getSegment()) ||
+ (_soundVersion >= SCI_VERSION_2 && obj.isNull())
) {
_music->pauseAll(shouldPause);
#ifdef ENABLE_SCI32
@@ -501,7 +501,7 @@ void SoundCommandParser::processUpdateCues(reg_t obj) {
if (musicSlot->isSample) {
#ifdef ENABLE_SCI32
- if (_soundVersion >= SCI_VERSION_2_1_EARLY) {
+ if (_soundVersion >= SCI_VERSION_2) {
const int position = g_sci->_audio32->getPosition(ResourceId(kResourceTypeAudio, musicSlot->resourceId), musicSlot->soundObj);
if (position == -1) {
@@ -717,9 +717,8 @@ reg_t SoundCommandParser::kDoSoundSetVolume(EngineState *s, int argc, reg_t *arg
// SSCI unconditionally sets volume if it is digital audio
if (_soundVersion >= SCI_VERSION_2_1_EARLY && musicSlot->isSample) {
_music->soundSetVolume(musicSlot, value);
- }
+ } else
#endif
-
if (musicSlot->volume != value) {
musicSlot->volume = value;
_music->soundSetVolume(musicSlot, value);
@@ -783,27 +782,15 @@ reg_t SoundCommandParser::kDoSoundSetLoop(EngineState *s, int argc, reg_t *argv)
return s->r_acc;
}
-#ifdef ENABLE_SCI32
- if (_soundVersion >= SCI_VERSION_2_1_EARLY) {
- if (value != -1) {
- value = 1;
- }
- }
-#endif
-
- if (value == -1) {
- musicSlot->loop = 0xFFFF;
- } else {
- musicSlot->loop = 1; // actually plays the music once
- }
-
- writeSelectorValue(_segMan, obj, SELECTOR(loop), musicSlot->loop);
+ const uint16 loopCount = value == -1 ? 0xFFFF : 1;
+ writeSelectorValue(_segMan, obj, SELECTOR(loop), loopCount);
#ifdef ENABLE_SCI32
- if (_soundVersion >= SCI_VERSION_2_1_EARLY && musicSlot->isSample) {
+ if (_soundVersion >= SCI_VERSION_2_1_MIDDLE && musicSlot->isSample) {
g_sci->_audio32->setLoop(ResourceId(kResourceTypeAudio, musicSlot->resourceId), musicSlot->soundObj, value == -1);
- }
+ } else
#endif
+ musicSlot->loop = loopCount;
return s->r_acc;
}