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"
|
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"
|
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
|
2012-03-31 13:55:03 +03:00
|
|
|
_useDigitalSFX = (getSciVersion() >= SCI_VERSION_2 || g_sci->getGameId() == GID_GK1 || 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
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundInit(int argc, reg_t *argv, reg_t acc) {
|
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]);
|
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2011-08-25 02:52:58 +03:00
|
|
|
int SoundCommandParser::getSoundResourceId(reg_t obj) {
|
2012-06-18 05:21:59 +03:00
|
|
|
int resourceId = obj.getSegment() ? 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
bool checkAudioResource = getSciVersion() >= SCI_VERSION_1_1;
|
2011-10-20 19:02:15 +03:00
|
|
|
// Hoyle 4 has garbled audio resources in place of the sound resources.
|
2012-03-05 12:14:54 -05:00
|
|
|
if (g_sci->getGameId() == GID_HOYLE4)
|
2011-10-20 19:02:15 +03:00
|
|
|
checkAudioResource = false;
|
2011-09-26 19:57:50 +03:00
|
|
|
|
|
|
|
if (checkAudioResource && _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;
|
|
|
|
newSound->pStreamAud = _audio->getAudioStream(newSound->resourceId, 65535, &sampleLen);
|
2012-08-20 03:22:56 +03:00
|
|
|
newSound->soundType = Audio::Mixer::kSFXSoundType;
|
2011-09-26 19:57:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!newSound->pStreamAud && newSound->soundRes)
|
|
|
|
_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));
|
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);
|
|
|
|
|
2010-01-03 21:51:30 +00:00
|
|
|
if (newSound->soundRes || newSound->pStreamAud) {
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundPlay(int argc, reg_t *argv, reg_t acc) {
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(play): %04x:%04x", PRINT_REG(argv[0]));
|
2010-07-09 12:06:41 +00:00
|
|
|
processPlaySound(argv[0]);
|
|
|
|
return acc;
|
|
|
|
}
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
void SoundCommandParser::processPlaySound(reg_t obj) {
|
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));
|
|
|
|
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;
|
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
|
|
|
|
2011-01-01 12:48:12 +00:00
|
|
|
debugC(kDebugLevelSound, "kDoSound(play): %04x:%04x number %d, loop %d, prio %d, vol %d", PRINT_REG(obj),
|
2010-07-18 16:02:16 +00:00
|
|
|
resourceId, musicSlot->loop, musicSlot->priority, musicSlot->volume);
|
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
|
|
|
}
|
|
|
|
|
2010-08-02 21:20:43 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundRestore(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
// Called after loading, to restore the playlist
|
|
|
|
// We don't really use or need this
|
|
|
|
return acc;
|
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundDummy(int argc, reg_t *argv, reg_t acc) {
|
2009-11-12 15:24:11 +00:00
|
|
|
warning("cmdDummy invoked"); // not supposed to occur
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundDispose(int argc, reg_t *argv, reg_t acc) {
|
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]);
|
|
|
|
return acc;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundStop(int argc, reg_t *argv, reg_t acc) {
|
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);
|
|
|
|
return 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
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundPause(int argc, reg_t *argv, reg_t acc) {
|
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];
|
|
|
|
uint16 value = argc > 1 ? argv[1].toUint16() : 0;
|
2012-06-18 05:21:59 +03:00
|
|
|
if (!obj.getSegment()) { // pause the whole playlist
|
2010-01-21 21:28:32 +00:00
|
|
|
_music->pauseAll(value);
|
|
|
|
} else { // pause a playlist slot
|
|
|
|
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));
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-12-28 22:35:53 +00:00
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2010-07-09 18:11:42 +00:00
|
|
|
_music->soundToggle(musicSlot, value);
|
2010-01-21 21:28:32 +00:00
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
return 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
|
|
|
|
reg_t SoundCommandParser::kDoSoundResumeAfterRestore(int argc, reg_t *argv, reg_t acc) {
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundMute(int argc, reg_t *argv, reg_t acc) {
|
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
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundMasterVolume(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
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);
|
|
|
|
vol = vol * Audio::Mixer::kMaxMixerVolume / MUSIC_MASTERVOLUME_MAX;
|
2010-01-12 00:51:37 +00:00
|
|
|
ConfMan.setInt("music_volume", vol);
|
|
|
|
ConfMan.setInt("sfx_volume", vol);
|
|
|
|
g_engine->syncSoundSettings();
|
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundFade(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
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)
|
|
|
|
return acc;
|
|
|
|
|
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));
|
2010-07-09 12:06:41 +00:00
|
|
|
return 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
|
|
|
|
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);
|
2010-07-09 12:06:41 +00:00
|
|
|
return 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)
|
|
|
|
return acc;
|
|
|
|
|
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,
|
2013-04-06 22:11:07 +02: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);
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundGetPolyphony(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
return make_reg(0, _music->soundGetVoices()); // Get the number of voices
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundUpdate(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
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));
|
2010-07-09 12:06:41 +00:00
|
|
|
return 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);
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundUpdateCues(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
processUpdateCues(argv[0]);
|
|
|
|
return acc;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
if (musicSlot->pStreamAud) {
|
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);
|
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(frame), musicSlot->ticker);
|
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
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundSendMidi(int argc, reg_t *argv, reg_t acc) {
|
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();
|
|
|
|
|
|
|
|
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));
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2010-06-17 11:54:54 +00:00
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
_music->sendMidiCommand(musicSlot, midiCommand);
|
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 14:21:31 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundGlobalReverb(int argc, reg_t *argv, reg_t acc) {
|
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
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundSetHold(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
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));
|
2010-07-09 12:06:41 +00:00
|
|
|
return 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();
|
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundGetAudioCapability(int argc, reg_t *argv, reg_t acc) {
|
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
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundStopAll(int argc, reg_t *argv, reg_t acc) {
|
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
|
|
|
|
return 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
|
|
|
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);
|
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundSetVolume(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
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));
|
2010-07-09 12:06:41 +00:00
|
|
|
return 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
|
|
|
|
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);
|
2009-11-29 14:48:15 +00:00
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundSetPriority(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
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));
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2010-01-02 01:41:39 +00:00
|
|
|
}
|
|
|
|
|
2009-12-22 13:31:52 +00:00
|
|
|
if (value == -1) {
|
2011-08-25 02:52:58 +03:00
|
|
|
uint16 resourceId = musicSlot->resourceId;
|
2010-11-25 14:22:09 +00:00
|
|
|
|
2010-01-02 01:41:39 +00:00
|
|
|
// Set priority from the song data
|
2011-08-25 02:52:58 +03:00
|
|
|
Resource *song = _resMan->findResource(ResourceId(kResourceTypeSound, resourceId), 0);
|
2010-01-02 01:41:39 +00:00
|
|
|
if (song->data[0] == 0xf0)
|
|
|
|
_music->soundSetPriority(musicSlot, song->data[1]);
|
|
|
|
else
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(setPriority): Attempt to unset song priority when there is no built-in value");
|
2010-01-02 01:41:39 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
//pSnd->prio=0;field_15B=0
|
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
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
//pSnd->field_15B=1;
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | 2);
|
2009-12-20 14:27:43 +00:00
|
|
|
//DoSOund(0xF,hobj,w)
|
2009-11-29 14:48:15 +00:00
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundSetLoop(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
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
|
|
|
|
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
|
|
|
|
}
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
2009-12-23 16:33:12 +00:00
|
|
|
if (value == -1) {
|
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->loop = 0xFFFF;
|
2009-12-23 16:33:12 +00:00
|
|
|
} else {
|
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->loop = 1; // actually plays the music once
|
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
|
|
|
|
2010-05-29 23:37:15 +00:00
|
|
|
writeSelectorValue(_segMan, obj, SELECTOR(loop), musicSlot->loop);
|
2010-07-09 12:06:41 +00:00
|
|
|
return acc;
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 12:06:41 +00:00
|
|
|
reg_t SoundCommandParser::kDoSoundSuspend(int argc, reg_t *argv, reg_t acc) {
|
2009-11-12 15:24:11 +00:00
|
|
|
// TODO
|
2010-07-10 13:19:20 +00:00
|
|
|
warning("kDoSound(suspend): STUB");
|
2010-07-09 12:06:41 +00:00
|
|
|
return 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) {
|
|
|
|
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);
|
|
|
|
processPlaySound(soundObj);
|
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);
|
|
|
|
}
|
|
|
|
|
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
|