From a0a82d911c77b63f2069dbc39ab26394fe4d377d Mon Sep 17 00:00:00 2001 From: Henry Bush Date: Wed, 28 Jan 2009 23:29:19 +0000 Subject: T7G: start background music at start of input loop (0x0B). Should fix 2474078, but might break other things so I'm not going to backport it. svn-id: r36125 --- engines/groovie/music.cpp | 14 ++++++++++---- engines/groovie/music.h | 2 ++ engines/groovie/script.cpp | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'engines/groovie') diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp index 8c4d846b65..5812d0a9ba 100644 --- a/engines/groovie/music.cpp +++ b/engines/groovie/music.cpp @@ -33,7 +33,7 @@ namespace Groovie { MusicPlayer::MusicPlayer(GroovieEngine *vm, const Common::String >lName) : _vm(vm), _midiParser(NULL), _data(NULL), _driver(NULL), - _backgroundFileRef(0), _gameVolume(100), _prevCDtrack(0) { + _backgroundFileRef(0), _gameVolume(100), _prevCDtrack(0), _isPlaying(0) { // Create the parser _midiParser = MidiParser::createParser_XMIDI(); @@ -174,12 +174,17 @@ void MusicPlayer::setGameVolume(uint16 volume, uint16 time) { _fadingEndVolume = 100; } +void MusicPlayer::startBackground() { + if (!_isPlaying && _backgroundFileRef) { + play(_backgroundFileRef, true); + } +} + void MusicPlayer::endTrack() { debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: End of song"); unload(); - if (_backgroundFileRef) { - play(_backgroundFileRef, true); - } + _isPlaying = false; + startBackground(); } void MusicPlayer::applyFading() { @@ -232,6 +237,7 @@ bool MusicPlayer::play(uint16 fileref, bool loop) { _midiParser->property(MidiParser::mpAutoLoop, loop); _gameVolume = 100; + _isPlaying = true; // Load the new file return load(fileref); } diff --git a/engines/groovie/music.h b/engines/groovie/music.h index 0883e7814b..3315ce1886 100644 --- a/engines/groovie/music.h +++ b/engines/groovie/music.h @@ -41,6 +41,7 @@ public: void playSong(uint16 fileref); void setBackgroundSong(uint16 fileref); void playCD(uint8 track); + void startBackground(); // Volume void setUserVolume(uint16 volume); @@ -99,6 +100,7 @@ private: MidiParser *_midiParser; MidiDriver *_driver; uint8 _musicType; + bool _isPlaying; uint16 _backgroundFileRef; uint8 _prevCDtrack; diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 99698a6148..a8feda0805 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -582,6 +582,8 @@ void Script::o_inputloopstart() { _mouseClicked = _eventMouseClicked; _eventMouseClicked = false; + _vm->_musicPlayer->startBackground(); + // Save the current pressed character for the whole loop _kbdChar = _eventKbdChar; _eventKbdChar = 0; -- cgit v1.2.3