diff options
33 files changed, 80 insertions, 90 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 4d879909c4..530803cf69 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -24,13 +24,13 @@ #include "common/file.h" #include "common/fs.h" #include "common/textconsole.h" -#include "common/system.h" #include "engines/util.h" #include "agos/debugger.h" #include "agos/intern.h" #include "agos/agos.h" +#include "agos/midi.h" #include "backends/audiocd/audiocd.h" @@ -541,16 +541,18 @@ Common::Error AGOSEngine::init() { initGraphics(_screenWidth, _screenHeight, getGameType() == GType_FF || getGameType() == GType_PP); + _midi = new MidiPlayer(); + if ((getGameType() == GType_SIMON2 && getPlatform() == Common::kPlatformWindows) || (getGameType() == GType_SIMON1 && getPlatform() == Common::kPlatformWindows) || ((getFeatures() & GF_TALKIE) && getPlatform() == Common::kPlatformAcorn) || (getPlatform() == Common::kPlatformPC)) { - int ret = _midi.open(getGameType()); + int ret = _midi->open(getGameType()); if (ret) warning("MIDI Player init failed: \"%s\"", MidiDriver::getErrorName(ret)); - _midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); + _midi->setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); _midiEnabled = true; } @@ -597,14 +599,14 @@ Common::Error AGOSEngine::init() { if (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute") == 1) { _musicPaused = true; if (_midiEnabled) { - _midi.pause(_musicPaused); + _midi->pause(_musicPaused); } _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, 0); } if (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute") == 1) { if (getGameId() == GID_SIMON1DOS) - _midi._enable_sfx = !_midi._enable_sfx; + _midi->_enable_sfx = !_midi->_enable_sfx; else { _effectsPaused = !_effectsPaused; _sound->effectsPause(_effectsPaused); @@ -708,7 +710,7 @@ void AGOSEngine_Simon2::setupGame() { _itemMemSize = 20000; _tableMemSize = 100000; // Check whether to use MT-32 MIDI tracks in Simon the Sorcerer 2 - if (getGameType() == GType_SIMON2 && _midi.hasNativeMT32()) + if (getGameType() == GType_SIMON2 && _midi->hasNativeMT32()) _musicIndexBase = (1128 + 612) / 4; else _musicIndexBase = 1128 / 4; @@ -911,6 +913,8 @@ AGOSEngine::~AGOSEngine() { _window6BackScn->free(); delete _window6BackScn; + free(_midi); + free(_firstTimeStruct); free(_pendingDeleteTimeEvent); @@ -938,12 +942,12 @@ void AGOSEngine::pauseEngineIntern(bool pauseIt) { _keyPressed.reset(); _pause = true; - _midi.pause(true); + _midi->pause(true); _mixer->pauseAll(true); } else { _pause = false; - _midi.pause(_musicPaused); + _midi->pause(_musicPaused); _mixer->pauseAll(false); } } @@ -1027,7 +1031,7 @@ void AGOSEngine::syncSoundSettings() { int soundVolumeSFX = ConfMan.getInt("sfx_volume"); if (_midiEnabled) - _midi.setVolume((mute ? 0 : soundVolumeMusic), (mute ? 0 : soundVolumeSFX)); + _midi->setVolume((mute ? 0 : soundVolumeMusic), (mute ? 0 : soundVolumeSFX)); } } // End of namespace AGOS diff --git a/engines/agos/agos.h b/engines/agos/agos.h index aa68a05eee..b1d2e6d735 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -33,7 +33,6 @@ #include "common/stack.h" #include "common/util.h" -#include "agos/midi.h" #include "agos/sound.h" #include "agos/vga.h" @@ -50,6 +49,16 @@ * - Simon the Sorcerer 2 * - Simon the Sorcerer Puzzle Pack */ + +namespace Common { +class File; +class SeekableReadStream; +} + +namespace Graphics { +class Surface; +} + namespace AGOS { uint fileReadItemID(Common::SeekableReadStream *in); @@ -60,6 +69,8 @@ uint fileReadItemID(Common::SeekableReadStream *in); class MoviePlayer; #endif +class MidiPlayer; + struct Child; struct SubObject; @@ -548,7 +559,7 @@ protected: byte _lettersToPrintBuf[80]; - MidiPlayer _midi; + MidiPlayer *_midi; bool _midiEnabled; int _vgaTickCounter; diff --git a/engines/agos/charset-fontdata.cpp b/engines/agos/charset-fontdata.cpp index b708b4890b..2f77bcfc8b 100644 --- a/engines/agos/charset-fontdata.cpp +++ b/engines/agos/charset-fontdata.cpp @@ -20,8 +20,6 @@ * */ - - #include "common/system.h" #include "common/textconsole.h" diff --git a/engines/agos/charset.cpp b/engines/agos/charset.cpp index 9d27afaa27..7afd2da129 100644 --- a/engines/agos/charset.cpp +++ b/engines/agos/charset.cpp @@ -20,8 +20,7 @@ * */ - - +#include "common/endian.h" #include "common/system.h" #include "agos/agos.h" diff --git a/engines/agos/contain.cpp b/engines/agos/contain.cpp index ba60c65ff3..173194d45e 100644 --- a/engines/agos/contain.cpp +++ b/engines/agos/contain.cpp @@ -20,8 +20,6 @@ * */ - - #include "agos/agos.h" #include "agos/intern.h" diff --git a/engines/agos/cursor.cpp b/engines/agos/cursor.cpp index ef4a1406c9..7c64d68048 100644 --- a/engines/agos/cursor.cpp +++ b/engines/agos/cursor.cpp @@ -20,10 +20,8 @@ * */ - - +#include "common/endian.h" #include "common/events.h" -#include "common/system.h" #include "graphics/cursorman.h" diff --git a/engines/agos/debug.cpp b/engines/agos/debug.cpp index 9c44342975..18c4736031 100644 --- a/engines/agos/debug.cpp +++ b/engines/agos/debug.cpp @@ -22,7 +22,6 @@ // AGOS debug functions - #include "common/file.h" #include "common/textconsole.h" diff --git a/engines/agos/debugger.cpp b/engines/agos/debugger.cpp index a313dbbd1e..5d4d4bbbab 100644 --- a/engines/agos/debugger.cpp +++ b/engines/agos/debugger.cpp @@ -20,12 +20,11 @@ * */ - - #include "common/config-manager.h" #include "agos/debugger.h" #include "agos/agos.h" +#include "agos/midi.h" namespace AGOS { @@ -79,7 +78,7 @@ bool Debugger::Cmd_PlayMusic(int argc, const char **argv) { // TODO } else if (_vm->getGameType() == GType_SIMON2) { _vm->loadMusic(music); - _vm->_midi.startTrack(0); + _vm->_midi->startTrack(0); } else { _vm->playMusic(music, 0); } diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp index 4d66b56a96..9fc5cedbf9 100644 --- a/engines/agos/draw.cpp +++ b/engines/agos/draw.cpp @@ -20,8 +20,7 @@ * */ - - +#include "common/endian.h" #include "common/system.h" #include "graphics/surface.h" diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp index 3411e6d632..ed26b96381 100644 --- a/engines/agos/event.cpp +++ b/engines/agos/event.cpp @@ -20,8 +20,6 @@ * */ - - #include "agos/agos.h" #include "agos/animation.h" #include "agos/debugger.h" diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 0b045bae01..fbf7f416ed 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -20,8 +20,7 @@ * */ - - +#include "common/endian.h" #include "common/system.h" #include "common/textconsole.h" diff --git a/engines/agos/icons.cpp b/engines/agos/icons.cpp index ead4e49ebb..7db2d85f21 100644 --- a/engines/agos/icons.cpp +++ b/engines/agos/icons.cpp @@ -20,8 +20,6 @@ * */ - - #include "common/file.h" #include "common/system.h" #include "common/textconsole.h" diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index 2ab543a943..24e5339420 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -20,13 +20,12 @@ * */ - - #include "common/config-manager.h" #include "common/file.h" #include "agos/intern.h" #include "agos/agos.h" +#include "agos/midi.h" #include "agos/vga.h" namespace AGOS { @@ -582,14 +581,14 @@ bool AGOSEngine::processSpecialKeys() { break; case '+': if (_midiEnabled) { - _midi.setVolume(_midi.getMusicVolume() + 16, _midi.getSFXVolume() + 16); + _midi->setVolume(_midi->getMusicVolume() + 16, _midi->getSFXVolume() + 16); } ConfMan.setInt("music_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 16); syncSoundSettings(); break; case '-': if (_midiEnabled) { - _midi.setVolume(_midi.getMusicVolume() - 16, _midi.getSFXVolume() - 16); + _midi->setVolume(_midi->getMusicVolume() - 16, _midi->getSFXVolume() - 16); } ConfMan.setInt("music_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) - 16); syncSoundSettings(); @@ -597,13 +596,13 @@ bool AGOSEngine::processSpecialKeys() { case 'm': _musicPaused = !_musicPaused; if (_midiEnabled) { - _midi.pause(_musicPaused); + _midi->pause(_musicPaused); } syncSoundSettings(); break; case 's': if (getGameId() == GID_SIMON1DOS) { - _midi._enable_sfx = !_midi._enable_sfx; + _midi->_enable_sfx = !_midi->_enable_sfx; } else { _effectsPaused = !_effectsPaused; _sound->effectsPause(_effectsPaused); diff --git a/engines/agos/input_pn.cpp b/engines/agos/input_pn.cpp index 9cc97ff10f..b3a44f2b2f 100644 --- a/engines/agos/input_pn.cpp +++ b/engines/agos/input_pn.cpp @@ -20,8 +20,6 @@ * */ - - #include "agos/agos.h" #include "agos/intern.h" diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp index 0fb873a733..3bb5a132ef 100644 --- a/engines/agos/items.cpp +++ b/engines/agos/items.cpp @@ -20,8 +20,6 @@ * */ - - #include "common/file.h" #include "common/textconsole.h" diff --git a/engines/agos/menus.cpp b/engines/agos/menus.cpp index 4d62e34820..a0d2bdcaa0 100644 --- a/engines/agos/menus.cpp +++ b/engines/agos/menus.cpp @@ -20,8 +20,6 @@ * */ - - #include "common/file.h" #include "common/system.h" #include "common/textconsole.h" diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index 88f6dd80d1..9a93e0a273 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -20,14 +20,12 @@ * */ - - #include "common/config-manager.h" #include "common/file.h" -#include "common/system.h" #include "common/textconsole.h" #include "agos/agos.h" +#include "agos/midi.h" namespace AGOS { diff --git a/engines/agos/oracle.cpp b/engines/agos/oracle.cpp index 2a3c668c08..025a833b77 100644 --- a/engines/agos/oracle.cpp +++ b/engines/agos/oracle.cpp @@ -25,7 +25,6 @@ #ifdef ENABLE_AGOS2 #include "common/savefile.h" -#include "common/system.h" #include "graphics/surface.h" diff --git a/engines/agos/res_ami.cpp b/engines/agos/res_ami.cpp index b83d10364a..32adfa29e6 100644 --- a/engines/agos/res_ami.cpp +++ b/engines/agos/res_ami.cpp @@ -26,6 +26,8 @@ #include "agos/agos.h" #include "agos/intern.h" +#include "common/endian.h" + namespace AGOS { enum { diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp index 819af4fa40..9a04ce2d26 100644 --- a/engines/agos/res_snd.cpp +++ b/engines/agos/res_snd.cpp @@ -27,12 +27,12 @@ #include "agos/intern.h" #include "agos/agos.h" +#include "agos/midi.h" #include "agos/vga.h" #include "backends/audiocd/audiocd.h" #include "audio/audiostream.h" -#include "audio/mididrv.h" #include "audio/mods/protracker.h" namespace AGOS { @@ -125,10 +125,10 @@ void AGOSEngine::loadMusic(uint16 music) { _gameFile->read(buf, 4); if (!memcmp(buf, "FORM", 4)) { _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); - _midi.loadXMIDI(_gameFile); + _midi->loadXMIDI(_gameFile); } else { _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); - _midi.loadMultipleSMF(_gameFile); + _midi->loadMultipleSMF(_gameFile); } _lastMusicPlayed = music; @@ -242,20 +242,20 @@ void AGOSEngine_Simon1::playMusic(uint16 music, uint16 track) { if (music == 35) return; - _midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.) + _midi->setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.) _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); _gameFile->read(buf, 4); if (!memcmp(buf, "GMF\x1", 4)) { _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); - _midi.loadSMF(_gameFile, music); + _midi->loadSMF(_gameFile, music); } else { _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); - _midi.loadMultipleSMF(_gameFile); + _midi->loadMultipleSMF(_gameFile); } - _midi.startTrack(0); - _midi.startTrack(track); + _midi->startTrack(0); + _midi->startTrack(track); } else if (getPlatform() == Common::kPlatformAcorn) { // TODO: Add support for Desktop Tracker format in Acorn disk version } else { @@ -266,15 +266,15 @@ void AGOSEngine_Simon1::playMusic(uint16 music, uint16 track) { if (f.isOpen() == false) error("playMusic: Can't load music from '%s'", filename); - _midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.) + _midi->setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.) if (getFeatures() & GF_DEMO) - _midi.loadS1D(&f); + _midi->loadS1D(&f); else - _midi.loadSMF(&f, music); + _midi->loadSMF(&f, music); - _midi.startTrack(0); - _midi.startTrack(track); + _midi->startTrack(0); + _midi->startTrack(track); } } @@ -286,7 +286,7 @@ void AGOSEngine::playMusic(uint16 music, uint16 track) { } else if (getPlatform() == Common::kPlatformAtariST) { // TODO: Add support for music formats used } else { - _midi.setLoop(true); // Must do this BEFORE loading music. + _midi->setLoop(true); // Must do this BEFORE loading music. char filename[15]; Common::File f; @@ -295,21 +295,21 @@ void AGOSEngine::playMusic(uint16 music, uint16 track) { if (f.isOpen() == false) error("playMusic: Can't load music from '%s'", filename); - _midi.loadS1D(&f); - _midi.startTrack(0); - _midi.startTrack(track); + _midi->loadS1D(&f); + _midi->startTrack(0); + _midi->startTrack(track); } } void AGOSEngine::stopMusic() { if (_midiEnabled) { - _midi.stop(); + _midi->stop(); } _mixer->stopHandle(_modHandle); } void AGOSEngine::playSting(uint16 soundId) { - if (!_midi._enable_sfx) + if (!_midi->_enable_sfx) return; char filename[15]; @@ -328,8 +328,8 @@ void AGOSEngine::playSting(uint16 soundId) { error("playSting: Can't read sting %d offset", soundId); mus_file.seek(mus_offset, SEEK_SET); - _midi.loadSMF(&mus_file, soundId, true); - _midi.startTrack(0); + _midi->loadSMF(&mus_file, soundId, true); + _midi->startTrack(0); } static const byte elvira1_soundTable[100] = { diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index e6cce36b22..10830db002 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -22,7 +22,6 @@ #include "common/file.h" #include "common/savefile.h" -#include "common/system.h" #include "common/textconsole.h" #include "common/translation.h" diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 68a90e405b..1c36454278 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -22,8 +22,7 @@ // Item script opcodes for Simon1/Simon2 - - +#include "common/endian.h" #include "common/system.h" #include "common/textconsole.h" diff --git a/engines/agos/script_dp.cpp b/engines/agos/script_dp.cpp index a4ee249f47..f51e15dc67 100644 --- a/engines/agos/script_dp.cpp +++ b/engines/agos/script_dp.cpp @@ -24,8 +24,6 @@ #ifdef ENABLE_AGOS2 -#include "common/system.h" - #include "agos/agos.h" namespace AGOS { diff --git a/engines/agos/script_pn.cpp b/engines/agos/script_pn.cpp index 3bd8ce19a3..196350b9bf 100644 --- a/engines/agos/script_pn.cpp +++ b/engines/agos/script_pn.cpp @@ -23,6 +23,7 @@ #include "agos/agos.h" #include "agos/vga.h" +#include "common/endian.h" #include "common/textconsole.h" namespace AGOS { diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp index 0e7e66778e..350ed31068 100644 --- a/engines/agos/script_s1.cpp +++ b/engines/agos/script_s1.cpp @@ -20,7 +20,6 @@ * */ - #include "common/system.h" #include "graphics/palette.h" diff --git a/engines/agos/script_s2.cpp b/engines/agos/script_s2.cpp index c646397ac3..c35771f8ec 100644 --- a/engines/agos/script_s2.cpp +++ b/engines/agos/script_s2.cpp @@ -23,6 +23,7 @@ #include "agos/agos.h" +#include "agos/midi.h" #include "common/textconsole.h" @@ -342,11 +343,11 @@ void AGOSEngine_Simon2::os2_playTune() { // effectively preloaded so there's no latency when // starting playback). - _midi.setLoop(loop != 0); + _midi->setLoop(loop != 0); if (_lastMusicPlayed != music) _nextMusicToPlay = music; else - _midi.startTrack(track); + _midi->startTrack(track); } void AGOSEngine_Simon2::os2_screenTextPObj() { diff --git a/engines/agos/script_ww.cpp b/engines/agos/script_ww.cpp index 29a91a15aa..873f258743 100644 --- a/engines/agos/script_ww.cpp +++ b/engines/agos/script_ww.cpp @@ -22,8 +22,6 @@ -#include "common/system.h" - #include "agos/agos.h" namespace AGOS { diff --git a/engines/agos/sound.h b/engines/agos/sound.h index a7c4cd73db..ab4a3a963d 100644 --- a/engines/agos/sound.h +++ b/engines/agos/sound.h @@ -28,6 +28,10 @@ #include "agos/intern.h" #include "common/str.h" +namespace Common { +class File; +} + namespace AGOS { class BaseSound; diff --git a/engines/agos/verb.cpp b/engines/agos/verb.cpp index abc45c1ace..dec05f6703 100644 --- a/engines/agos/verb.cpp +++ b/engines/agos/verb.cpp @@ -22,7 +22,6 @@ // Verb and hitarea handling - #include "common/system.h" #include "graphics/surface.h" diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp index de6a6976e5..8541f579d6 100644 --- a/engines/agos/vga.cpp +++ b/engines/agos/vga.cpp @@ -27,6 +27,7 @@ #include "agos/intern.h" #include "agos/vga.h" +#include "common/endian.h" #include "common/system.h" #include "common/textconsole.h" diff --git a/engines/agos/vga_e2.cpp b/engines/agos/vga_e2.cpp index 1bde6945f0..d4aafd3d7b 100644 --- a/engines/agos/vga_e2.cpp +++ b/engines/agos/vga_e2.cpp @@ -26,6 +26,7 @@ #include "agos/agos.h" #include "agos/intern.h" +#include "common/endian.h" #include "common/system.h" #include "graphics/surface.h" diff --git a/engines/agos/vga_s2.cpp b/engines/agos/vga_s2.cpp index 1021ea8f94..9b9ed4e297 100644 --- a/engines/agos/vga_s2.cpp +++ b/engines/agos/vga_s2.cpp @@ -20,10 +20,9 @@ * */ - - #include "agos/agos.h" #include "agos/intern.h" +#include "agos/midi.h" #include "graphics/surface.h" @@ -146,8 +145,8 @@ void AGOSEngine::vc69_playSeq() { // specifying a non-valid track number (999 or -1) // as a means of stopping what music is currently // playing. - _midi.setLoop(loop != 0); - _midi.startTrack(track); + _midi->setLoop(loop != 0); + _midi->startTrack(track); } void AGOSEngine::vc70_joinSeq() { @@ -161,9 +160,9 @@ void AGOSEngine::vc70_joinSeq() { // track and, if not, whether to switch to // a different track upon completion. if (track != 0xFFFF && track != 999) - _midi.queueTrack(track, loop != 0); + _midi->queueTrack(track, loop != 0); else - _midi.setLoop(loop != 0); + _midi->setLoop(loop != 0); } void AGOSEngine::vc71_ifSeqWaiting() { @@ -171,7 +170,7 @@ void AGOSEngine::vc71_ifSeqWaiting() { // This command skips the next instruction // unless (1) there is a track playing, AND // (2) there is a track queued to play after it. - if (!_midi.isPlaying(true)) + if (!_midi->isPlaying(true)) vcSkipNextInstruction(); } @@ -195,8 +194,8 @@ void AGOSEngine::vc72_segue() { if (track == -1 || track == 999) { stopMusic(); } else { - _midi.setLoop(loop != 0); - _midi.startTrack(track); + _midi->setLoop(loop != 0); + _midi->startTrack(track); } } diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp index c55e3dcdda..0365c736d8 100644 --- a/engines/agos/window.cpp +++ b/engines/agos/window.cpp @@ -21,7 +21,6 @@ */ - #include "common/system.h" #include "common/textconsole.h" |