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.
|
|
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#include "sci/sci.h" // for USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
|
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-12-20 13:38:13 +00:00
|
|
|
#include "sci/sfx/iterator/iterator.h" // for SongIteratorStatus
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
|
|
|
|
2009-11-15 14:14:49 +00:00
|
|
|
#include "sci/sfx/music.h"
|
2009-11-12 15:24:11 +00:00
|
|
|
#include "sci/sfx/soundcmd.h"
|
|
|
|
|
|
|
|
namespace Sci {
|
|
|
|
|
|
|
|
#define SCI1_SOUND_FLAG_MAY_PAUSE 1 /* Only here for completeness; The interpreter doesn't touch this bit */
|
|
|
|
#define SCI1_SOUND_FLAG_SCRIPTED_PRI 2 /* but does touch this */
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-11-12 15:24:11 +00:00
|
|
|
#define FROBNICATE_HANDLE(reg) ((reg).segment << 16 | (reg).offset)
|
|
|
|
#define DEFROBNICATE_HANDLE(handle) (make_reg((handle >> 16) & 0xffff, handle & 0xffff))
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#define SOUNDCOMMAND(x) _soundCommands.push_back(new MusicEntryCommand(#x, &SoundCommandParser::x))
|
|
|
|
|
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-11-12 15:24:11 +00:00
|
|
|
static void script_set_priority(ResourceManager *resMan, SegManager *segMan, SfxState *state, reg_t obj, int priority) {
|
|
|
|
int song_nr = GET_SEL32V(segMan, obj, number);
|
|
|
|
Resource *song = resMan->findResource(ResourceId(kResourceTypeSound, song_nr), 0);
|
|
|
|
int flags = GET_SEL32V(segMan, obj, flags);
|
|
|
|
|
|
|
|
if (priority == -1) {
|
|
|
|
if (song->data[0] == 0xf0)
|
|
|
|
priority = song->data[1];
|
|
|
|
else
|
|
|
|
warning("Attempt to unset song priority when there is no built-in value");
|
|
|
|
|
|
|
|
flags &= ~SCI1_SOUND_FLAG_SCRIPTED_PRI;
|
|
|
|
} else flags |= SCI1_SOUND_FLAG_SCRIPTED_PRI;
|
|
|
|
|
|
|
|
state->sfx_song_renice(FROBNICATE_HANDLE(obj), priority);
|
|
|
|
PUT_SEL32V(segMan, obj, flags, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
SongIterator *build_iterator(ResourceManager *resMan, int song_nr, SongIteratorType type, songit_id_t id) {
|
|
|
|
Resource *song = resMan->findResource(ResourceId(kResourceTypeSound, song_nr), 0);
|
|
|
|
|
|
|
|
if (!song)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return songit_new(song->data, song->size, type, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void process_sound_events(EngineState *s) { /* Get all sound events, apply their changes to the heap */
|
|
|
|
int result;
|
|
|
|
SongHandle handle;
|
|
|
|
int cue;
|
|
|
|
SegManager *segMan = s->_segMan;
|
|
|
|
|
|
|
|
if (getSciVersion() > SCI_VERSION_01)
|
|
|
|
return;
|
|
|
|
// SCI1 and later explicitly poll for everything
|
|
|
|
|
|
|
|
while ((result = s->_sound.sfx_poll(&handle, &cue))) {
|
|
|
|
reg_t obj = DEFROBNICATE_HANDLE(handle);
|
|
|
|
if (!s->_segMan->isObject(obj)) {
|
|
|
|
warning("Non-object %04x:%04x received sound signal (%d/%d)", PRINT_REG(obj), result, cue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
|
|
|
|
case SI_LOOP:
|
|
|
|
debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x looped (to %d)\n",
|
|
|
|
PRINT_REG(obj), cue);
|
|
|
|
/* PUT_SEL32V(segMan, obj, loops, GET_SEL32V(segMan, obj, loop) - 1);*/
|
|
|
|
PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_RELATIVE_CUE:
|
|
|
|
debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received relative cue %d\n",
|
|
|
|
PRINT_REG(obj), cue);
|
|
|
|
PUT_SEL32V(segMan, obj, signal, cue + 0x7f);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_ABSOLUTE_CUE:
|
|
|
|
debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received absolute cue %d\n",
|
|
|
|
PRINT_REG(obj), cue);
|
|
|
|
PUT_SEL32V(segMan, obj, signal, cue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_FINISHED:
|
|
|
|
debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x finished\n",
|
|
|
|
PRINT_REG(obj));
|
|
|
|
PUT_SEL32V(segMan, obj, signal, SIGNAL_OFFSET);
|
2009-12-28 20:58:00 +00:00
|
|
|
PUT_SEL32V(segMan, obj, state, kSoundStopped);
|
2009-11-12 15:24:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
warning("Unexpected result from sfx_poll: %d", result);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-12-25 13:13:42 +00:00
|
|
|
SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segMan, AudioPlayer *audio, SciVersion soundVersion) :
|
|
|
|
_resMan(resMan), _segMan(segMan), _audio(audio), _soundVersion(soundVersion) {
|
2009-12-20 13:38:13 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-12-20 13:38:13 +00:00
|
|
|
// The following hack is needed to ease the change from old to new sound code (because the new sound code does not use SfxState)
|
|
|
|
_state = &((SciEngine *)g_engine)->getEngineState()->_sound; // HACK
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2009-12-03 22:24:29 +00:00
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
2010-01-03 13:28:59 +00:00
|
|
|
_music = new SciMusic(_soundVersion);
|
2009-12-03 22:24:29 +00:00
|
|
|
_music->init();
|
|
|
|
#endif
|
2009-11-15 14:14:49 +00:00
|
|
|
|
2009-12-25 13:13:42 +00:00
|
|
|
switch (_soundVersion) {
|
2009-11-12 15:24:11 +00:00
|
|
|
case SCI_VERSION_0_EARLY:
|
2009-12-25 18:15:16 +00:00
|
|
|
case SCI_VERSION_0_LATE:
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdInitSound);
|
|
|
|
SOUNDCOMMAND(cmdPlaySound);
|
2009-11-12 15:24:11 +00:00
|
|
|
SOUNDCOMMAND(cmdDummy);
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdDisposeSound);
|
2009-11-12 15:24:11 +00:00
|
|
|
SOUNDCOMMAND(cmdMuteSound);
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdStopSound);
|
|
|
|
SOUNDCOMMAND(cmdPauseSound);
|
|
|
|
SOUNDCOMMAND(cmdResumeSound);
|
|
|
|
SOUNDCOMMAND(cmdMasterVolume);
|
|
|
|
SOUNDCOMMAND(cmdUpdateSound);
|
|
|
|
SOUNDCOMMAND(cmdFadeSound);
|
2009-11-12 15:24:11 +00:00
|
|
|
SOUNDCOMMAND(cmdGetPolyphony);
|
2009-12-27 23:46:11 +00:00
|
|
|
SOUNDCOMMAND(cmdStopAllSounds);
|
2009-11-12 15:24:11 +00:00
|
|
|
break;
|
|
|
|
case SCI_VERSION_1_EARLY:
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdMasterVolume);
|
2009-11-12 15:24:11 +00:00
|
|
|
SOUNDCOMMAND(cmdMuteSound);
|
|
|
|
SOUNDCOMMAND(cmdDummy);
|
|
|
|
SOUNDCOMMAND(cmdGetPolyphony);
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdUpdateSound);
|
|
|
|
SOUNDCOMMAND(cmdInitSound);
|
|
|
|
SOUNDCOMMAND(cmdDisposeSound);
|
|
|
|
SOUNDCOMMAND(cmdPlaySound);
|
|
|
|
SOUNDCOMMAND(cmdStopSound);
|
|
|
|
SOUNDCOMMAND(cmdPauseSound);
|
|
|
|
SOUNDCOMMAND(cmdFadeSound);
|
2009-11-12 15:24:11 +00:00
|
|
|
SOUNDCOMMAND(cmdUpdateCues);
|
|
|
|
SOUNDCOMMAND(cmdSendMidi);
|
|
|
|
SOUNDCOMMAND(cmdReverb);
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdSetSoundHold);
|
2009-11-12 15:24:11 +00:00
|
|
|
break;
|
|
|
|
case SCI_VERSION_1_LATE:
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdMasterVolume);
|
2009-11-12 15:24:11 +00:00
|
|
|
SOUNDCOMMAND(cmdMuteSound);
|
|
|
|
SOUNDCOMMAND(cmdDummy);
|
|
|
|
SOUNDCOMMAND(cmdGetPolyphony);
|
|
|
|
SOUNDCOMMAND(cmdGetAudioCapability);
|
|
|
|
SOUNDCOMMAND(cmdSuspendSound);
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdInitSound);
|
|
|
|
SOUNDCOMMAND(cmdDisposeSound);
|
|
|
|
SOUNDCOMMAND(cmdPlaySound);
|
|
|
|
SOUNDCOMMAND(cmdStopSound);
|
|
|
|
SOUNDCOMMAND(cmdPauseSound);
|
|
|
|
SOUNDCOMMAND(cmdFadeSound);
|
|
|
|
SOUNDCOMMAND(cmdSetSoundHold);
|
2009-11-12 15:24:11 +00:00
|
|
|
SOUNDCOMMAND(cmdDummy);
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdSetSoundVolume);
|
|
|
|
SOUNDCOMMAND(cmdSetSoundPriority);
|
|
|
|
SOUNDCOMMAND(cmdSetSoundLoop);
|
2009-11-12 15:24:11 +00:00
|
|
|
SOUNDCOMMAND(cmdUpdateCues);
|
|
|
|
SOUNDCOMMAND(cmdSendMidi);
|
|
|
|
SOUNDCOMMAND(cmdReverb);
|
2010-01-02 01:09:49 +00:00
|
|
|
SOUNDCOMMAND(cmdUpdateSound);
|
2009-11-12 15:24:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-12-25 13:13:42 +00:00
|
|
|
warning("Sound command parser: unknown sound version %d", _soundVersion);
|
2009-11-12 15:24:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SoundCommandParser::~SoundCommandParser() {
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_t SoundCommandParser::parseCommand(int argc, reg_t *argv, reg_t acc) {
|
|
|
|
uint16 command = argv[0].toUint16();
|
|
|
|
reg_t obj = (argc > 1) ? argv[1] : NULL_REG;
|
2009-12-20 14:27:43 +00:00
|
|
|
int16 value = (argc > 2) ? argv[2].toSint16() : 0;
|
2009-11-12 15:24:11 +00:00
|
|
|
_acc = acc;
|
2009-11-17 06:39:28 +00:00
|
|
|
_argv = argv;
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
// cmdMuteSound and cmdMasterVolume do not operate on an object, but need the number of
|
2009-12-28 22:52:07 +00:00
|
|
|
// arguments passed. We load this in the value
|
2009-12-29 01:27:15 +00:00
|
|
|
if (!strcmp(_soundCommands[command]->desc, "cmdMuteSound") ||
|
2010-01-02 01:09:49 +00:00
|
|
|
!strcmp(_soundCommands[command]->desc, "cmdMasterVolume")) {
|
2009-12-28 22:52:07 +00:00
|
|
|
value = argc - 1; // minus the command
|
2009-12-29 01:27:15 +00:00
|
|
|
}
|
2009-12-28 22:52:07 +00:00
|
|
|
|
|
|
|
if (argc == 6) { // cmdSendMidi
|
|
|
|
byte channel = argv[2].toUint16() & 0xf;
|
2009-12-30 23:13:49 +00:00
|
|
|
byte midiCmd = argv[3].toUint16() & 0xff;
|
2009-12-28 22:52:07 +00:00
|
|
|
|
|
|
|
uint16 controller = argv[4].toUint16();
|
|
|
|
uint16 param = argv[5].toUint16();
|
|
|
|
|
|
|
|
_midiCommand = (channel | midiCmd) | ((uint32)controller << 8) | ((uint32)param << 16);
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 18:27:16 +00:00
|
|
|
if (command < _soundCommands.size()) {
|
2009-12-28 20:10:15 +00:00
|
|
|
if (strcmp(_soundCommands[command]->desc, "cmdUpdateCues")) {
|
|
|
|
//printf("%s, object %04x:%04x\n", _soundCommands[command]->desc, PRINT_REG(obj)); // debug
|
2009-12-28 22:52:07 +00:00
|
|
|
debugC(2, kDebugLevelSound, "%s, object %04x:%04x", _soundCommands[command]->desc, PRINT_REG(obj));
|
2009-12-28 20:10:15 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
(this->*(_soundCommands[command]->sndCmd))(obj, value);
|
2009-11-12 15:24:11 +00:00
|
|
|
} else {
|
|
|
|
warning("Invalid sound command requested (%d), valid range is 0-%d", command, _soundCommands.size() - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return _acc;
|
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdInitSound(reg_t obj, int16 value) {
|
2009-12-22 20:44:03 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int number = obj.segment ? GET_SEL32V(_segMan, obj, number) : 0;
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2009-11-15 14:14:49 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-11-19 08:56:05 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
|
|
|
|
2009-12-25 13:26:13 +00:00
|
|
|
if (_soundVersion != SCI_VERSION_1_LATE) {
|
2009-11-19 08:56:05 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-27 15:24:33 +00:00
|
|
|
SongIteratorType type = (_soundVersion <= SCI_VERSION_0_LATE) ? SCI_SONG_ITERATOR_TYPE_SCI0 : SCI_SONG_ITERATOR_TYPE_SCI1;
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE) {
|
2009-11-12 15:24:11 +00:00
|
|
|
if (GET_SEL32V(_segMan, obj, nodePtr)) {
|
|
|
|
_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
|
|
|
_state->sfx_remove_song(handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-20 20:32:25 +00:00
|
|
|
if (!obj.segment || !_resMan->testResource(ResourceId(kResourceTypeSound, number)))
|
|
|
|
return;
|
2009-11-12 15:24:11 +00:00
|
|
|
|
|
|
|
_state->sfx_add_song(build_iterator(_resMan, number, type, handle), 0, handle, number);
|
|
|
|
|
2009-12-31 08:10:51 +00:00
|
|
|
#else
|
2009-11-15 14:14:49 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
MusicEntry *newSound = new MusicEntry();
|
2009-12-22 20:44:03 +00:00
|
|
|
newSound->resnum = number;
|
|
|
|
if (number && _resMan->testResource(ResourceId(kResourceTypeSound, number)))
|
2009-12-25 13:13:42 +00:00
|
|
|
newSound->soundRes = new SoundResource(number, _resMan, _soundVersion);
|
2010-01-03 18:06:48 +00:00
|
|
|
else
|
|
|
|
newSound->soundRes = 0;
|
2010-01-03 21:17:58 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
newSound->soundObj = obj;
|
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
|
|
|
newSound->loop = GET_SEL32V(_segMan, obj, loop);
|
2009-12-20 14:27:43 +00:00
|
|
|
newSound->prio = GET_SEL32V(_segMan, obj, pri) & 0xFF;
|
2010-01-02 08:15:01 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_LATE)
|
|
|
|
newSound->volume = CLIP<int>(GET_SEL32V(_segMan, obj, vol), 0, MUSIC_VOLUME_MAX);
|
2009-12-28 20:10:15 +00:00
|
|
|
|
|
|
|
// Check if a track with the same sound object is already playing
|
|
|
|
MusicEntry *oldSound = _music->getSlot(obj);
|
|
|
|
if (oldSound)
|
2010-01-02 01:09:49 +00:00
|
|
|
cmdDisposeSound(obj, value);
|
2009-12-28 20:10:15 +00:00
|
|
|
|
2009-12-22 20:44:03 +00:00
|
|
|
// 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)
|
|
|
|
|
2010-01-01 14:41:11 +00:00
|
|
|
if (getSciVersion() >= SCI_VERSION_1_1 && _resMan->testResource(ResourceId(kResourceTypeAudio, number))) {
|
2009-12-22 20:44:03 +00:00
|
|
|
// Found a relevant audio resource, play it
|
|
|
|
int sampleLen;
|
|
|
|
newSound->pStreamAud = _audio->getAudioStream(number, 65535, &sampleLen);
|
2010-01-01 18:57:14 +00:00
|
|
|
newSound->soundType = Audio::Mixer::kSpeechSoundType;
|
2009-12-22 20:44:03 +00:00
|
|
|
} else {
|
2010-01-03 21:17:58 +00:00
|
|
|
// If sound resource doesnt exist, we are supposed to leave nodePtr/handle selector alone
|
|
|
|
// otherwise character selection music in qfg1vga wont work.
|
|
|
|
if (!newSound->soundRes)
|
|
|
|
return;
|
|
|
|
_music->soundInitSnd(newSound);
|
2009-12-22 20:44:03 +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
|
|
|
|
|
|
|
_music->pushBackSlot(newSound);
|
|
|
|
|
2009-11-15 14:14:49 +00:00
|
|
|
#endif
|
2009-12-31 08:10:51 +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
|
|
|
// Notify the engine
|
2009-12-31 08:10:51 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
|
|
|
PUT_SEL32V(_segMan, obj, state, kSoundInitialized);
|
|
|
|
else
|
|
|
|
PUT_SEL32(_segMan, obj, nodePtr, obj);
|
|
|
|
|
|
|
|
PUT_SEL32(_segMan, obj, handle, obj);
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdPlaySound(reg_t obj, int16 value) {
|
2009-11-12 15:24:11 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
|
|
|
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE) {
|
2009-11-17 06:39:28 +00:00
|
|
|
_state->sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
|
|
|
|
_state->sfx_song_set_loops(handle, GET_SEL32V(_segMan, obj, loop));
|
2009-12-28 20:58:00 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, state, kSoundPlaying);
|
2009-12-25 13:26:13 +00:00
|
|
|
} else if (_soundVersion == SCI_VERSION_1_EARLY) {
|
2009-11-17 06:39:28 +00:00
|
|
|
_state->sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
|
|
|
|
_state->sfx_song_set_loops(handle, GET_SEL32V(_segMan, obj, loop));
|
2009-11-12 15:24:11 +00:00
|
|
|
_state->sfx_song_renice(handle, GET_SEL32V(_segMan, obj, pri));
|
|
|
|
RESTORE_BEHAVIOR rb = (RESTORE_BEHAVIOR) value; /* Too lazy to look up a default value for this */
|
|
|
|
_state->_songlib.setSongRestoreBehavior(handle, rb);
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, 0);
|
2009-12-25 13:26:13 +00:00
|
|
|
} else if (_soundVersion == SCI_VERSION_1_LATE) {
|
2009-11-12 15:24:11 +00:00
|
|
|
int looping = GET_SEL32V(_segMan, obj, loop);
|
|
|
|
//int vol = GET_SEL32V(_segMan, obj, vol);
|
|
|
|
int pri = GET_SEL32V(_segMan, obj, pri);
|
|
|
|
int sampleLen = 0;
|
|
|
|
Song *song = _state->_songlib.findSong(handle);
|
|
|
|
int songNumber = GET_SEL32V(_segMan, obj, number);
|
|
|
|
|
|
|
|
if (GET_SEL32V(_segMan, obj, nodePtr) && (song && songNumber != song->_resourceNum)) {
|
|
|
|
_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
|
|
|
_state->sfx_remove_song(handle);
|
|
|
|
PUT_SEL32(_segMan, obj, nodePtr, NULL_REG);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GET_SEL32V(_segMan, obj, nodePtr) && obj.segment) {
|
|
|
|
// 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)
|
|
|
|
if (_resMan->testResource(ResourceId(kResourceTypeAudio, songNumber)) &&
|
|
|
|
getSciVersion() >= SCI_VERSION_1_1) {
|
|
|
|
// Found a relevant audio resource, play it
|
|
|
|
_audio->stopAudio();
|
|
|
|
warning("Initializing audio resource instead of requested sound resource %d", songNumber);
|
|
|
|
sampleLen = _audio->startAudio(65535, songNumber);
|
|
|
|
// Also create iterator, that will fire SI_FINISHED event, when the sound is done playing
|
|
|
|
_state->sfx_add_song(new_timer_iterator(sampleLen), 0, handle, songNumber);
|
|
|
|
} else {
|
|
|
|
if (!_resMan->testResource(ResourceId(kResourceTypeSound, songNumber))) {
|
|
|
|
warning("Could not open song number %d", songNumber);
|
|
|
|
// Send a "stop handle" event so that the engine won't wait forever here
|
|
|
|
_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
debugC(2, kDebugLevelSound, "Initializing song number %d\n", songNumber);
|
|
|
|
_state->sfx_add_song(build_iterator(_resMan, songNumber, SCI_SONG_ITERATOR_TYPE_SCI1,
|
|
|
|
handle), 0, handle, songNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
PUT_SEL32(_segMan, obj, nodePtr, obj);
|
|
|
|
PUT_SEL32(_segMan, obj, handle, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj.segment) {
|
|
|
|
_state->sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
|
|
|
|
_state->sfx_song_set_loops(handle, looping);
|
|
|
|
_state->sfx_song_renice(handle, pri);
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-11-29 14:48:15 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdPlaySound: Slot not found (%04x:%04x)", PRINT_REG(obj));
|
2009-12-23 16:33:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2009-12-23 16:33:12 +00:00
|
|
|
int number = obj.segment ? GET_SEL32V(_segMan, obj, number) : -1;
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
if (musicSlot->resnum != number) { // another sound loaded into struct
|
2010-01-02 01:09:49 +00:00
|
|
|
cmdDisposeSound(obj, value);
|
|
|
|
cmdInitSound(obj, value);
|
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
|
|
|
}
|
2010-01-01 13:21:30 +00:00
|
|
|
int16 loop = GET_SEL32V(_segMan, obj, loop);
|
2010-01-02 01:09:49 +00:00
|
|
|
debugC(2, kDebugLevelSound, "cmdPlaySound: resource number %d, loop %d", number, loop);
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2009-12-31 08:10:51 +00:00
|
|
|
PUT_SEL32(_segMan, obj, handle, obj);
|
|
|
|
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_EARLY) {
|
2009-12-31 08:10:51 +00:00
|
|
|
PUT_SEL32(_segMan, obj, nodePtr, obj);
|
2009-12-23 16:43:24 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, min, 0);
|
|
|
|
PUT_SEL32V(_segMan, obj, sec, 0);
|
|
|
|
PUT_SEL32V(_segMan, obj, frame, 0);
|
2009-12-23 18:34:19 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, signal, 0);
|
|
|
|
} else {
|
2009-12-28 20:58:00 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, state, kSoundPlaying);
|
2009-12-23 16:43:24 +00:00
|
|
|
}
|
2009-12-23 20:13:54 +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->loop = GET_SEL32V(_segMan, obj, loop);
|
2009-12-26 11:54:57 +00:00
|
|
|
musicSlot->prio = GET_SEL32V(_segMan, obj, priority);
|
2010-01-02 08:15:01 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_LATE)
|
2009-12-26 11:54:57 +00:00
|
|
|
musicSlot->volume = GET_SEL32V(_segMan, obj, vol);
|
|
|
|
_music->soundPlay(musicSlot);
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2009-11-29 14:48:15 +00:00
|
|
|
#endif
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
void SoundCommandParser::cmdDummy(reg_t obj, int16 value) {
|
2009-11-12 15:24:11 +00:00
|
|
|
warning("cmdDummy invoked"); // not supposed to occur
|
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::changeSoundStatus(reg_t obj, int newStatus) {
|
2009-12-20 14:27:43 +00:00
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
2009-11-12 15:24:11 +00:00
|
|
|
if (obj.segment) {
|
|
|
|
_state->sfx_song_set_status(handle, newStatus);
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
2009-11-12 15:24:11 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, state, newStatus);
|
|
|
|
}
|
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdDisposeSound(reg_t obj, int16 value) {
|
2009-12-23 18:34:19 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
2010-01-02 01:09:49 +00:00
|
|
|
changeSoundStatus(obj, SOUND_STATUS_STOPPED);
|
2009-11-12 15:24:11 +00:00
|
|
|
|
|
|
|
if (obj.segment) {
|
|
|
|
_state->sfx_remove_song(handle);
|
|
|
|
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
2009-11-12 15:24:11 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, handle, 0x0000);
|
|
|
|
}
|
2009-11-29 14:48:15 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdDisposeSound: 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-02 01:09:49 +00:00
|
|
|
cmdStopSound(obj, value);
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
_music->soundKill(musicSlot);
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_EARLY)
|
2009-12-20 14:27:43 +00:00
|
|
|
PUT_SEL32(_segMan, obj, nodePtr, NULL_REG);
|
2009-12-23 18:34:19 +00:00
|
|
|
else
|
2009-12-28 20:58:00 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, state, kSoundStopped);
|
2009-11-29 14:48:15 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdStopSound(reg_t obj, int16 value) {
|
2009-12-23 18:34:19 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2010-01-02 01:09:49 +00:00
|
|
|
changeSoundStatus(obj, SOUND_STATUS_STOPPED);
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_EARLY)
|
2009-11-12 15:24:11 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdStopSound: 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
|
|
|
}
|
|
|
|
|
|
|
|
PUT_SEL32V(_segMan, obj, handle, 0);
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
2009-12-28 20:58:00 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, state, kSoundStopped);
|
2009-12-23 18:34:19 +00:00
|
|
|
else
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
2009-12-20 14:27:43 +00:00
|
|
|
|
2009-12-27 11:43:34 +00:00
|
|
|
musicSlot->dataInc = 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
|
|
|
musicSlot->signal = 0;
|
2009-12-27 11:43:34 +00:00
|
|
|
_music->soundStop(musicSlot);
|
2009-11-29 14:48:15 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdPauseSound(reg_t obj, int16 value) {
|
2009-12-28 22:35:53 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-12-20 14:27:43 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
2009-12-21 15:24:43 +00:00
|
|
|
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
2010-01-02 01:09:49 +00:00
|
|
|
changeSoundStatus(obj, SOUND_STATUS_SUSPENDED);
|
2009-11-12 15:24:11 +00:00
|
|
|
else
|
2010-01-02 01:09:49 +00:00
|
|
|
changeSoundStatus(obj, value ? SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING);
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
2009-12-29 00:22:39 +00:00
|
|
|
|
2010-01-03 18:06:48 +00:00
|
|
|
Common::StackLock lock(_music->_mutex);
|
|
|
|
|
2009-12-28 22:35:53 +00:00
|
|
|
MusicEntry *musicSlot = NULL;
|
|
|
|
MusicList::iterator slotLoop = NULL;
|
2009-12-28 16:23:00 +00:00
|
|
|
|
2009-12-28 22:35:53 +00:00
|
|
|
if (!obj.segment) {
|
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
|
|
|
// Pausing/Resuming the whole playlist was introduced
|
|
|
|
// in the SCI1 late sound scheme
|
2009-12-29 18:17:14 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_1_EARLY)
|
|
|
|
return;
|
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
|
|
|
slotLoop = _music->getPlayListStart();
|
2009-12-28 22:35:53 +00:00
|
|
|
musicSlot = *slotLoop;
|
|
|
|
} else {
|
|
|
|
musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdPauseSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
|
2009-12-28 22:35:53 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
}
|
|
|
|
|
2009-12-28 22:35:53 +00:00
|
|
|
do {
|
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE) {
|
2009-12-29 00:22:39 +00:00
|
|
|
PUT_SEL32V(_segMan, musicSlot->soundObj, state, kSoundPaused);
|
2009-12-27 11:43:34 +00:00
|
|
|
_music->soundPause(musicSlot);
|
2009-12-28 22:35:53 +00:00
|
|
|
} else {
|
|
|
|
if (value)
|
|
|
|
_music->soundPause(musicSlot);
|
|
|
|
else
|
2009-12-28 22:57:43 +00:00
|
|
|
_music->soundResume(musicSlot);
|
2009-12-28 22:35:53 +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
|
|
|
|
2009-12-28 22:35:53 +00:00
|
|
|
if (slotLoop) {
|
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
|
|
|
if (slotLoop == _music->getPlayListEnd())
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
musicSlot = *(slotLoop++);
|
2009-12-28 22:35:53 +00:00
|
|
|
}
|
|
|
|
} while (slotLoop);
|
2010-01-02 13:57:36 +00:00
|
|
|
|
2009-11-29 14:48:15 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdResumeSound(reg_t obj, int16 value) {
|
2009-12-22 20:44:03 +00:00
|
|
|
// SCI0 only command
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2010-01-02 01:09:49 +00:00
|
|
|
changeSoundStatus(obj, SOUND_STATUS_PLAYING);
|
2009-12-20 14:27:43 +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
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
2009-12-29 18:28:26 +00:00
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdResumeSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
|
2009-12-29 18:28:26 +00:00
|
|
|
return;
|
2009-12-20 14:27:43 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 18:28:26 +00:00
|
|
|
PUT_SEL32V(_segMan, musicSlot->soundObj, state, kSoundPlaying);
|
|
|
|
_music->soundResume(musicSlot);
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
void SoundCommandParser::cmdMuteSound(reg_t obj, int16 value) {
|
2009-12-27 14:11:26 +00:00
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
2009-12-28 22:52:07 +00:00
|
|
|
if (value > 0)
|
|
|
|
_music->soundSetSoundOn(obj.toUint16());
|
2009-12-27 14:11:26 +00:00
|
|
|
_acc = make_reg(0, _music->soundGetSoundOn());
|
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdMasterVolume(reg_t obj, int16 value) {
|
2009-12-21 15:24:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
if (obj != SIGNAL_REG)
|
|
|
|
_state->sfx_setVolume(obj.toSint16());
|
|
|
|
|
|
|
|
_acc = make_reg(0, _state->sfx_getVolume());
|
|
|
|
#else
|
2010-01-02 01:09:49 +00:00
|
|
|
debugC(2, kDebugLevelSound, "cmdMasterVolume: %d", value);
|
2010-01-01 18:57:14 +00:00
|
|
|
if (value > 0)
|
|
|
|
_music->soundSetMasterVolume(obj.toSint16());
|
|
|
|
_acc = make_reg(0, _music->soundGetMasterVolume());
|
2009-12-21 15:24:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdFadeSound(reg_t obj, int16 value) {
|
2009-11-17 06:39:28 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
2009-12-25 13:26:13 +00:00
|
|
|
if (_soundVersion != SCI_VERSION_1_LATE) {
|
2009-11-17 15:01:16 +00:00
|
|
|
/*s->sound_server->command(s, SOUND_COMMAND_FADE_HANDLE, obj, 120);*/ /* Fade out in 2 secs */
|
|
|
|
/* FIXME: The next couple of lines actually STOP the handle, rather
|
|
|
|
** than fading it! */
|
|
|
|
_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
2009-11-17 15:01:16 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, state, SOUND_STATUS_STOPPED);
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
|
|
|
} else {
|
2009-11-12 15:24:11 +00:00
|
|
|
fade_params_t fade;
|
2009-11-17 06:39:28 +00:00
|
|
|
fade.final_volume = _argv[2].toUint16();
|
|
|
|
fade.ticks_per_step = _argv[3].toUint16();
|
|
|
|
fade.step_size = _argv[4].toUint16();
|
|
|
|
fade.action = _argv[5].toUint16() ?
|
|
|
|
FADE_ACTION_FADE_AND_STOP :
|
|
|
|
FADE_ACTION_FADE_AND_CONT;
|
|
|
|
|
|
|
|
_state->sfx_song_set_fade(handle, &fade);
|
|
|
|
|
|
|
|
/* FIXME: The next couple of lines actually STOP the handle, rather
|
|
|
|
** than fading it! */
|
|
|
|
if (_argv[5].toUint16()) {
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
|
|
|
_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
|
|
|
} else {
|
|
|
|
// FIXME: Support fade-and-continue. For now, send signal right away.
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
2009-11-17 06:39:28 +00:00
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdFadeSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
|
2009-12-23 16:33:12 +00:00
|
|
|
return;
|
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-02 08:30:19 +00:00
|
|
|
musicSlot->fadeTo = CLIP<uint16>(_argv[2].toUint16(), 0, MUSIC_VOLUME_MAX);
|
2009-12-26 11:54:57 +00:00
|
|
|
musicSlot->fadeStep = volume > _argv[2].toUint16() ? -_argv[4].toUint16() : _argv[4].toUint16();
|
|
|
|
musicSlot->fadeTickerStep = _argv[3].toUint16() * 16667 / _music->soundGetTempo();
|
|
|
|
musicSlot->fadeTicker = 0;
|
2009-12-29 23:25:24 +00:00
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
debugC(2, kDebugLevelSound, "cmdFadeSound: to %d, step %d, ticker %d", musicSlot->fadeTo, musicSlot->fadeStep, musicSlot->fadeTickerStep);
|
2009-11-29 14:48:15 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
void SoundCommandParser::cmdGetPolyphony(reg_t obj, int16 value) {
|
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-11-12 15:24:11 +00:00
|
|
|
_acc = make_reg(0, _state->sfx_get_player_polyphony());
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
2009-12-29 02:21:04 +00:00
|
|
|
_acc = make_reg(0, _music->soundGetVoices()); // Get the number of voices
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdUpdateSound(reg_t obj, int16 value) {
|
2009-12-22 20:44:03 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
2009-12-27 15:24:33 +00:00
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE && obj.segment) {
|
2009-12-22 20:44:03 +00:00
|
|
|
_state->sfx_song_set_loops(handle, GET_SEL32V(_segMan, obj, loop));
|
|
|
|
script_set_priority(_resMan, _segMan, _state, obj, GET_SEL32V(_segMan, obj, pri));
|
|
|
|
}
|
|
|
|
#else
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdUpdateSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
|
2009-12-20 14:27:43 +00:00
|
|
|
return;
|
2009-11-29 14:48:15 +00:00
|
|
|
}
|
2009-12-20 14:27:43 +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->loop = GET_SEL32V(_segMan, obj, loop);
|
2009-12-27 23:46:11 +00:00
|
|
|
int16 objVol = CLIP<int>(GET_SEL32V(_segMan, obj, vol), 0, 255);
|
2009-12-26 11:54:57 +00:00
|
|
|
if (objVol != musicSlot->volume)
|
|
|
|
_music->soundSetVolume(musicSlot, objVol);
|
2009-12-27 16:44:38 +00:00
|
|
|
uint32 objPrio = GET_SEL32V(_segMan, obj, pri);
|
2009-12-26 11:54:57 +00:00
|
|
|
if (objPrio != musicSlot->prio)
|
|
|
|
_music->soundSetPriority(musicSlot, objPrio);
|
2009-12-22 20:44:03 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
void SoundCommandParser::cmdUpdateCues(reg_t obj, int16 value) {
|
2009-12-20 16:35:37 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-11-12 15:24:11 +00:00
|
|
|
int signal = 0;
|
|
|
|
int min = 0;
|
|
|
|
int sec = 0;
|
|
|
|
int frame = 0;
|
|
|
|
int result = SI_LOOP; // small hack
|
2009-12-20 14:27:43 +00:00
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
2009-11-12 15:24:11 +00:00
|
|
|
|
|
|
|
while (result == SI_LOOP)
|
2009-11-17 15:01:16 +00:00
|
|
|
result = _state->sfx_poll_specific(handle, &signal);
|
2009-11-12 15:24:11 +00:00
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case SI_ABSOLUTE_CUE:
|
|
|
|
debugC(2, kDebugLevelSound, "--- [CUE] %04x:%04x Absolute Cue: %d\n",
|
|
|
|
PRINT_REG(obj), signal);
|
2009-12-25 18:15:16 +00:00
|
|
|
debugC(2, kDebugLevelSound, "abs-signal %04X\n", signal);
|
2009-11-12 15:24:11 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, signal, signal);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_RELATIVE_CUE:
|
|
|
|
debugC(2, kDebugLevelSound, "--- [CUE] %04x:%04x Relative Cue: %d\n",
|
2009-11-17 15:01:16 +00:00
|
|
|
PRINT_REG(obj), signal);
|
2009-11-12 15:24:11 +00:00
|
|
|
|
|
|
|
/* FIXME to match commented-out semantics
|
|
|
|
* below, with proper storage of dataInc and
|
|
|
|
* signal in the iterator code. */
|
|
|
|
PUT_SEL32V(_segMan, obj, dataInc, signal);
|
2009-12-25 18:15:16 +00:00
|
|
|
debugC(2, kDebugLevelSound, "rel-signal %04X\n", signal);
|
2009-12-25 13:26:13 +00:00
|
|
|
if (_soundVersion == SCI_VERSION_1_EARLY)
|
2009-11-17 15:01:16 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, signal, signal);
|
|
|
|
else
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, signal + 127);
|
2009-11-12 15:24:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_FINISHED:
|
|
|
|
debugC(2, kDebugLevelSound, "--- [FINISHED] %04x:%04x\n", PRINT_REG(obj));
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_LOOP:
|
|
|
|
break; // Doesn't happen
|
|
|
|
}
|
|
|
|
|
|
|
|
//switch (signal) {
|
|
|
|
//case 0x00:
|
|
|
|
// if (dataInc!=GET_SEL32V(segMan, obj, dataInc)) {
|
|
|
|
// PUT_SEL32V(segMan, obj, dataInc, dataInc);
|
|
|
|
// PUT_SEL32V(segMan, obj, signal, dataInc+0x7f);
|
|
|
|
// } else {
|
|
|
|
// PUT_SEL32V(segMan, obj, signal, signal);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
//case 0xFF: // May be unnecessary
|
|
|
|
// s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
|
|
|
// break;
|
|
|
|
//default :
|
|
|
|
// if (dataInc!=GET_SEL32V(segMan, obj, dataInc)) {
|
|
|
|
// PUT_SEL32V(segMan, obj, dataInc, dataInc);
|
|
|
|
// PUT_SEL32V(segMan, obj, signal, dataInc + 0x7f);
|
|
|
|
// } else {
|
|
|
|
// PUT_SEL32V(segMan, obj, signal, signal);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
//}
|
|
|
|
|
2009-12-25 13:26:13 +00:00
|
|
|
if (_soundVersion == SCI_VERSION_1_EARLY) {
|
2009-11-17 15:01:16 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, min, min);
|
|
|
|
PUT_SEL32V(_segMan, obj, sec, sec);
|
|
|
|
PUT_SEL32V(_segMan, obj, frame, frame);
|
|
|
|
}
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdUpdateCues: 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-03 18:43:17 +00:00
|
|
|
// Update digital sound effect slots here
|
|
|
|
Audio::Mixer *mixer = g_system->getMixer();
|
|
|
|
|
2010-01-01 22:15:52 +00:00
|
|
|
uint currentLoopCounter = musicSlot->pStreamAud->getNumPlayedLoops();
|
|
|
|
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-01-01 16:05:26 +00:00
|
|
|
if (!mixer->isSoundHandleActive(musicSlot->hCurrentAud)) {
|
2010-01-02 15:02:41 +00:00
|
|
|
cmdStopSound(obj, 0);
|
2010-01-01 16:05:26 +00:00
|
|
|
} else {
|
|
|
|
musicSlot->ticker = (uint16)(mixer->getSoundElapsedTime(musicSlot->hCurrentAud) * 0.06);
|
|
|
|
}
|
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-01-01 22:15:52 +00:00
|
|
|
mixer->setChannelVolume(musicSlot->hCurrentAud, musicSlot->volume);
|
2010-01-02 15:54:08 +00:00
|
|
|
musicSlot->fadeSetVolume = false;
|
2010-01-01 22:15:52 +00:00
|
|
|
}
|
2010-01-02 15:02:41 +00:00
|
|
|
} else {
|
|
|
|
switch (musicSlot->signal) {
|
|
|
|
case 0:
|
|
|
|
if (musicSlot->dataInc != GET_SEL32V(_segMan, obj, dataInc)) {
|
|
|
|
PUT_SEL32V(_segMan, obj, dataInc, musicSlot->dataInc);
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, musicSlot->dataInc + 127);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SIGNAL_OFFSET:
|
2010-01-03 13:28:59 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
2010-01-02 15:02:41 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Sync the signal of the sound object
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, musicSlot->signal);
|
|
|
|
break;
|
|
|
|
}
|
2010-01-01 16:05:26 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 17:16:59 +00:00
|
|
|
if (musicSlot->fadeCompleted) {
|
|
|
|
musicSlot->fadeCompleted = false;
|
|
|
|
PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET);
|
|
|
|
}
|
|
|
|
|
2010-01-01 16:15:20 +00:00
|
|
|
// Sync loop selector for SCI0
|
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
|
|
|
PUT_SEL32V(_segMan, obj, 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) {
|
|
|
|
PUT_SEL32V(_segMan, obj, min, musicSlot->ticker / 3600);
|
|
|
|
PUT_SEL32V(_segMan, obj, sec, musicSlot->ticker % 3600 / 60);
|
|
|
|
PUT_SEL32V(_segMan, obj, frame, musicSlot->ticker);
|
|
|
|
}
|
2010-01-01 16:05:26 +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
|
|
|
#endif
|
2010-01-01 16:05:26 +00:00
|
|
|
}
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
void SoundCommandParser::cmdSendMidi(reg_t obj, int16 value) {
|
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-12-28 22:52:07 +00:00
|
|
|
//SongHandle handle = FROBNICATE_HANDLE(obj);
|
|
|
|
//_state->sfx_send_midi(handle, value, _midiCmd, _controller, _param);
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
2009-12-28 22:52:07 +00:00
|
|
|
_music->sendMidiCommand(_midiCommand);
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
void SoundCommandParser::cmdReverb(reg_t obj, int16 value) {
|
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
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
_music->setReverb(obj.toUint16() & 0xF);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdSetSoundHold(reg_t obj, int16 value) {
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
2009-11-12 15:24:11 +00:00
|
|
|
_state->sfx_song_set_hold(handle, value);
|
2009-12-20 14:27:43 +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
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-02 01:09:49 +00:00
|
|
|
warning("cmdSetSoundHold: Slot not found (%04x:%04x)", PRINT_REG(obj));
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-02 15:37:17 +00:00
|
|
|
// Set the special hold marker ID where the song should be looped at.
|
|
|
|
musicSlot->hold = value;
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
void SoundCommandParser::cmdGetAudioCapability(reg_t obj, int16 value) {
|
2009-11-12 15:24:11 +00:00
|
|
|
// Tests for digital audio support
|
|
|
|
_acc = make_reg(0, 1);
|
|
|
|
}
|
|
|
|
|
2009-12-27 23:46:11 +00:00
|
|
|
void SoundCommandParser::cmdStopAllSounds(reg_t obj, int16 value) {
|
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
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) {
|
|
|
|
if (_soundVersion <= SCI_VERSION_0_LATE)
|
|
|
|
PUT_SEL32V(_segMan, (*i)->soundObj, state, kSoundStopped);
|
|
|
|
else
|
|
|
|
PUT_SEL32V(_segMan, (*i)->soundObj, signal, SIGNAL_OFFSET);
|
|
|
|
|
|
|
|
(*i)->dataInc = 0;
|
|
|
|
_music->soundStop(*i);
|
|
|
|
}
|
2009-12-27 23:46:11 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdSetSoundVolume(reg_t obj, int16 value) {
|
2009-12-22 20:44:03 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
2009-12-27 11:43:34 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
2010-01-03 13:28:59 +00:00
|
|
|
// Do not throw a warning if the sound can't be found, as in some games
|
|
|
|
// 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
|
|
|
|
//warning("cmdSetSoundVolume: 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-02 01:09:49 +00:00
|
|
|
debugC(2, kDebugLevelSound, "cmdSetSoundVolume: %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);
|
2009-12-23 16:33:12 +00:00
|
|
|
PUT_SEL32V(_segMan, obj, vol, value);
|
2009-11-29 14:48:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdSetSoundPriority(reg_t obj, int16 value) {
|
2009-12-22 20:44:03 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-11-12 15:24:11 +00:00
|
|
|
script_set_priority(_resMan, _segMan, _state, obj, value);
|
2009-12-20 14:27:43 +00:00
|
|
|
#else
|
2010-01-02 01:41:39 +00:00
|
|
|
MusicEntry *musicSlot = _music->getSlot(obj);
|
|
|
|
if (!musicSlot) {
|
|
|
|
warning("cmdSetSoundPriority: Slot not found (%04x:%04x)", PRINT_REG(obj));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-22 13:31:52 +00:00
|
|
|
if (value == -1) {
|
2010-01-02 01:41:39 +00:00
|
|
|
// Set priority from the song data
|
|
|
|
Resource *song = _resMan->findResource(ResourceId(kResourceTypeSound, musicSlot->resnum), 0);
|
|
|
|
if (song->data[0] == 0xf0)
|
|
|
|
_music->soundSetPriority(musicSlot, song->data[1]);
|
|
|
|
else
|
|
|
|
warning("cmdSetSoundPriority: Attempt to unset song priority when there is no built-in value");
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
//pSnd->prio=0;field_15B=0
|
|
|
|
PUT_SEL32V(_segMan, obj, flags, GET_SEL32V(_segMan, obj, flags) & 0xFD);
|
|
|
|
} else {
|
2010-01-02 01:41:39 +00:00
|
|
|
// Scripted priority
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
//pSnd->field_15B=1;
|
|
|
|
PUT_SEL32V(_segMan, obj, flags, GET_SEL32V(_segMan, obj, flags) | 2);
|
|
|
|
//DoSOund(0xF,hobj,w)
|
2009-11-29 14:48:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void SoundCommandParser::cmdSetSoundLoop(reg_t obj, int16 value) {
|
2009-12-22 20:44:03 +00:00
|
|
|
if (!obj.segment)
|
|
|
|
return;
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-12-23 16:33:12 +00:00
|
|
|
if (!GET_SEL32(_segMan, obj, nodePtr).isNull()) {
|
2009-12-22 20:44:03 +00:00
|
|
|
SongHandle handle = FROBNICATE_HANDLE(obj);
|
|
|
|
_state->sfx_song_set_loops(handle, value);
|
2009-12-23 16:33:12 +00:00
|
|
|
}
|
2009-12-22 20:44:03 +00:00
|
|
|
#else
|
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,
|
|
|
|
// otherwise do, because the sound won't be looped
|
|
|
|
if (value == -1) {
|
|
|
|
warning("cmdSetSoundLoop: Slot not found (%04x:%04x) and the song was requested to be looped", PRINT_REG(obj));
|
|
|
|
} else {
|
|
|
|
// Doesn't really matter
|
|
|
|
}
|
2009-12-23 16:33:12 +00:00
|
|
|
return;
|
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
|
|
|
|
|
|
|
PUT_SEL32V(_segMan, obj, loop, musicSlot->loop);
|
2009-12-23 16:33:12 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
void SoundCommandParser::cmdSuspendSound(reg_t obj, int16 value) {
|
2009-11-12 15:24:11 +00:00
|
|
|
// TODO
|
2009-12-22 12:35:48 +00:00
|
|
|
warning("STUB: cmdSuspendSound");
|
2009-11-12 15:24:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-01 16:05:26 +00:00
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
|
|
|
|
void SoundCommandParser::updateSci0Cues() {
|
|
|
|
Common::StackLock(_music->_mutex);
|
|
|
|
|
|
|
|
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
|
|
|
|
// this sound, as SCI0 only allows one active song
|
|
|
|
if ((*i)->signal == 0 && (*i)->status != kSoundPlaying)
|
|
|
|
continue;
|
|
|
|
|
2010-01-01 16:05:26 +00:00
|
|
|
cmdUpdateCues((*i)->soundObj, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-12-28 20:10:15 +00:00
|
|
|
void SoundCommandParser::clearPlayList() {
|
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
_music->clearPlayList();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundCommandParser::syncPlayList(Common::Serializer &s) {
|
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
_music->saveLoadWithSerializer(s);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundCommandParser::reconstructPlayList(int savegame_version) {
|
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
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 lock(_music->_mutex);
|
|
|
|
|
2010-01-02 19:24:52 +00:00
|
|
|
_music->resetDriver();
|
|
|
|
|
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
|
|
|
const MusicList::iterator end = _music->getPlayListEnd();
|
|
|
|
for (MusicList::iterator i = _music->getPlayListStart(); i != end; ++i) {
|
|
|
|
if (savegame_version < 14) {
|
|
|
|
(*i)->dataInc = GET_SEL32V(_segMan, (*i)->soundObj, dataInc);
|
|
|
|
(*i)->signal = GET_SEL32V(_segMan, (*i)->soundObj, signal);
|
|
|
|
|
2010-01-02 08:15:01 +00:00
|
|
|
if (_soundVersion >= SCI_VERSION_1_LATE)
|
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)->volume = GET_SEL32V(_segMan, (*i)->soundObj, vol);
|
|
|
|
}
|
|
|
|
|
2010-01-03 18:06:48 +00:00
|
|
|
if ((*i)->resnum && _resMan->testResource(ResourceId(kResourceTypeSound, (*i)->resnum))) {
|
|
|
|
(*i)->soundRes = new SoundResource((*i)->resnum, _resMan, _soundVersion);
|
|
|
|
_music->soundInitSnd(*i);
|
|
|
|
} else {
|
|
|
|
(*i)->soundRes = 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
|
|
|
if ((*i)->status == kSoundPlaying)
|
2010-01-02 01:09:49 +00:00
|
|
|
cmdPlaySound((*i)->soundObj, 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
|
|
|
}
|
|
|
|
|
2009-12-28 20:10:15 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundCommandParser::printPlayList(Console *con) {
|
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
_music->printPlayList(con);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-01-01 19:23:23 +00:00
|
|
|
void SoundCommandParser::resetDriver() {
|
|
|
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
_music->resetDriver();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:24:11 +00:00
|
|
|
} // End of namespace Sci
|