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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SCI_SOUNDCMD_H
|
|
|
|
#define SCI_SOUNDCMD_H
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#include "sci/sci.h" // for USE_OLD_MUSIC_FUNCTIONS
|
|
|
|
|
2009-11-15 14:14:49 +00:00
|
|
|
#include "common/list.h"
|
2009-11-12 15:24:11 +00:00
|
|
|
#include "sci/engine/state.h"
|
|
|
|
|
|
|
|
namespace Sci {
|
|
|
|
|
2009-12-28 20:10:15 +00:00
|
|
|
class Console;
|
2009-11-15 14:14:49 +00:00
|
|
|
class SciMusic;
|
2009-11-12 15:24:11 +00:00
|
|
|
class SoundCommandParser;
|
2009-12-20 14:27:43 +00:00
|
|
|
typedef void (SoundCommandParser::*SoundCommand)(reg_t obj, int16 value);
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
struct MusicEntryCommand {
|
|
|
|
MusicEntryCommand(const char *d, SoundCommand c) : sndCmd(c), desc(d) {}
|
2009-11-12 15:24:11 +00:00
|
|
|
SoundCommand sndCmd;
|
2009-12-08 22:08:33 +00:00
|
|
|
const char *desc;
|
2009-11-12 15:24:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SoundCommandParser {
|
|
|
|
public:
|
2010-01-18 22:39:56 +00:00
|
|
|
SoundCommandParser(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, AudioPlayer *audio, SciVersion soundVersion);
|
2009-11-12 15:24:11 +00:00
|
|
|
~SoundCommandParser();
|
|
|
|
|
2010-01-12 00:51:37 +00:00
|
|
|
enum {
|
|
|
|
kMaxSciVolume = 15
|
|
|
|
};
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-11-29 14:44:12 +00:00
|
|
|
void updateSfxState(SfxState *newState) { _state = newState; }
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-29 14:44:12 +00:00
|
|
|
|
2009-11-12 15:24:11 +00:00
|
|
|
reg_t parseCommand(int argc, reg_t *argv, reg_t acc);
|
2010-01-23 14:39:03 +00:00
|
|
|
|
|
|
|
// Functions used for game state loading
|
2009-12-28 20:10:15 +00:00
|
|
|
void clearPlayList();
|
|
|
|
void syncPlayList(Common::Serializer &s);
|
|
|
|
void reconstructPlayList(int savegame_version);
|
2010-01-23 14:39:03 +00:00
|
|
|
|
|
|
|
// Functions used for the ScummVM menus
|
2010-01-12 00:51:37 +00:00
|
|
|
void setMasterVolume(int vol);
|
2010-01-21 21:28:32 +00:00
|
|
|
void pauseAll(bool pause);
|
2009-12-25 13:18:48 +00:00
|
|
|
|
2010-01-23 14:39:03 +00:00
|
|
|
// Debug console functions
|
|
|
|
void playSound(reg_t obj) { cmdPlaySound(obj, 0); }
|
|
|
|
void stopSound(reg_t obj) { cmdStopSound(obj, 0); }
|
|
|
|
void startNewSound(int number);
|
|
|
|
void stopAllSounds();
|
|
|
|
void printPlayList(Console *con);
|
|
|
|
void printSongInfo(reg_t obj, Console *con);
|
|
|
|
|
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
|
2010-01-01 16:05:26 +00:00
|
|
|
/**
|
|
|
|
* Synchronizes the current state of the music list to the rest of the engine, so that
|
|
|
|
* the changes that the sound thread makes to the music are registered with the engine
|
|
|
|
* scripts. In SCI0, we invoke this from kAnimate (which is called very often). SCI01
|
|
|
|
* and later have a specific callback function, cmdUpdateCues, which is called regularly
|
|
|
|
* by the engine scripts themselves, so the engine itself polls for changes to the music
|
|
|
|
*/
|
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
|
|
|
void updateSci0Cues();
|
|
|
|
#endif
|
|
|
|
|
2009-12-25 13:18:48 +00:00
|
|
|
private:
|
2010-01-12 20:08:17 +00:00
|
|
|
typedef Common::Array<MusicEntryCommand *> SoundCommandContainer;
|
|
|
|
SoundCommandContainer _soundCommands;
|
2009-11-12 15:24:11 +00:00
|
|
|
ResourceManager *_resMan;
|
|
|
|
SegManager *_segMan;
|
2010-01-18 22:39:56 +00:00
|
|
|
Kernel *_kernel;
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2009-11-12 15:24:11 +00:00
|
|
|
SfxState *_state;
|
2010-01-02 01:09:49 +00:00
|
|
|
int _midiCmd, _controller, _param;
|
2009-12-28 20:10:15 +00:00
|
|
|
#else
|
|
|
|
SciMusic *_music;
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
AudioPlayer *_audio;
|
2009-12-25 13:13:42 +00:00
|
|
|
SciVersion _soundVersion;
|
2010-01-03 23:30:23 +00:00
|
|
|
int _argc;
|
2010-01-02 01:09:49 +00:00
|
|
|
reg_t *_argv; // for cmdFadeSound
|
2009-12-28 22:52:07 +00:00
|
|
|
uint32 _midiCommand; // for cmdSendMidi
|
2009-11-12 15:24:11 +00:00
|
|
|
reg_t _acc;
|
2010-01-04 19:39:33 +00:00
|
|
|
int _cmdUpdateCuesIndex;
|
2009-11-12 15:24:11 +00:00
|
|
|
|
2010-01-02 01:09:49 +00:00
|
|
|
void cmdInitSound(reg_t obj, int16 value);
|
|
|
|
void cmdPlaySound(reg_t obj, int16 value);
|
2009-12-20 14:27:43 +00:00
|
|
|
void cmdDummy(reg_t obj, int16 value);
|
|
|
|
void cmdMuteSound(reg_t obj, int16 value);
|
2010-01-02 01:09:49 +00:00
|
|
|
void cmdPauseSound(reg_t obj, int16 value);
|
|
|
|
void cmdResumeSound(reg_t obj, int16 value);
|
|
|
|
void cmdStopSound(reg_t obj, int16 value);
|
|
|
|
void cmdDisposeSound(reg_t obj, int16 value);
|
|
|
|
void cmdMasterVolume(reg_t obj, int16 value);
|
|
|
|
void cmdFadeSound(reg_t obj, int16 value);
|
2009-12-20 14:27:43 +00:00
|
|
|
void cmdGetPolyphony(reg_t obj, int16 value);
|
2009-12-27 23:46:11 +00:00
|
|
|
void cmdStopAllSounds(reg_t obj, int16 value);
|
2010-01-02 01:09:49 +00:00
|
|
|
void cmdUpdateSound(reg_t obj, int16 value);
|
2009-12-20 14:27:43 +00:00
|
|
|
void cmdUpdateCues(reg_t obj, int16 value);
|
|
|
|
void cmdSendMidi(reg_t obj, int16 value);
|
|
|
|
void cmdReverb(reg_t obj, int16 value);
|
2010-01-02 01:09:49 +00:00
|
|
|
void cmdSetSoundHold(reg_t obj, int16 value);
|
2009-12-20 14:27:43 +00:00
|
|
|
void cmdGetAudioCapability(reg_t obj, int16 value);
|
2010-01-02 01:09:49 +00:00
|
|
|
void cmdSetSoundVolume(reg_t obj, int16 value);
|
|
|
|
void cmdSetSoundPriority(reg_t obj, int16 value);
|
|
|
|
void cmdSetSoundLoop(reg_t obj, int16 value);
|
2009-12-20 14:27:43 +00:00
|
|
|
void cmdSuspendSound(reg_t obj, int16 value);
|
|
|
|
|
2010-05-03 17:54:47 +00:00
|
|
|
void processStopSound(reg_t obj, int16 value, bool sampleFinishedPlaying);
|
|
|
|
|
2009-12-20 14:27:43 +00:00
|
|
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
2010-01-02 01:09:49 +00:00
|
|
|
void changeSoundStatus(reg_t obj, int newStatus);
|
2009-12-20 14:27:43 +00:00
|
|
|
#endif
|
2009-11-12 15:24:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Sci
|
|
|
|
|
|
|
|
#endif // SCI_SOUNDCMD_H
|