2009-11-12 15:24:11 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2009-11-12 15:24:11 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2009-11-12 15:24:11 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-01-12 00:51:37 +00:00
|
|
|
#include "common/config-manager.h"
|
2016-04-14 16:10:21 +03:00
|
|
|
#include "audio/audiostream.h"
|
|
|
|
#include "audio/mixer.h"
|
2016-03-18 22:55:56 -05:00
|
|
|
#include "sci/resource.h"
|
2010-02-15 00:20:53 +00:00
|
|
|
#include "sci/sound/audio.h"
|
2010-01-05 01:22:16 +00:00
|
|
|
#include "sci/sound/music.h"
|
|
|
|
#include "sci/sound/soundcmd.h"
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2010-11-25 14:22:09 +00:00
|
|
|
#include "sci/engine/features.h"
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
#include "sci/engine/guest_additions.h"
|
2010-06-23 15:23:37 +00:00
|
|
|
#include "sci/engine/kernel.h"
|
2010-11-19 08:18:24 +00:00
|
|
|
#include "sci/engine/object.h"
|
2010-01-29 11:03:54 +00:00
|
|
|
#include "sci/engine/selector.h"
|
|
|
|
|
2009-11-12 15:24:11 +00:00
|
|
|
namespace Sci {
|
|
|
|
|
2010-01-25 01:39:44 +00:00
|
|
|
SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, AudioPlayer *audio, SciVersion soundVersion) :
|
2010-01-18 22:39:56 +00:00
|
|
|
_resMan(resMan), _segMan(segMan), _kernel(kernel), _audio(audio), _soundVersion(soundVersion) {
|
2009-12-20 13:38:13 +00:00
|
|
|
|
2011-10-10 12:20:52 +03:00
|
|
|
// Check if the user wants synthesized or digital sound effects in SCI1.1
|
2012-03-25 16:40:49 +03:00
|
|
|
// games based on the prefer_digitalsfx config setting
|
2011-12-28 13:07:14 +02:00
|
|
|
|
2011-10-10 12:20:52 +03:00
|
|
|
// In SCI2 and later games, this check should always be true - there was
|
|
|
|
// always only one version of each sound effect or digital music track
|
|
|
|
// (e.g. the menu music in GK1 - there is a sound effect with the same
|
|
|
|
// resource number, but it's totally unrelated to the menu music).
|
2012-03-05 12:14:54 -05:00
|
|
|
// The GK1 demo (very late SCI1.1) does the same thing
|
|
|
|
// TODO: Check the QFG4 demo
|
2017-06-16 16:32:16 -05:00
|
|
|
_useDigitalSFX = (_soundVersion >= SCI_VERSION_2 || g_sci->getGameId() == GID_GK1DEMO || ConfMan.getBool("prefer_digitalsfx"));
|
2011-12-28 13:07:14 +02:00
|
|
|
|
|
|
|
_music = new SciMusic(_soundVersion, _useDigitalSFX);
|
|
|
|
_music->init();
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SoundCommandParser::~SoundCommandParser() {
|
2010-01-12 18:40:43 +00:00
|
|
|
delete _music;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundInit(EngineState *s, int argc, reg_t *argv) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(init): %04x:%04x", PRINT_REG(argv[0]));
|
2010-07-09 12:06:41 +00:00
|
|
|
processInitSound(argv[0]);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2011-08-25 02:52:58 +03:00
|
|
|
int SoundCommandParser::getSoundResourceId(reg_t obj) {
|
2014-06-01 17:27:59 -04:00
|
|
|
int resourceId = obj.getSegment() ? (int)readSelectorValue(_segMan, obj, SELECTOR(number)) : -1;
|
2010-11-25 14:22:09 +00:00
|
|
|
// Modify the resourceId for the Windows versions that have an alternate MIDI soundtrack, like SSCI did.
|
2011-08-25 02:52:58 +03:00
|
|
|
if (g_sci && g_sci->_features->useAltWinGMSound()) {
|
|
|
|
// Check if the alternate MIDI song actually exists...
|
|
|
|
// There are cases where it just doesn't exist (e.g. SQ4, room 530 -
|
|
|
|
// bug #3392767). In these cases, use the DOS tracks instead.
|
|
|
|
if (resourceId && _resMan->testResource(ResourceId(kResourceTypeSound, resourceId + 1000)))
|
|
|
|
resourceId += 1000;
|
|
|
|
}
|
2017-09-25 00:44:04 +02:00
|
|
|
if (g_sci->isCD() && g_sci->getGameId() == GID_SQ4 && resourceId < 1000) {
|
|
|
|
// For Space Quest 4 a few additional samples and also higher quality samples were played.
|
|
|
|
// We must not connect this to General MIDI support, because that will get disabled
|
|
|
|
// in case the user hasn't also chosen a General MIDI output device.
|
|
|
|
// We use those samples for DOS platform as well. We do basically the same for Space Quest 3,
|
|
|
|
// which also contains a few samples that were not played under the original interpreter.
|
|
|
|
// Maybe some fan wishes to opt-out of this. In this case a game specific option should be added.
|
|
|
|
// For more information see enhancement/bug #10228
|
|
|
|
// TODO: Check, if there are also enhanced samples for any of the other General MIDI games.
|
|
|
|
if (_resMan->testResource(ResourceId(kResourceTypeAudio, resourceId + 1000)))
|
|
|
|
resourceId += 1000;
|
|
|
|
}
|
2011-08-25 02:52:58 +03:00
|
|
|
|
|
|
|
return resourceId;
|
|
|
|
}
|
|
|
|
|
2011-09-26 19:57:50 +03:00
|
|
|
void SoundCommandParser::initSoundResource(MusicEntry *newSound) {
|
|
|
|
if (newSound->resourceId && _resMan->testResource(ResourceId(kResourceTypeSound, newSound->resourceId)))
|
|
|
|
newSound->soundRes = new SoundResource(newSound->resourceId, _resMan, _soundVersion);
|
|
|
|
else
|
|
|
|
newSound->soundRes = 0;
|
|
|
|
|
|
|
|
// In SCI1.1 games, sound effects are started from here. If we can find
|
|
|
|
// a relevant audio resource, play it, otherwise switch to synthesized
|
|
|
|
// effects. If the resource exists, play it using map 65535 (sound
|
|
|
|
// effects map)
|
2018-08-27 23:45:04 +03:00
|
|
|
if (getSciVersion() >= SCI_VERSION_1_1 && _resMan->testResource(ResourceId(kResourceTypeAudio, newSound->resourceId))) {
|
2011-10-10 01:40:36 +03:00
|
|
|
// Found a relevant audio resource, create an audio stream if there is
|
|
|
|
// no associated sound resource, or if both resources exist and the
|
2011-10-10 12:20:52 +03:00
|
|
|
// user wants the digital version.
|
2011-12-28 13:07:14 +02:00
|
|
|
if (_useDigitalSFX || !newSound->soundRes) {
|
2011-09-26 19:57:50 +03:00
|
|
|
int sampleLen;
|
2016-03-18 22:55:56 -05:00
|
|
|
#ifdef ENABLE_SCI32
|
2017-06-16 16:32:16 -05:00
|
|
|
if (_soundVersion >= SCI_VERSION_2) {
|
|
|
|
newSound->isSample = g_sci->getResMan()->testResource(ResourceId(kResourceTypeAudio, newSound->resourceId)) != nullptr;
|
2016-03-18 22:55:56 -05:00
|
|
|
} else {
|
|
|
|
#endif
|
|
|
|
newSound->pStreamAud = _audio->getAudioStream(newSound->resourceId, 65535, &sampleLen);
|
|
|
|
newSound->soundType = Audio::Mixer::kSFXSoundType;
|
|
|
|
newSound->isSample = newSound->pStreamAud != nullptr;
|
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
}
|
|
|
|
#endif
|
2011-09-26 19:57:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 22:55:56 -05:00
|
|
|
if (!newSound->isSample && newSound->soundRes)
|
2011-09-26 19:57:50 +03:00
|
|
|
_music->soundInitSnd(newSound);
|
|
|
|
}
|
|
|
|
|
2011-08-25 02:52:58 +03:00
|
|
|
void SoundCommandParser::processInitSound(reg_t obj) {
|
|
|
|
int resourceId = getSoundResourceId(obj);
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2010-01-27 21:11:24 +00:00
|
|
|
// Check if a track with the same sound object is already playing
|
|
|
|
MusicEntry *oldSound = _music->getSlot(obj);
|
|
|
|
if (oldSound)
|
2010-07-09 12:06:41 +00:00
|
|
|
processDisposeSound(obj);
|
2010-01-27 21:11:24 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
MusicEntry *newSound = new MusicEntry();
|
2010-05-19 14:19:16 +00:00
|
|
|
newSound->resourceId = resourceId;
|
2009-12-20 14:27:43 +00:00
|
|
|
newSound->soundObj = obj;
|
2010-05-29 23:37:15 +00:00
|
|
|
newSound->loop = readSelectorValue(_segMan, obj, SELECTOR(loop));
|
2016-06-11 16:53:17 -05:00
|
|
|
newSound->overridePriority = false;
|
2013-09-21 14:27:16 +02:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
|
|
|
newSound->priority = readSelectorValue(_segMan, obj, SELECTOR(priority));
|
|
|
|
else
|
|
|
|
newSound->priority = readSelectorValue(_segMan, obj, SELECTOR(priority)) & 0xFF;
|
2010-05-28 09:29:05 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_EARLY)
|
2010-05-29 23:37:15 +00:00
|
|
|
newSound->volume = CLIP<int>(readSelectorValue(_segMan, obj, SELECTOR(vol)), 0, MUSIC_VOLUME_MAX);
|
2010-11-25 16:09:45 +00:00
|
|
|
newSound->reverb = -1; // initialize to SCI invalid, it'll be set correctly in soundInitSnd() below
|
2009-12-28 20:10:15 +00:00
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(init): %04x:%04x number %d, loop %d, prio %d, vol %d", PRINT_REG(obj),
|
2010-07-18 16:02:16 +00:00
|
|
|
resourceId, newSound->loop, newSound->priority, newSound->volume);
|
2010-06-12 11:41:22 +00:00
|
|
|
|
2011-09-26 19:57:50 +03:00
|
|
|
initSoundResource(newSound);
|
SCI/new music code:
- Resolved a deadlock with the mixer, and added appropriate mutexes (a result of the fact that SCI mixes MIDI and digital audio in the same list)
- Fixed sound playing when loading games, by properly resetting the MIDI driver
- Reverted savegame version to 14 - the changes in versions 15 and 16 don't have any effect on the currently enabled old music code, and the new music code is disabled by default, and is still prone to changes
- Now saving/loading signal, loop and hold for each sound, as well as reverb
- Added stub code for setting reverb and channel hold
- The signal, loop and hold values of each song are cached, like in SSCI and like what happens in Greg's SCI implementation. This allows a clear separation of the engine code from the rest of the engine. Reverted commits 46792 and 46797
- Removed duplicate song list accessing code
- Song cues are now updated in kAnimate for SCI0, like the old music code does, to compensate for the fact that SCI0 didn't poll for music changes via cmdUpdateCues, like what SCI01 and newer do
- Cleanup
svn-id: r46812
2010-01-01 06:41:52 +00:00
|
|
|
|
|
|
|
_music->pushBackSlot(newSound);
|
|
|
|
|
2016-03-18 22:55:56 -05:00
|
|
|
if (newSound->soundRes || newSound->isSample) {
|
2010-01-03 21:51:30 +00:00
|
|
|
// Notify the engine
|
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(state), kSoundInitialized);
|
2010-01-03 21:51:30 +00:00
|
|
|
else
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelector(_segMan, obj, SELECTOR(nodePtr), obj);
|
2010-01-03 21:51:30 +00:00
|
|
|
}
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundPlay(EngineState *s, int argc, reg_t *argv) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(play): %04x:%04x", PRINT_REG(argv[0]));
|
2014-10-07 19:48:18 +02:00
|
|
|
bool playBed = false;
|
|
|
|
if (argc >= 2 && !argv[1].isNull())
|
|
|
|
playBed = true;
|
|
|
|
processPlaySound(argv[0], playBed);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2010-07-09 12:06:41 +00:00
|
|
|
}
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2014-10-07 19:48:18 +02:00
|
|
|
void SoundCommandParser::processPlaySound(reg_t obj, bool playBed) {
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2011-09-23 17:41:30 +03:00
|
|
|
warning("kDoSound(play): Slot not found (%04x:%04x), initializing it manually", PRINT_REG(obj));
|
2011-10-13 13:58:42 +03:00
|
|
|
// The sound hasn't been initialized for some reason, so initialize it
|
|
|
|
// here. Happens in KQ6, room 460, when giving the creature (child) to
|
|
|
|
// the bookworm. Fixes bugs #3413301 and #3421098.
|
2011-09-23 17:41:30 +03:00
|
|
|
processInitSound(obj);
|
|
|
|
musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot)
|
|
|
|
error("Failed to initialize uninitialized sound slot");
|
2009-12-23 16:33:12 +00:00
|
|
|
}
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2011-08-25 02:52:58 +03:00
|
|
|
int resourceId = getSoundResourceId(obj);
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2010-05-19 14:19:16 +00:00
|
|
|
if (musicSlot->resourceId != resourceId) { // another sound loaded into struct
|
2010-07-09 12:06:41 +00:00
|
|
|
processDisposeSound(obj);
|
|
|
|
processInitSound(obj);
|
2009-12-25 13:52:40 +00:00
|
|
|
// Find slot again :)
|
2009-12-27 11:43:34 +00:00
|
|
|
musicSlot = _music->getSlot(obj);
|
2009-12-23 16:33:12 +00:00
|
|
|
}
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelector(_segMan, obj, SELECTOR(handle), obj);
|
2009-12-31 08:10:51 +00:00
|
|
|
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_EARLY) {
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelector(_segMan, obj, SELECTOR(nodePtr), obj);
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(min), 0);
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(sec), 0);
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(frame), 0);
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(signal), 0);
|
2009-12-23 18:34:19 +00:00
|
|
|
} else {
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(state), kSoundPlaying);
|
2009-12-23 16:43:24 +00:00
|
|
|
}
|
2009-12-23 20:13:54 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
musicSlot->loop = readSelectorValue(_segMan, obj, SELECTOR(loop));
|
2015-02-14 15:20:23 +01:00
|
|
|
|
|
|
|
// Get song priority from either obj or soundRes
|
2015-02-18 09:33:03 +01:00
|
|
|
byte resourcePriority = 0xFF;
|
|
|
|
if (musicSlot->soundRes)
|
|
|
|
resourcePriority = musicSlot->soundRes->getSoundPriority();
|
2015-02-14 15:20:23 +01:00
|
|
|
if (!musicSlot->overridePriority && resourcePriority != 0xFF) {
|
|
|
|
musicSlot->priority = resourcePriority;
|
|
|
|
} else {
|
|
|
|
musicSlot->priority = readSelectorValue(_segMan, obj, SELECTOR(priority));
|
|
|
|
}
|
|
|
|
|
2011-09-24 18:44:57 +03:00
|
|
|
// Reset hold when starting a new song. kDoSoundSetHold is always called after
|
|
|
|
// kDoSoundPlay to set it properly, if needed. Fixes bug #3413589.
|
|
|
|
musicSlot->hold = -1;
|
2014-10-07 19:48:18 +02:00
|
|
|
musicSlot->playBed = playBed;
|
2010-05-28 09:29:05 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_EARLY)
|
2010-05-29 23:37:15 +00:00
|
|
|
musicSlot->volume = readSelectorValue(_segMan, obj, SELECTOR(vol));
|
2010-06-12 11:41:22 +00:00
|
|
|
|
2014-10-07 19:48:18 +02:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(play): %04x:%04x number %d, loop %d, prio %d, vol %d, bed %d", PRINT_REG(obj),
|
|
|
|
resourceId, musicSlot->loop, musicSlot->priority, musicSlot->volume, playBed ? 1 : 0);
|
2010-06-12 11:41:22 +00:00
|
|
|
|
2009-12-26 11:54:57 +00:00
|
|
|
_music->soundPlay(musicSlot);
|
2013-04-06 19:06:05 +02:00
|
|
|
|
|
|
|
// Reset any left-over signals
|
|
|
|
musicSlot->signal = 0;
|
|
|
|
musicSlot->fadeStep = 0;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundDispose(EngineState *s, int argc, reg_t *argv) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(dispose): %04x:%04x", PRINT_REG(argv[0]));
|
2010-07-09 12:06:41 +00:00
|
|
|
processDisposeSound(argv[0]);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2010-07-09 12:06:41 +00:00
|
|
|
}
|
2009-12-23 18:34:19 +00:00
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
void SoundCommandParser::processDisposeSound(reg_t obj) {
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(dispose): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
2009-11-29 14:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
processStopSound(obj, false);
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
_music->soundKill(musicSlot);
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(handle), 0);
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_EARLY)
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelector(_segMan, obj, SELECTOR(nodePtr), NULL_REG);
|
2009-12-23 18:34:19 +00:00
|
|
|
else
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(state), kSoundStopped);
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundStop(EngineState *s, int argc, reg_t *argv) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(stop): %04x:%04x", PRINT_REG(argv[0]));
|
2010-07-09 12:06:41 +00:00
|
|
|
processStopSound(argv[0], false);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2010-05-03 17:54:47 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
void SoundCommandParser::processStopSound(reg_t obj, bool sampleFinishedPlaying) {
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(stop): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
2009-11-29 14:48:15 +00:00
|
|
|
return;
|
2009-12-20 14:27:43 +00:00
|
|
|
}
|
|
|
|
|
2010-01-29 19:02:13 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE) {
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(state), kSoundStopped);
|
2010-01-29 19:02:13 +00:00
|
|
|
} else {
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(handle), 0);
|
2010-01-29 17:45:30 +00:00
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2010-06-29 20:50:52 +00:00
|
|
|
// Set signal selector in sound SCI0 games only, when the sample has
|
|
|
|
// finished playing. If we don't set it at all, we get a problem when using
|
|
|
|
// vaporizer on the 2 guys. If we set it all the time, we get no music in
|
|
|
|
// sq3new and kq1.
|
|
|
|
// FIXME: This *may* be wrong, it's impossible to find out in Sierra DOS
|
|
|
|
// SCI, because SCI0 under DOS didn't have sfx drivers included.
|
|
|
|
// We need to set signal in sound SCI1+ games all the time.
|
2010-05-03 17:54:47 +00:00
|
|
|
if ((_soundVersion > SCI_VERSION_0_LATE) || sampleFinishedPlaying)
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
|
2010-05-03 17:54:47 +00:00
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
musicSlot->dataInc = 0;
|
2013-04-01 21:28:56 +03:00
|
|
|
musicSlot->signal = SIGNAL_OFFSET;
|
2009-12-27 11:43:34 +00:00
|
|
|
_music->soundStop(musicSlot);
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundPause(EngineState *s, int argc, reg_t *argv) {
|
2010-07-29 10:58:01 +00:00
|
|
|
if (argc == 1)
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(pause): %04x:%04x", PRINT_REG(argv[0]));
|
2010-07-29 10:58:01 +00:00
|
|
|
else
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(pause): %04x:%04x, %04x:%04x", PRINT_REG(argv[0]), PRINT_REG(argv[1]));
|
2010-07-29 10:58:01 +00:00
|
|
|
|
2010-07-09 16:05:47 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE) {
|
2010-07-09 18:11:42 +00:00
|
|
|
// SCI0 games give us 0/1 for either resuming or pausing the current music
|
|
|
|
// this one doesn't count, so pausing 2 times and resuming once means here that we are supposed to resume
|
2010-07-09 16:05:47 +00:00
|
|
|
uint16 value = argv[0].toUint16();
|
|
|
|
MusicEntry *musicSlot = _music->getActiveSci0MusicSlot();
|
|
|
|
switch (value) {
|
|
|
|
case 1:
|
2010-07-09 18:11:42 +00:00
|
|
|
if ((musicSlot) && (musicSlot->status == kSoundPlaying)) {
|
2010-07-09 16:05:47 +00:00
|
|
|
_music->soundPause(musicSlot);
|
2010-07-09 18:11:42 +00:00
|
|
|
writeSelectorValue(_segMan, musicSlot->soundObj, SELECTOR(state), kSoundPaused);
|
|
|
|
}
|
2010-07-09 16:05:47 +00:00
|
|
|
return make_reg(0, 0);
|
|
|
|
case 0:
|
|
|
|
if ((musicSlot) && (musicSlot->status == kSoundPaused)) {
|
|
|
|
_music->soundResume(musicSlot);
|
2010-07-09 18:11:42 +00:00
|
|
|
writeSelectorValue(_segMan, musicSlot->soundObj, SELECTOR(state), kSoundPlaying);
|
2010-07-09 16:05:47 +00:00
|
|
|
return make_reg(0, 1);
|
|
|
|
}
|
|
|
|
return make_reg(0, 0);
|
|
|
|
default:
|
2010-07-10 13:19:20 +00:00
|
|
|
error("kDoSound(pause): parameter 0 is invalid for sound-sci0");
|
2010-07-09 16:05:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t obj = argv[0];
|
2016-03-18 22:55:56 -05:00
|
|
|
const bool shouldPause = argc > 1 ? argv[1].toUint16() : false;
|
|
|
|
if (
|
2017-06-16 16:32:16 -05:00
|
|
|
(_soundVersion < SCI_VERSION_2 && !obj.getSegment()) ||
|
|
|
|
(_soundVersion >= SCI_VERSION_2 && obj.isNull())
|
2016-03-18 22:55:56 -05:00
|
|
|
) {
|
|
|
|
_music->pauseAll(shouldPause);
|
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
if (_soundVersion >= SCI_VERSION_2_1_EARLY) {
|
|
|
|
if (shouldPause) {
|
|
|
|
g_sci->_audio32->pause(kAllChannels);
|
|
|
|
} else {
|
|
|
|
g_sci->_audio32->resume(kAllChannels);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} else {
|
2010-01-21 21:28:32 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
2009-12-28 22:35:53 +00:00
|
|
|
if (!musicSlot) {
|
2010-08-02 21:20:43 +00:00
|
|
|
// This happens quite frequently
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(pause): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-12-28 22:35:53 +00:00
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2016-03-18 22:55:56 -05:00
|
|
|
#ifdef ENABLE_SCI32
|
2017-10-06 11:24:08 -05:00
|
|
|
// SSCI also expected a global "kernel call" flag to be true in order to
|
|
|
|
// perform this action, but the architecture of the ScummVM
|
|
|
|
// implementation is so different that it doesn't matter here
|
2016-03-18 22:55:56 -05:00
|
|
|
if (_soundVersion >= SCI_VERSION_2_1_EARLY && musicSlot->isSample) {
|
|
|
|
if (shouldPause) {
|
2017-03-12 13:07:20 -05:00
|
|
|
g_sci->_audio32->pause(ResourceId(kResourceTypeAudio, musicSlot->resourceId), musicSlot->soundObj);
|
2016-03-18 22:55:56 -05:00
|
|
|
} else {
|
2017-03-12 13:07:20 -05:00
|
|
|
g_sci->_audio32->resume(ResourceId(kResourceTypeAudio, musicSlot->resourceId), musicSlot->soundObj);
|
2016-03-18 22:55:56 -05:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
_music->soundToggle(musicSlot, shouldPause);
|
2010-01-21 21:28:32 +00:00
|
|
|
}
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
// SCI0 only command
|
2010-07-20 11:17:33 +00:00
|
|
|
// It's called right after restoring a game - it's responsible to kick off playing music again
|
|
|
|
// we don't need this at all, so we don't do anything here
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundResumeAfterRestore(EngineState *s, int argc, reg_t *argv) {
|
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundMute(EngineState *s, int argc, reg_t *argv) {
|
2010-08-01 19:57:03 +00:00
|
|
|
uint16 previousState = _music->soundGetSoundOn();
|
2010-07-29 10:58:01 +00:00
|
|
|
if (argc > 0) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(mute): %d", argv[0].toUint16());
|
2010-07-09 12:06:41 +00:00
|
|
|
_music->soundSetSoundOn(argv[0].toUint16());
|
2010-07-29 10:58:01 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 19:57:03 +00:00
|
|
|
return make_reg(0, previousState);
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundMasterVolume(EngineState *s, int argc, reg_t *argv) {
|
|
|
|
s->r_acc = make_reg(0, _music->soundGetMasterVolume());
|
2010-01-13 17:34:42 +00:00
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
if (argc > 0) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(masterVolume): %d", argv[0].toSint16());
|
2010-09-01 19:20:17 +00:00
|
|
|
int vol = CLIP<int16>(argv[0].toSint16(), 0, MUSIC_MASTERVOLUME_MAX);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
|
|
|
|
if (!g_sci->_guestAdditions->kDoSoundMasterVolumeHook(vol)) {
|
|
|
|
setMasterVolume(vol);
|
2016-03-18 22:55:56 -05:00
|
|
|
}
|
2010-01-12 00:51:37 +00:00
|
|
|
}
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundFade(EngineState *s, int argc, reg_t *argv) {
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t obj = argv[0];
|
2009-11-17 06:39:28 +00:00
|
|
|
|
2012-10-22 12:47:28 +03:00
|
|
|
// The object can be null in several SCI0 games (e.g. Camelot, KQ1, KQ4, MUMG).
|
|
|
|
// Check bugs #3035149, #3036942 and #3578335.
|
|
|
|
// In this case, we just ignore the call.
|
|
|
|
if (obj.isNull() && argc == 1)
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2012-10-22 12:47:28 +03:00
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(fade): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-12-22 12:35:48 +00:00
|
|
|
}
|
2009-12-23 16:33:12 +00:00
|
|
|
|
2009-12-29 23:25:24 +00:00
|
|
|
int volume = musicSlot->volume;
|
2010-01-03 23:30:23 +00:00
|
|
|
|
2016-03-18 22:55:56 -05:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
if (_soundVersion >= SCI_VERSION_2_1_EARLY && musicSlot->isSample) {
|
2016-07-01 12:38:44 -05:00
|
|
|
g_sci->_audio32->fadeChannel(ResourceId(kResourceTypeAudio, musicSlot->resourceId), musicSlot->soundObj, argv[1].toSint16(), argv[2].toSint16(), argv[3].toSint16(), argc > 4 ? (bool)argv[4].toSint16() : false);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2016-03-18 22:55:56 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-06-08 09:36:27 +00:00
|
|
|
// If sound is not playing currently, set signal directly
|
|
|
|
if (musicSlot->status != kSoundPlaying) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(fade): %04x:%04x fading requested, but sound is currently not playing", PRINT_REG(obj));
|
2010-06-08 09:36:27 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2010-06-08 09:36:27 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
switch (argc) {
|
|
|
|
case 1: // SCI0
|
2010-06-29 20:50:52 +00:00
|
|
|
// SCI0 fades out all the time and when fadeout is done it will also
|
|
|
|
// stop the music from playing
|
2010-01-03 23:30:23 +00:00
|
|
|
musicSlot->fadeTo = 0;
|
|
|
|
musicSlot->fadeStep = -5;
|
2010-01-04 15:17:46 +00:00
|
|
|
musicSlot->fadeTickerStep = 10 * 16667 / _music->soundGetTempo();
|
2010-01-03 23:30:23 +00:00
|
|
|
musicSlot->fadeTicker = 0;
|
|
|
|
break;
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
case 4: // SCI01+
|
|
|
|
case 5: // SCI1+ (SCI1 late sound scheme), with fade and continue
|
2013-04-06 19:10:23 +02:00
|
|
|
musicSlot->fadeTo = CLIP<uint16>(argv[1].toUint16(), 0, MUSIC_VOLUME_MAX);
|
|
|
|
// Check if the song is already at the requested volume. If it is, don't
|
|
|
|
// perform any fading. Happens for example during the intro of Longbow.
|
|
|
|
if (musicSlot->fadeTo == musicSlot->volume)
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2013-04-06 19:10:23 +02:00
|
|
|
|
2013-04-27 14:02:49 +03:00
|
|
|
// Sometimes we get objects in that position, so fix the value (refer to workarounds.cpp)
|
2013-04-06 19:10:23 +02:00
|
|
|
if (!argv[1].getSegment())
|
|
|
|
musicSlot->fadeStep = volume > musicSlot->fadeTo ? -argv[3].toUint16() : argv[3].toUint16();
|
|
|
|
else
|
|
|
|
musicSlot->fadeStep = volume > musicSlot->fadeTo ? -5 : 5;
|
|
|
|
musicSlot->fadeTickerStep = argv[2].toUint16() * 16667 / _music->soundGetTempo();
|
|
|
|
musicSlot->fadeTicker = 0;
|
2013-04-06 20:48:52 +02:00
|
|
|
|
|
|
|
// argv[4] is a boolean. Scripts sometimes pass strange values,
|
2018-08-28 02:03:50 +03:00
|
|
|
// but SSCI only checks for zero/non-zero. (Verified in KQ6).
|
2013-04-06 20:48:52 +02:00
|
|
|
// KQ6 room 460 even passes an object, but treating this as 'true'
|
|
|
|
// seems fine in that case.
|
2013-04-06 22:28:42 +02:00
|
|
|
if (argc == 5)
|
|
|
|
musicSlot->stopAfterFading = !argv[4].isNull();
|
|
|
|
else
|
|
|
|
musicSlot->stopAfterFading = false;
|
2010-01-03 23:30:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-07-10 13:19:20 +00:00
|
|
|
error("kDoSound(fade): unsupported argc %d", argc);
|
2010-01-03 23:30:23 +00:00
|
|
|
}
|
2009-12-29 23:25:24 +00:00
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(fade): %04x:%04x to %d, step %d, ticker %d", PRINT_REG(obj), musicSlot->fadeTo, musicSlot->fadeStep, musicSlot->fadeTickerStep);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundGetPolyphony(EngineState *s, int argc, reg_t *argv) {
|
2010-07-09 12:06:41 +00:00
|
|
|
return make_reg(0, _music->soundGetVoices()); // Get the number of voices
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundUpdate(EngineState *s, int argc, reg_t *argv) {
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t obj = argv[0];
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(update): %04x:%04x", PRINT_REG(argv[0]));
|
2010-07-29 10:58:01 +00:00
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(update): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-29 14:48:15 +00:00
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
musicSlot->loop = readSelectorValue(_segMan, obj, SELECTOR(loop));
|
|
|
|
int16 objVol = CLIP<int>(readSelectorValue(_segMan, obj, SELECTOR(vol)), 0, 255);
|
2009-12-26 11:54:57 +00:00
|
|
|
if (objVol != musicSlot->volume)
|
|
|
|
_music->soundSetVolume(musicSlot, objVol);
|
2013-09-21 14:34:42 +02:00
|
|
|
int16 objPrio = readSelectorValue(_segMan, obj, SELECTOR(priority));
|
2010-05-19 14:19:16 +00:00
|
|
|
if (objPrio != musicSlot->priority)
|
2009-12-26 11:54:57 +00:00
|
|
|
_music->soundSetPriority(musicSlot, objPrio);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundUpdateCues(EngineState *s, int argc, reg_t *argv) {
|
2010-07-09 12:06:41 +00:00
|
|
|
processUpdateCues(argv[0]);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2010-07-09 12:06:41 +00:00
|
|
|
}
|
2009-12-20 16:35:37 +00:00
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
void SoundCommandParser::processUpdateCues(reg_t obj) {
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(updateCues): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
2009-11-29 14:48:15 +00:00
|
|
|
return;
|
2009-12-20 16:35:37 +00:00
|
|
|
}
|
2010-01-01 16:05:26 +00:00
|
|
|
|
2016-03-18 22:55:56 -05:00
|
|
|
if (musicSlot->isSample) {
|
|
|
|
#ifdef ENABLE_SCI32
|
2017-06-16 16:32:16 -05:00
|
|
|
if (_soundVersion >= SCI_VERSION_2) {
|
2017-09-24 22:20:14 -05:00
|
|
|
const ResourceId audioId = ResourceId(kResourceTypeAudio, musicSlot->resourceId);
|
|
|
|
|
|
|
|
if (getSciVersion() == SCI_VERSION_3) {
|
|
|
|
// In SSCI the volume is first set to -1 and then reset later if
|
|
|
|
// a sample is playing in the audio player, but since our audio
|
|
|
|
// code returns -1 for not-found samples, the extra check is not
|
|
|
|
// needed and we can just always set it to the return value of
|
|
|
|
// the getVolume call
|
|
|
|
const int16 volume = g_sci->_audio32->getVolume(audioId, musicSlot->soundObj);
|
|
|
|
writeSelectorValue(_segMan, musicSlot->soundObj, SELECTOR(vol), volume);
|
|
|
|
}
|
2016-03-18 22:55:56 -05:00
|
|
|
|
2017-09-24 22:20:14 -05:00
|
|
|
const int16 position = g_sci->_audio32->getPosition(audioId, musicSlot->soundObj);
|
2016-03-18 22:55:56 -05:00
|
|
|
if (position == -1) {
|
|
|
|
processStopSound(musicSlot->soundObj, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2010-01-08 20:11:27 +00:00
|
|
|
// Update digital sound effect slots
|
2010-01-07 17:45:17 +00:00
|
|
|
uint currentLoopCounter = 0;
|
|
|
|
|
|
|
|
if (musicSlot->pLoopStream)
|
|
|
|
currentLoopCounter = musicSlot->pLoopStream->getCompleteIterations();
|
|
|
|
|
2010-01-01 22:15:52 +00:00
|
|
|
if (currentLoopCounter != musicSlot->sampleLoopCounter) {
|
|
|
|
// during last time we looped at least one time, update loop accordingly
|
|
|
|
musicSlot->loop -= currentLoopCounter - musicSlot->sampleLoopCounter;
|
|
|
|
musicSlot->sampleLoopCounter = currentLoopCounter;
|
|
|
|
}
|
2010-07-19 07:29:17 +00:00
|
|
|
if (musicSlot->status == kSoundPlaying) {
|
|
|
|
if (!_music->soundIsActive(musicSlot)) {
|
|
|
|
processStopSound(obj, true);
|
|
|
|
} else {
|
|
|
|
_music->updateAudioStreamTicker(musicSlot);
|
|
|
|
}
|
2010-07-19 07:37:22 +00:00
|
|
|
} else if (musicSlot->status == kSoundPaused) {
|
|
|
|
_music->updateAudioStreamTicker(musicSlot);
|
2010-01-01 16:05:26 +00:00
|
|
|
}
|
2010-01-01 22:15:52 +00:00
|
|
|
// We get a flag from MusicEntry::doFade() here to set volume for the stream
|
2010-01-02 15:54:08 +00:00
|
|
|
if (musicSlot->fadeSetVolume) {
|
2010-09-06 18:23:03 +00:00
|
|
|
_music->soundSetSampleVolume(musicSlot, musicSlot->volume);
|
2010-01-02 15:54:08 +00:00
|
|
|
musicSlot->fadeSetVolume = false;
|
2010-01-01 22:15:52 +00:00
|
|
|
}
|
2010-05-10 20:32:55 +00:00
|
|
|
} else if (musicSlot->pMidiParser) {
|
2010-01-08 20:11:27 +00:00
|
|
|
// Update MIDI slots
|
|
|
|
if (musicSlot->signal == 0) {
|
2010-05-29 23:37:15 +00:00
|
|
|
if (musicSlot->dataInc != readSelectorValue(_segMan, obj, SELECTOR(dataInc))) {
|
2010-06-10 09:18:57 +00:00
|
|
|
if (SELECTOR(dataInc) > -1)
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(dataInc), musicSlot->dataInc);
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(signal), musicSlot->dataInc + 127);
|
2010-01-08 20:11:27 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Sync the signal of the sound object
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(signal), musicSlot->signal);
|
2010-01-08 20:25:42 +00:00
|
|
|
// We need to do this especially because state selector needs to get updated
|
|
|
|
if (musicSlot->signal == SIGNAL_OFFSET)
|
2010-07-09 12:06:41 +00:00
|
|
|
processStopSound(obj, false);
|
2010-01-02 15:02:41 +00:00
|
|
|
}
|
2010-05-10 20:32:55 +00:00
|
|
|
} else {
|
2013-03-29 01:17:23 +02:00
|
|
|
// The sound slot has no data for the currently selected sound card.
|
|
|
|
// An example can be found during the mud wrestling scene in LSL5, room
|
|
|
|
// 730: sound 744 (a splat sound heard when Lana Luscious jumps in the
|
|
|
|
// mud) only contains MIDI channel data. If a non-MIDI sound card is
|
|
|
|
// selected (like Adlib), then the scene freezes. We also need to stop
|
|
|
|
// the sound at this point, otherwise KQ6 Mac breaks because the rest
|
|
|
|
// of the object needs to be reset to avoid a continuous stream of
|
|
|
|
// sound cues.
|
|
|
|
processStopSound(obj, true); // this also sets the signal selector
|
2010-01-01 16:05:26 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 17:16:59 +00:00
|
|
|
if (musicSlot->fadeCompleted) {
|
|
|
|
musicSlot->fadeCompleted = false;
|
2011-02-25 21:45:39 +02:00
|
|
|
// We need signal for sci0 at least in iceman as well (room 14,
|
|
|
|
// fireworks).
|
|
|
|
// It is also needed in other games, e.g. LSL6 when talking to the
|
|
|
|
// receptionist (bug #3192166).
|
2013-11-23 15:25:56 +01:00
|
|
|
// TODO: More thorougly check the different SCI version:
|
|
|
|
// * SCI1late sets signal to 0xFE here. (With signal 0xFF
|
|
|
|
// duplicate music plays in LauraBow2CD - bug #6462)
|
2013-11-23 16:11:07 +01:00
|
|
|
// SCI1middle LSL1 1.000.510 does not have the 0xFE;
|
|
|
|
// SCI1late CastleDrBrain demo 1.000.005 does have the 0xFE.
|
2013-11-23 15:25:56 +01:00
|
|
|
// * Other SCI1 games seem to rely on processStopSound to set the signal
|
|
|
|
// * Need to check SCI0 behaviour.
|
|
|
|
uint16 sig;
|
2013-11-23 16:11:07 +01:00
|
|
|
if (getSciVersion() >= SCI_VERSION_1_LATE)
|
2013-11-23 15:25:56 +01:00
|
|
|
sig = 0xFFFE;
|
|
|
|
else
|
|
|
|
sig = SIGNAL_OFFSET;
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(signal), sig);
|
2011-02-25 21:45:39 +02:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE) {
|
2010-07-09 12:06:41 +00:00
|
|
|
processStopSound(obj, false);
|
2010-01-04 15:17:46 +00:00
|
|
|
} else {
|
2010-01-11 14:26:13 +00:00
|
|
|
if (musicSlot->stopAfterFading)
|
2010-07-09 12:06:41 +00:00
|
|
|
processStopSound(obj, false);
|
2010-01-04 15:17:46 +00:00
|
|
|
}
|
2010-01-02 17:16:59 +00:00
|
|
|
}
|
|
|
|
|
2010-01-01 16:15:20 +00:00
|
|
|
// Sync loop selector for SCI0
|
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(loop), musicSlot->loop);
|
2009-12-23 16:33:12 +00:00
|
|
|
|
SCI/new music code:
- Resolved a deadlock with the mixer, and added appropriate mutexes (a result of the fact that SCI mixes MIDI and digital audio in the same list)
- Fixed sound playing when loading games, by properly resetting the MIDI driver
- Reverted savegame version to 14 - the changes in versions 15 and 16 don't have any effect on the currently enabled old music code, and the new music code is disabled by default, and is still prone to changes
- Now saving/loading signal, loop and hold for each sound, as well as reverb
- Added stub code for setting reverb and channel hold
- The signal, loop and hold values of each song are cached, like in SSCI and like what happens in Greg's SCI implementation. This allows a clear separation of the engine code from the rest of the engine. Reverted commits 46792 and 46797
- Removed duplicate song list accessing code
- Song cues are now updated in kAnimate for SCI0, like the old music code does, to compensate for the fact that SCI0 didn't poll for music changes via cmdUpdateCues, like what SCI01 and newer do
- Cleanup
svn-id: r46812
2010-01-01 06:41:52 +00:00
|
|
|
musicSlot->signal = 0;
|
|
|
|
|
|
|
|
if (_soundVersion >= SCI_VERSION_1_EARLY) {
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(min), musicSlot->ticker / 3600);
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(sec), musicSlot->ticker % 3600 / 60);
|
2015-02-15 14:14:46 +01:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(frame), musicSlot->ticker % 60 / 2);
|
SCI/new music code:
- Resolved a deadlock with the mixer, and added appropriate mutexes (a result of the fact that SCI mixes MIDI and digital audio in the same list)
- Fixed sound playing when loading games, by properly resetting the MIDI driver
- Reverted savegame version to 14 - the changes in versions 15 and 16 don't have any effect on the currently enabled old music code, and the new music code is disabled by default, and is still prone to changes
- Now saving/loading signal, loop and hold for each sound, as well as reverb
- Added stub code for setting reverb and channel hold
- The signal, loop and hold values of each song are cached, like in SSCI and like what happens in Greg's SCI implementation. This allows a clear separation of the engine code from the rest of the engine. Reverted commits 46792 and 46797
- Removed duplicate song list accessing code
- Song cues are now updated in kAnimate for SCI0, like the old music code does, to compensate for the fact that SCI0 didn't poll for music changes via cmdUpdateCues, like what SCI01 and newer do
- Cleanup
svn-id: r46812
2010-01-01 06:41:52 +00:00
|
|
|
}
|
2010-01-01 16:05:26 +00:00
|
|
|
}
|
2009-11-12 15:24:11 +00:00
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundSendMidi(EngineState *s, int argc, reg_t *argv) {
|
2013-06-19 02:02:05 +03:00
|
|
|
// The 4 parameter variant of this call is used in at least LSL1VGA, room
|
|
|
|
// 110 (Lefty's bar), to distort the music when Larry is drunk and stands
|
|
|
|
// up - bug #3614447.
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t obj = argv[0];
|
2010-07-09 12:30:34 +00:00
|
|
|
byte channel = argv[1].toUint16() & 0xf;
|
2013-06-19 02:02:05 +03:00
|
|
|
byte midiCmd = (argc == 5) ? argv[2].toUint16() & 0xff : 0xB0; // 0xB0: controller
|
|
|
|
uint16 controller = (argc == 5) ? argv[3].toUint16() : argv[2].toUint16();
|
|
|
|
uint16 param = (argc == 5) ? argv[4].toUint16() : argv[3].toUint16();
|
|
|
|
|
2018-08-21 03:34:40 +03:00
|
|
|
// This call is made in Hoyle 5 when toggling the music from the main menu.
|
|
|
|
// Ignore it for this game, since it doesn't use MIDI audio, and this call
|
|
|
|
// looks to be a leftover in Sound::mute (script 64989).
|
|
|
|
if (g_sci->getGameId() == GID_HOYLE5)
|
|
|
|
return s->r_acc;
|
|
|
|
|
2013-06-19 02:02:05 +03:00
|
|
|
if (argc == 4 && controller == 0xFF) {
|
|
|
|
midiCmd = 0xE0; // 0xE0: pitch wheel
|
|
|
|
uint16 pitch = CLIP<uint16>(argv[3].toSint16() + 0x2000, 0x0000, 0x3FFF);
|
|
|
|
controller = pitch & 0x7F;
|
|
|
|
param = pitch >> 7;
|
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(sendMidi): %04x:%04x, %d, %d, %d, %d", PRINT_REG(obj), channel, midiCmd, controller, param);
|
2010-07-09 12:06:41 +00:00
|
|
|
if (channel)
|
|
|
|
channel--; // channel is given 1-based, we are using 0-based
|
|
|
|
|
|
|
|
uint32 midiCommand = (channel | midiCmd) | ((uint32)controller << 8) | ((uint32)param << 16);
|
|
|
|
|
2010-06-17 11:54:54 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
|
|
|
// TODO: maybe it's possible to call this with obj == 0:0 and send directly?!
|
|
|
|
// if so, allow it
|
|
|
|
//_music->sendMidiCommand(_midiCommand);
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(sendMidi): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2010-06-17 11:54:54 +00:00
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
_music->sendMidiCommand(musicSlot, midiCommand);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundGlobalReverb(EngineState *s, int argc, reg_t *argv) {
|
2010-11-24 16:01:30 +00:00
|
|
|
byte prevReverb = _music->getCurrentReverb();
|
|
|
|
byte reverb = argv[0].toUint16() & 0xF;
|
2010-11-24 14:21:31 +00:00
|
|
|
|
2010-11-24 16:01:30 +00:00
|
|
|
if (argc == 1) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "doSoundGlobalReverb: %d", argv[0].toUint16() & 0xF);
|
2010-11-24 16:01:30 +00:00
|
|
|
if (reverb <= 10)
|
|
|
|
_music->setGlobalReverb(reverb);
|
|
|
|
}
|
2010-11-24 14:21:31 +00:00
|
|
|
|
2010-11-24 16:01:30 +00:00
|
|
|
return make_reg(0, prevReverb);
|
SCI/new music code:
- Resolved a deadlock with the mixer, and added appropriate mutexes (a result of the fact that SCI mixes MIDI and digital audio in the same list)
- Fixed sound playing when loading games, by properly resetting the MIDI driver
- Reverted savegame version to 14 - the changes in versions 15 and 16 don't have any effect on the currently enabled old music code, and the new music code is disabled by default, and is still prone to changes
- Now saving/loading signal, loop and hold for each sound, as well as reverb
- Added stub code for setting reverb and channel hold
- The signal, loop and hold values of each song are cached, like in SSCI and like what happens in Greg's SCI implementation. This allows a clear separation of the engine code from the rest of the engine. Reverted commits 46792 and 46797
- Removed duplicate song list accessing code
- Song cues are now updated in kAnimate for SCI0, like the old music code does, to compensate for the fact that SCI0 didn't poll for music changes via cmdUpdateCues, like what SCI01 and newer do
- Cleanup
svn-id: r46812
2010-01-01 06:41:52 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundSetHold(EngineState *s, int argc, reg_t *argv) {
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t obj = argv[0];
|
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "doSoundSetHold: %04x:%04x, %d", PRINT_REG(argv[0]), argv[1].toUint16());
|
2010-07-29 10:58:01 +00:00
|
|
|
|
SCI/new music code:
- Resolved a deadlock with the mixer, and added appropriate mutexes (a result of the fact that SCI mixes MIDI and digital audio in the same list)
- Fixed sound playing when loading games, by properly resetting the MIDI driver
- Reverted savegame version to 14 - the changes in versions 15 and 16 don't have any effect on the currently enabled old music code, and the new music code is disabled by default, and is still prone to changes
- Now saving/loading signal, loop and hold for each sound, as well as reverb
- Added stub code for setting reverb and channel hold
- The signal, loop and hold values of each song are cached, like in SSCI and like what happens in Greg's SCI implementation. This allows a clear separation of the engine code from the rest of the engine. Reverted commits 46792 and 46797
- Removed duplicate song list accessing code
- Song cues are now updated in kAnimate for SCI0, like the old music code does, to compensate for the fact that SCI0 didn't poll for music changes via cmdUpdateCues, like what SCI01 and newer do
- Cleanup
svn-id: r46812
2010-01-01 06:41:52 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(setHold): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
SCI/new music code:
- Resolved a deadlock with the mixer, and added appropriate mutexes (a result of the fact that SCI mixes MIDI and digital audio in the same list)
- Fixed sound playing when loading games, by properly resetting the MIDI driver
- Reverted savegame version to 14 - the changes in versions 15 and 16 don't have any effect on the currently enabled old music code, and the new music code is disabled by default, and is still prone to changes
- Now saving/loading signal, loop and hold for each sound, as well as reverb
- Added stub code for setting reverb and channel hold
- The signal, loop and hold values of each song are cached, like in SSCI and like what happens in Greg's SCI implementation. This allows a clear separation of the engine code from the rest of the engine. Reverted commits 46792 and 46797
- Removed duplicate song list accessing code
- Song cues are now updated in kAnimate for SCI0, like the old music code does, to compensate for the fact that SCI0 didn't poll for music changes via cmdUpdateCues, like what SCI01 and newer do
- Cleanup
svn-id: r46812
2010-01-01 06:41:52 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 15:37:17 +00:00
|
|
|
// Set the special hold marker ID where the song should be looped at.
|
2010-07-09 12:06:41 +00:00
|
|
|
musicSlot->hold = argv[1].toSint16();
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundGetAudioCapability(EngineState *s, int argc, reg_t *argv) {
|
2009-11-12 15:24:11 +00:00
|
|
|
// Tests for digital audio support
|
2010-07-09 12:06:41 +00:00
|
|
|
return make_reg(0, 1);
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundStopAll(EngineState *s, int argc, reg_t *argv) {
|
2010-07-19 22:11:06 +00:00
|
|
|
// TODO: this can't be right, this gets called in kq1 - e.g. being in witch house, getting the note
|
|
|
|
// now the point jingle plays and after a messagebox they call this - and would stop the background effects with it
|
|
|
|
// this doesn't make sense, so i disable it for now
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2010-07-19 22:11:06 +00:00
|
|
|
|
2017-09-10 22:01:33 -05:00
|
|
|
#if 0
|
SCI/new music code:
- Resolved a deadlock with the mixer, and added appropriate mutexes (a result of the fact that SCI mixes MIDI and digital audio in the same list)
- Fixed sound playing when loading games, by properly resetting the MIDI driver
- Reverted savegame version to 14 - the changes in versions 15 and 16 don't have any effect on the currently enabled old music code, and the new music code is disabled by default, and is still prone to changes
- Now saving/loading signal, loop and hold for each sound, as well as reverb
- Added stub code for setting reverb and channel hold
- The signal, loop and hold values of each song are cached, like in SSCI and like what happens in Greg's SCI implementation. This allows a clear separation of the engine code from the rest of the engine. Reverted commits 46792 and 46797
- Removed duplicate song list accessing code
- Song cues are now updated in kAnimate for SCI0, like the old music code does, to compensate for the fact that SCI0 didn't poll for music changes via cmdUpdateCues, like what SCI01 and newer do
- Cleanup
svn-id: r46812
2010-01-01 06:41:52 +00:00
|
|
|
Common::StackLock(_music->_mutex);
|
|
|
|
|
|
|
|
const MusicList::iterator end = _music->getPlayListEnd();
|
|
|
|
for (MusicList::iterator i = _music->getPlayListStart(); i != end; ++i) {
|
2010-01-29 19:02:13 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE) {
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, (*i)->soundObj, SELECTOR(state), kSoundStopped);
|
2010-01-29 19:02:13 +00:00
|
|
|
} else {
|
2010-07-09 12:06:41 +00:00
|
|
|
writeSelectorValue(_segMan, (*i)->soundObj, SELECTOR(handle), 0);
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, (*i)->soundObj, SELECTOR(signal), SIGNAL_OFFSET);
|
2010-01-29 17:45:30 +00:00
|
|
|
}
|
SCI/new music code:
- Resolved a deadlock with the mixer, and added appropriate mutexes (a result of the fact that SCI mixes MIDI and digital audio in the same list)
- Fixed sound playing when loading games, by properly resetting the MIDI driver
- Reverted savegame version to 14 - the changes in versions 15 and 16 don't have any effect on the currently enabled old music code, and the new music code is disabled by default, and is still prone to changes
- Now saving/loading signal, loop and hold for each sound, as well as reverb
- Added stub code for setting reverb and channel hold
- The signal, loop and hold values of each song are cached, like in SSCI and like what happens in Greg's SCI implementation. This allows a clear separation of the engine code from the rest of the engine. Reverted commits 46792 and 46797
- Removed duplicate song list accessing code
- Song cues are now updated in kAnimate for SCI0, like the old music code does, to compensate for the fact that SCI0 didn't poll for music changes via cmdUpdateCues, like what SCI01 and newer do
- Cleanup
svn-id: r46812
2010-01-01 06:41:52 +00:00
|
|
|
|
|
|
|
(*i)->dataInc = 0;
|
|
|
|
_music->soundStop(*i);
|
|
|
|
}
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2017-09-10 22:01:33 -05:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundSetVolume(EngineState *s, int argc, reg_t *argv) {
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t obj = argv[0];
|
|
|
|
int16 value = argv[1].toSint16();
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-25 01:39:44 +00:00
|
|
|
// Do not throw a warning if the sound can't be found, as in some games
|
2010-06-29 20:50:52 +00:00
|
|
|
// this is called before the actual sound is loaded (e.g. SQ4CD, with
|
|
|
|
// the drum sounds of the energizer bunny at the beginning), so this is
|
|
|
|
// normal behavior.
|
2010-01-03 13:28:59 +00:00
|
|
|
//warning("cmdSetSoundVolume: Slot not found (%04x:%04x)", PRINT_REG(obj));
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-12-20 14:27:43 +00:00
|
|
|
}
|
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(setVolume): %d", value);
|
2010-01-01 17:53:37 +00:00
|
|
|
|
2010-01-01 21:04:20 +00:00
|
|
|
value = CLIP<int>(value, 0, MUSIC_VOLUME_MAX);
|
2009-12-25 14:02:28 +00:00
|
|
|
|
2016-03-18 22:55:56 -05:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
// SSCI unconditionally sets volume if it is digital audio
|
|
|
|
if (_soundVersion >= SCI_VERSION_2_1_EARLY && musicSlot->isSample) {
|
2017-10-06 13:15:16 -05:00
|
|
|
g_sci->_audio32->setVolume(ResourceId(kResourceTypeAudio, musicSlot->resourceId), musicSlot->soundObj, value);
|
|
|
|
}
|
2016-03-18 22:55:56 -05:00
|
|
|
#endif
|
2009-12-27 11:43:34 +00:00
|
|
|
if (musicSlot->volume != value) {
|
|
|
|
musicSlot->volume = value;
|
|
|
|
_music->soundSetVolume(musicSlot, value);
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(vol), value);
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
g_sci->_guestAdditions->kDoSoundSetVolumeHook(obj, value);
|
|
|
|
#endif
|
2009-11-29 14:48:15 +00:00
|
|
|
}
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
|
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundSetPriority(EngineState *s, int argc, reg_t *argv) {
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t obj = argv[0];
|
|
|
|
int16 value = argv[1].toSint16();
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(setPriority): %04x:%04x, %d", PRINT_REG(obj), value);
|
2010-07-29 10:58:01 +00:00
|
|
|
|
2010-01-02 01:41:39 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(setPriority): Slot not found (%04x:%04x)", PRINT_REG(obj));
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2010-01-02 01:41:39 +00:00
|
|
|
}
|
|
|
|
|
2009-12-22 13:31:52 +00:00
|
|
|
if (value == -1) {
|
2015-02-14 15:20:23 +01:00
|
|
|
musicSlot->overridePriority = false;
|
|
|
|
musicSlot->priority = 0;
|
2010-11-25 14:22:09 +00:00
|
|
|
|
2015-02-14 15:20:23 +01:00
|
|
|
// NB: It seems SSCI doesn't actually reset the priority here.
|
2010-01-02 01:41:39 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) & 0xFD);
|
2009-12-20 14:27:43 +00:00
|
|
|
} else {
|
2010-01-02 01:41:39 +00:00
|
|
|
// Scripted priority
|
2015-02-14 15:20:23 +01:00
|
|
|
musicSlot->overridePriority = true;
|
2010-01-02 01:41:39 +00:00
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | 2);
|
2015-02-14 15:20:23 +01:00
|
|
|
|
|
|
|
_music->soundSetPriority(musicSlot, value);
|
2009-11-29 14:48:15 +00:00
|
|
|
}
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundSetLoop(EngineState *s, int argc, reg_t *argv) {
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t obj = argv[0];
|
|
|
|
int16 value = argv[1].toSint16();
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(setLoop): %04x:%04x, %d", PRINT_REG(obj), value);
|
2010-07-29 10:58:01 +00:00
|
|
|
|
2017-06-18 00:36:46 -05:00
|
|
|
const uint16 loopCount = value == -1 ? 0xFFFF : 1;
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(loop), loopCount);
|
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
// Apparently, it's perfectly normal for a game to call cmdSetSoundLoop
|
|
|
|
// before actually initializing the sound and adding it to the playlist
|
|
|
|
// with cmdInitSound. Usually, it doesn't matter if the game doesn't
|
|
|
|
// request to loop the sound, so in this case, don't throw any warning,
|
2010-06-29 20:50:52 +00:00
|
|
|
// otherwise do, because the sound won't be looped.
|
2010-01-02 01:09:49 +00:00
|
|
|
if (value == -1) {
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(setLoop): Slot not found (%04x:%04x) and the song was requested to be looped", PRINT_REG(obj));
|
2010-01-02 01:09:49 +00:00
|
|
|
} else {
|
|
|
|
// Doesn't really matter
|
|
|
|
}
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
2016-03-18 22:55:56 -05:00
|
|
|
|
|
|
|
#ifdef ENABLE_SCI32
|
2017-06-16 16:32:16 -05:00
|
|
|
if (_soundVersion >= SCI_VERSION_2_1_MIDDLE && musicSlot->isSample) {
|
2016-03-18 22:55:56 -05:00
|
|
|
g_sci->_audio32->setLoop(ResourceId(kResourceTypeAudio, musicSlot->resourceId), musicSlot->soundObj, value == -1);
|
2017-06-16 16:32:16 -05:00
|
|
|
} else
|
2016-03-18 22:55:56 -05:00
|
|
|
#endif
|
2017-06-16 16:32:16 -05:00
|
|
|
musicSlot->loop = loopCount;
|
2016-03-18 22:55:56 -05:00
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
reg_t SoundCommandParser::kDoSoundSuspend(EngineState *s, int argc, reg_t *argv) {
|
2009-11-12 15:24:11 +00:00
|
|
|
// TODO
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(suspend): STUB");
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
return s->r_acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-01 16:05:26 +00:00
|
|
|
void SoundCommandParser::updateSci0Cues() {
|
2010-05-19 21:10:43 +00:00
|
|
|
bool noOnePlaying = true;
|
|
|
|
MusicEntry *pWaitingForPlay = NULL;
|
|
|
|
|
2010-01-01 16:05:26 +00:00
|
|
|
const MusicList::iterator end = _music->getPlayListEnd();
|
|
|
|
for (MusicList::iterator i = _music->getPlayListStart(); i != end; ++i) {
|
2010-01-02 19:01:34 +00:00
|
|
|
// Is the sound stopped, and the sound object updated too? If yes, skip
|
2010-06-29 20:50:52 +00:00
|
|
|
// this sound, as SCI0 only allows one active song.
|
2010-05-23 13:22:58 +00:00
|
|
|
if ((*i)->isQueued) {
|
2010-05-19 21:10:43 +00:00
|
|
|
pWaitingForPlay = (*i);
|
2010-06-29 20:50:52 +00:00
|
|
|
// FIXME(?): In iceman 2 songs are queued when playing the door
|
|
|
|
// sound - if we use the first song for resuming then it's the wrong
|
|
|
|
// one. Both songs have same priority. Maybe the new sound function
|
|
|
|
// in sci0 is somehow responsible.
|
2010-05-19 21:10:43 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-01-02 19:01:34 +00:00
|
|
|
if ((*i)->signal == 0 && (*i)->status != kSoundPlaying)
|
|
|
|
continue;
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
processUpdateCues((*i)->soundObj);
|
2010-05-19 21:10:43 +00:00
|
|
|
noOnePlaying = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (noOnePlaying && pWaitingForPlay) {
|
2013-04-28 23:30:03 +03:00
|
|
|
// If there is a queued entry, play it now - check SciMusic::soundPlay()
|
2010-05-19 21:10:43 +00:00
|
|
|
pWaitingForPlay->isQueued = false;
|
|
|
|
_music->soundPlay(pWaitingForPlay);
|
2010-01-01 16:05:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-28 20:10:15 +00:00
|
|
|
void SoundCommandParser::clearPlayList() {
|
|
|
|
_music->clearPlayList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundCommandParser::printPlayList(Console *con) {
|
|
|
|
_music->printPlayList(con);
|
|
|
|
}
|
|
|
|
|
2010-01-23 14:39:03 +00:00
|
|
|
void SoundCommandParser::printSongInfo(reg_t obj, Console *con) {
|
|
|
|
_music->printSongInfo(obj, con);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundCommandParser::stopAllSounds() {
|
|
|
|
_music->stopAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundCommandParser::startNewSound(int number) {
|
2014-10-07 19:48:18 +02:00
|
|
|
// NB: This is only used by the debugging console.
|
|
|
|
|
2010-01-23 14:39:03 +00:00
|
|
|
Common::StackLock lock(_music->_mutex);
|
|
|
|
|
|
|
|
// Overwrite the first sound in the playlist
|
|
|
|
MusicEntry *song = *_music->getPlayListStart();
|
|
|
|
reg_t soundObj = song->soundObj;
|
2010-07-09 12:06:41 +00:00
|
|
|
processDisposeSound(soundObj);
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, soundObj, SELECTOR(number), number);
|
2010-07-09 12:06:41 +00:00
|
|
|
processInitSound(soundObj);
|
2014-10-07 19:48:18 +02:00
|
|
|
processPlaySound(soundObj, false);
|
2010-01-23 14:39:03 +00:00
|
|
|
}
|
|
|
|
|
2010-01-12 00:51:37 +00:00
|
|
|
void SoundCommandParser::setMasterVolume(int vol) {
|
2010-09-01 19:20:17 +00:00
|
|
|
// 0...15
|
2010-01-12 00:51:37 +00:00
|
|
|
_music->soundSetMasterVolume(vol);
|
|
|
|
}
|
|
|
|
|
SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.
1. Fixes audio volumes syncing erroneously to ScummVM in games
that modify the audio volume without user action (e.g. SCI1.1
talkies that reduce music volume during speech playback). Now,
volumes will only be synchronised when the user interacts with
the game's audio settings. This mechanism works by looking for
a known volume control object in the stack, and only syncing
when the control object is present. (Ports and planes were
researched and found unreliable.)
2. Fixes audio syncing in SCI32 games that do not set game
volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
GK2, Phant1, and Torin.
3. Fixes speech/subtitles syncing in SCI32 games that do not use
global 90, like LSL6hires.
4. Fixes in-game volume controls in SCI32 games reflecting
outdated audio volumes when a change is made during the game
from the ScummVM launcher.
5. Fixes SCI32 games that would restore volumes from save games
or reset volumes on startup, which caused game volumes to be
out-of-sync with ScummVM when started.
6. ScummVM integration code for audio sync has been abstracted
into a new GuestAdditions class. This keeps the ScummVM-
specific code all in one place, with only small hooks into the
engine code. ScummVM integrated save/load code should probably
also go here in the future.
Fixes Trac#9700.
2017-01-26 13:18:41 -06:00
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
void SoundCommandParser::setVolume(const reg_t obj, const int volume) {
|
|
|
|
MusicEntry *slot = _music->getSlot(obj);
|
|
|
|
if (slot != nullptr) {
|
|
|
|
slot->volume = volume;
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(vol), volume);
|
|
|
|
_music->soundSetVolume(slot, volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-21 21:28:32 +00:00
|
|
|
void SoundCommandParser::pauseAll(bool pause) {
|
|
|
|
_music->pauseAll(pause);
|
|
|
|
}
|
|
|
|
|
2010-09-02 21:50:00 +00:00
|
|
|
MusicType SoundCommandParser::getMusicType() const {
|
|
|
|
assert(_music);
|
|
|
|
return _music->soundGetMusicType();
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:24:11 +00:00
|
|
|
} // End of namespace Sci
|