aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/console.cpp20
-rw-r--r--engines/sci/engine/kevent.cpp2
-rw-r--r--engines/sci/engine/ksound.cpp2
-rw-r--r--engines/sci/engine/savegame.cpp4
-rw-r--r--engines/sci/engine/state.cpp1
-rw-r--r--engines/sci/engine/state.h1
-rw-r--r--engines/sci/sci.cpp18
-rw-r--r--engines/sci/sci.h2
8 files changed, 24 insertions, 26 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index b30349dd5a..f9d2ac5090 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -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");
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index e38550adee..bc8ddc34fc 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -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
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 0172b005ac..3d8869e89e 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -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) {
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 7804265d0d..bf7b88b699 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -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:
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index 9bd8f380a1..f13a44e704 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -87,7 +87,6 @@ void EngineState::reset(bool isRestoring) {
if (!isRestoring) {
_memorySegmentSize = 0;
- _soundCmd = 0;
_fileHandles.resize(5);
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 2fcad5b2e4..07843a68e3 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -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() */
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 46d33eda78..e90ca9de5d 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -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
}
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index f60aad67a7..d7ca1345bf 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -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: