From 12b6d4ab032cad05e54b9a40bd8c36736597bb71 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 26 Dec 2009 00:50:09 +0000 Subject: Some more work on the new music code svn-id: r46569 --- engines/sci/engine/game.cpp | 14 +++++++++----- engines/sci/engine/savegame.cpp | 1 + engines/sci/engine/vm.h | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'engines/sci/engine') diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 10d914ac59..bc7307e940 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -33,12 +33,13 @@ #include "sci/engine/state.h" #include "sci/engine/kernel.h" #include "sci/engine/kernel_types.h" -#include "sci/gui/gui.h" #include "sci/engine/message.h" +#include "sci/gui/gui.h" #ifdef INCLUDE_OLDGFX #include "sci/gfx/gfx_state_internal.h" // required for GfxPort, GfxVisual #include "sci/gfx/menubar.h" #endif +#include "sci/sfx/music.h" namespace Sci { @@ -291,17 +292,17 @@ static void _free_graphics_input(EngineState *s) { } #endif -int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion) { #ifdef USE_OLD_MUSIC_FUNCTIONS +int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion) { if (getSciVersion() > SCI_VERSION_0_LATE) sound_flags |= SFX_STATE_FLAG_MULTIPLAY; s->sfx_init_flags = sound_flags; s->_sound.sfx_init(s->resMan, sound_flags, soundVersion); -#endif return 0; } +#endif // Architectural stuff: Init/Unintialize engine int script_init_engine(EngineState *s) { @@ -433,13 +434,16 @@ int game_init(EngineState *s) { int game_exit(EngineState *s) { s->_executionStack.clear(); -#ifdef USE_OLD_MUSIC_FUNCTIONS if (!s->successor) { +#ifdef USE_OLD_MUSIC_FUNCTIONS s->_sound.sfx_exit(); // Reinit because some other code depends on having a valid state game_init_sound(s, SFX_STATE_FLAG_NOSOUND, s->detectDoSoundType()); - } +#else + s->_audio->stopAllAudio(); + s->_soundCmd->_music->stopAll(); #endif + } // Note: It's a bad idea to delete the segment manager here // when loading a game. diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index a0b6421731..9f43957eaf 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -148,6 +148,7 @@ static void syncSong(Common::Serializer &s, MusicEntry *song) { // pMidiParser and pStreamAud will be initialized when the // sound list is reconstructed in gamestate_restore() if (s.isLoading()) { + song->soundRes = 0; song->pMidiParser = 0; song->pStreamAud = 0; } diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index 696aeb1a57..25acfc5ae6 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -486,6 +486,7 @@ int game_init(EngineState *s); int game_init_graphics(EngineState *s); #endif +#ifdef USE_OLD_MUSIC_FUNCTIONS /** * Initializes the sound part of an SCI game * This function may only be called if game_init() did not initialize @@ -496,6 +497,7 @@ int game_init_graphics(EngineState *s); * @return 0 on success, 1 if an error occured */ int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion); +#endif /** * Runs an SCI game -- cgit v1.2.3