SCI: Made the SoundCommandParser a member of the SciEngine class and removed it from the EngineState, since it's static throughout the course of a game

svn-id: r50484
This commit is contained in:
Filippos Karapetis 2010-06-29 09:00:08 +00:00
parent 5e030bebcc
commit 9f1320d5cc
8 changed files with 24 additions and 26 deletions

View File

@ -219,8 +219,8 @@ void Console::preEnter() {
if (_engine->_gamestate)
_engine->_gamestate->_sound.sfx_suspend(true);
#endif
if (_engine->_gamestate && _engine->_gamestate->_soundCmd)
_engine->_gamestate->_soundCmd->pauseAll(true);
if (g_sci && g_sci->_soundCmd)
g_sci->_soundCmd->pauseAll(true);
}
void Console::postEnter() {
@ -228,8 +228,8 @@ void Console::postEnter() {
if (_engine->_gamestate)
_engine->_gamestate->_sound.sfx_suspend(false);
#endif
if (_engine->_gamestate && _engine->_gamestate->_soundCmd)
_engine->_gamestate->_soundCmd->pauseAll(false);
if (g_sci && g_sci->_soundCmd)
g_sci->_soundCmd->pauseAll(false);
if (!_videoFile.empty()) {
_engine->_gfxCursor->kernelHide();
@ -1662,7 +1662,7 @@ bool Console::cmdSongLib(int argc, const char **argv) {
} while (seeker);
DebugPrintf("\n");
#else
_engine->_gamestate->_soundCmd->printPlayList(this);
g_sci->_soundCmd->printPlayList(this);
#endif
return true;
@ -1683,7 +1683,7 @@ bool Console::cmdSongInfo(int argc, const char **argv) {
return true;
}
_engine->_gamestate->_soundCmd->printSongInfo(addr, this);
g_sci->_soundCmd->printSongInfo(addr, this);
return true;
}
@ -1702,7 +1702,7 @@ bool Console::cmdStartSound(int argc, const char **argv) {
return true;
}
_engine->_gamestate->_soundCmd->startNewSound(number);
g_sci->_soundCmd->startNewSound(number);
return false;
}
@ -1743,9 +1743,9 @@ bool Console::cmdToggleSound(int argc, const char **argv) {
newState.toLowercase();
if (newState == "play")
_engine->_gamestate->_soundCmd->playSound(id);
g_sci->_soundCmd->playSound(id);
else if (newState == "stop")
_engine->_gamestate->_soundCmd->stopSound(id);
g_sci->_soundCmd->stopSound(id);
else
DebugPrintf("New state can either be 'play' or 'stop'");
#endif
@ -1755,7 +1755,7 @@ bool Console::cmdToggleSound(int argc, const char **argv) {
bool Console::cmdStopAllSounds(int argc, const char **argv) {
#ifndef USE_OLD_MUSIC_FUNCTIONS
_engine->_gamestate->_soundCmd->stopAllSounds();
g_sci->_soundCmd->stopAllSounds();
#endif
DebugPrintf("All sounds have been stopped\n");

View File

@ -156,7 +156,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
// like SCI01 and later do with cmdUpdateSoundCues. kGetEvent is called
// quite often, so emulate the SCI01 behavior of cmdUpdateSoundCues with
// this call
s->_soundCmd->updateSci0Cues();
g_sci->_soundCmd->updateSci0Cues();
}
#endif

View File

@ -39,7 +39,7 @@ namespace Sci {
* Used for synthesized music playback
*/
reg_t kDoSound(EngineState *s, int argc, reg_t *argv) {
return s->_soundCmd->parseCommand(argc, argv, s->r_acc);
return g_sci->_soundCmd->parseCommand(argc, argv, s->r_acc);
}
reg_t kDoCdAudio(EngineState *s, int argc, reg_t *argv) {

View File

@ -385,7 +385,7 @@ void EngineState::saveLoadWithSerializer(Common::Serializer &s) {
#ifdef USE_OLD_MUSIC_FUNCTIONS
sync_songlib(s, _sound._songlib);
#else
_soundCmd->syncPlayList(s);
g_sci->_soundCmd->syncPlayList(s);
#endif
}
@ -978,7 +978,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
s->_sound._suspended = s->_sound._suspended;
reconstruct_sounds(s);
#else
s->_soundCmd->reconstructPlayList(meta.savegame_version);
g_sci->_soundCmd->reconstructPlayList(meta.savegame_version);
#endif
// Message state:

View File

@ -87,7 +87,6 @@ void EngineState::reset(bool isRestoring) {
if (!isRestoring) {
_memorySegmentSize = 0;
_soundCmd = 0;
_fileHandles.resize(5);

View File

@ -109,7 +109,6 @@ public:
SfxState _sound; /**< sound subsystem */
int sfx_init_flags; /**< flags the sfx subsystem was initialised with */
#endif
SoundCommandParser *_soundCmd;
uint32 gameStartTime; /**< The time at which the interpreter was started */
uint32 lastWaitTime; /**< The last time the game invoked Wait() */

View File

@ -154,6 +154,7 @@ SciEngine::~SciEngine() {
delete _gfxScreen;
delete _audio;
delete _soundCmd;
delete _kernel;
delete _vocabulary;
delete _console;
@ -161,7 +162,6 @@ SciEngine::~SciEngine() {
delete _gfxMacIconBar;
delete _eventMan;
delete _gamestate->_soundCmd;
delete _gamestate->_segMan;
delete _gamestate;
delete _resMan; // should be deleted last
@ -216,16 +216,14 @@ Common::Error SciEngine::run() {
return Common::kUnknownError;
}
_kernel->loadKernelNames(_features); // Must be called after game_init()
script_adjust_opcode_formats();
SciVersion soundVersion = _features->detectDoSoundType();
_gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, soundVersion);
// Must be called after game_init(), as they use _features
_kernel->loadKernelNames(_features);
_soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, _features->detectDoSoundType());
#ifdef USE_OLD_MUSIC_FUNCTIONS
initGameSound(0, soundVersion);
initGameSound(0, _features->detectDoSoundType());
#endif
syncSoundSettings();
@ -463,7 +461,7 @@ void SciEngine::exitGame() {
initGameSound(SFX_STATE_FLAG_NOSOUND, _features->detectDoSoundType());
#else
_audio->stopAllAudio();
_gamestate->_soundCmd->clearPlayList();
g_sci->_soundCmd->clearPlayList();
#endif
}
@ -562,9 +560,9 @@ void SciEngine::syncSoundSettings() {
int soundVolumeMusic = (mute ? 0 : ConfMan.getInt("music_volume"));
if (_gamestate && _gamestate->_soundCmd) {
if (_gamestate && g_sci->_soundCmd) {
int vol = (soundVolumeMusic + 1) * SoundCommandParser::kMaxSciVolume / Audio::Mixer::kMaxMixerVolume;
_gamestate->_soundCmd->setMasterVolume(vol);
g_sci->_soundCmd->setMasterVolume(vol);
}
#endif
}

View File

@ -52,6 +52,7 @@ class Kernel;
class GameFeatures;
class Console;
class AudioPlayer;
class SoundCommandParser;
class EventManager;
class GfxAnimate;
@ -291,6 +292,7 @@ public:
#endif
AudioPlayer *_audio;
SoundCommandParser *_soundCmd;
GameFeatures *_features;
private: