diff options
author | Travis Howell | 2006-10-19 05:37:22 +0000 |
---|---|---|
committer | Travis Howell | 2006-10-19 05:37:22 +0000 |
commit | 8c72861de463e0db36b234750fb19904e5f04d3b (patch) | |
tree | 9b8139009ee2510033fc3392f2daab1d8b737e35 | |
parent | ed3c6871f967ab15321df14ca6a026e08d96fae1 (diff) | |
download | scummvm-rg350-8c72861de463e0db36b234750fb19904e5f04d3b.tar.gz scummvm-rg350-8c72861de463e0db36b234750fb19904e5f04d3b.tar.bz2 scummvm-rg350-8c72861de463e0db36b234750fb19904e5f04d3b.zip |
Add option to load a module via stream
svn-id: r24387
-rw-r--r-- | engines/agos/agos.cpp | 16 | ||||
-rw-r--r-- | engines/agos/agos.h | 4 | ||||
-rw-r--r-- | sound/mods/module.cpp | 10 | ||||
-rw-r--r-- | sound/mods/module.h | 3 | ||||
-rw-r--r-- | sound/mods/protracker.cpp | 8 | ||||
-rw-r--r-- | sound/mods/protracker.h | 1 |
6 files changed, 34 insertions, 8 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 92c6acc138..c55aed0221 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -34,6 +34,7 @@ #include "agos/vga.h" #include "sound/mididrv.h" +#include "sound/mods/protracker.h" #ifdef PALMOS_68K #include "globals.h" @@ -386,6 +387,7 @@ AGOSEngine::AGOSEngine(OSystem *syst) _vgaTickCounter = 0; + _modPlayer = 0; _moviePlay = 0; _sound = 0; @@ -510,9 +512,12 @@ int AGOSEngine::init() { setupGame(); _debugger = new Debugger(this); - _moviePlay = new MoviePlayer(this, _mixer); + _modPlayer = new Modules::ProtrackerPlayer(); _sound = new Sound(this, gss, _mixer); + _modPlayer->init(_system); + _moviePlay = new MoviePlayer(this, _mixer); + if (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute") == 1) { if (getGameId() == GID_SIMON1DOS) midi._enable_sfx ^= 1; @@ -757,6 +762,7 @@ AGOSEngine::~AGOSEngine() { delete [] _windowList; delete _debugger; + delete _modPlayer; delete _moviePlay; delete _sound; } @@ -1353,8 +1359,7 @@ startOver: if (getGameType() != GType_FF && getGameType() != GType_PP && _keyPressed == 35) displayBoxStars(); if (processSpecialKeys() != 0) { - _needHitAreaRecalc++; - return; + goto out_of_here; } if (_lastHitArea3 == (HitArea *) -1) goto startOver; @@ -1472,6 +1477,7 @@ startOver: } } +out_of_here: if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) clearMenuStrip(); @@ -2434,7 +2440,6 @@ void AGOSEngine::loadMusic(uint music) { if (getPlatform() == Common::kPlatformAtariST) { // TODO: Add support for music format used by Elvira 2 } else if (getPlatform() == Common::kPlatformAmiga) { - /* _modPlayer->stop(); char filename[15]; @@ -2447,7 +2452,7 @@ void AGOSEngine::loadMusic(uint music) { f.open(filename); if (f.isOpen() == false) { - error("loadMusic: Can't load music from '%s'", filename); + error("loadMusic: Can't load module from '%s'", filename); } if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) && @@ -2468,7 +2473,6 @@ void AGOSEngine::loadMusic(uint music) { _modPlayer->loadModuleStream(f); } _modPlayer->start(); - */ } else if (getGameType() == GType_SIMON2) { midi.stop(); _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 7ac04fd569..01006862e2 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -33,8 +33,11 @@ #include "agos/midi.h" #include "agos/sound.h" #include "agos/vga.h" + #include "common/advancedDetector.h" +#include "sound/mods/protracker.h" + namespace AGOS { /* Various other settings */ @@ -492,6 +495,7 @@ protected: int _vgaTickCounter; MoviePlayer *_moviePlay; + Modules::ProtrackerPlayer *_modPlayer; Sound *_sound; diff --git a/sound/mods/module.cpp b/sound/mods/module.cpp index f7f343fde5..4c20c3a741 100644 --- a/sound/mods/module.cpp +++ b/sound/mods/module.cpp @@ -46,6 +46,14 @@ bool Module::load(const char *fn) { Common::MemoryReadStream st(buf, bufsz); + bool result = loadStream(st); + + delete[] buf; + + return result; +} + +bool Module::loadStream(Common::SeekableReadStream &st) { st.read(songname, 20); songname[0] = '\0'; @@ -155,8 +163,6 @@ bool Module::load(const char *fn) { assert(st.eos()); - delete[] buf; - return true; } diff --git a/sound/mods/module.h b/sound/mods/module.h index f16d3eb4f4..4073d5d4ec 100644 --- a/sound/mods/module.h +++ b/sound/mods/module.h @@ -24,6 +24,8 @@ #ifndef SOUND_MODS_MODULE_H #define SOUND_MODS_MODULE_H +#include "common/file.h" + namespace Modules { /* @@ -68,6 +70,7 @@ public: ~Module(); bool load(const char *fn); + bool loadStream(Common::SeekableReadStream &st); }; } // End of namespace Modules diff --git a/sound/mods/protracker.cpp b/sound/mods/protracker.cpp index 2a308407e4..8948ae4c20 100644 --- a/sound/mods/protracker.cpp +++ b/sound/mods/protracker.cpp @@ -78,6 +78,14 @@ void ProtrackerPlayer::loadModule(const char *fn) { _module->load(fn); } +void ProtrackerPlayer::loadModuleStream(Common::SeekableReadStream &fs) { + if (_module) + delete _module; + + _module = new Module(); + _module->loadStream(fs); +} + void ProtrackerPlayer::generateSound() { _generatedSamplesOverflow += 5.0 * 44100.0 / (2.0 * _bpm); int samples = (int)floor(_generatedSamplesOverflow); diff --git a/sound/mods/protracker.h b/sound/mods/protracker.h index 070f972d4a..c6511e8a47 100644 --- a/sound/mods/protracker.h +++ b/sound/mods/protracker.h @@ -139,6 +139,7 @@ public: void stop(); void loadModule(const char *fn); + void loadModuleStream(Common::SeekableReadStream &fs); void mix(byte *buf, int len); |