diff options
author | Paul Gilbert | 2016-09-18 10:22:49 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-09-18 10:22:49 -0400 |
commit | a39da343b7dd0ea69c481c3f0a5346a9134ae736 (patch) | |
tree | 95a738f2e4500982900a5fcd156564d62edef6c1 /engines | |
parent | 2bec9c5a0cfc9f339ce04460c9d6bd3b8633f1b2 (diff) | |
download | scummvm-rg350-a39da343b7dd0ea69c481c3f0a5346a9134ae736.tar.gz scummvm-rg350-a39da343b7dd0ea69c481c3f0a5346a9134ae736.tar.bz2 scummvm-rg350-a39da343b7dd0ea69c481c3f0a5346a9134ae736.zip |
XEEN: Support switching between fx & game music, fx fixes
Diffstat (limited to 'engines')
-rw-r--r-- | engines/xeen/files.cpp | 26 | ||||
-rw-r--r-- | engines/xeen/files.h | 15 | ||||
-rw-r--r-- | engines/xeen/music.cpp | 52 | ||||
-rw-r--r-- | engines/xeen/music.h | 26 | ||||
-rw-r--r-- | engines/xeen/worldofxeen/darkside_cutscenes.cpp | 4 | ||||
-rw-r--r-- | engines/xeen/worldofxeen/worldofxeen.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 1 |
7 files changed, 85 insertions, 41 deletions
diff --git a/engines/xeen/files.cpp b/engines/xeen/files.cpp index 443a296bd4..b928677aac 100644 --- a/engines/xeen/files.cpp +++ b/engines/xeen/files.cpp @@ -189,6 +189,7 @@ FileManager::FileManager(XeenEngine *vm) { Common::File f; int sideNum = 0; + File::_currentArchive = ANY_ARCHIVE; _isDarkCc = vm->getGameID() == GType_DarkSide; _archives[0] = _archives[1] = _archives[2] = nullptr; @@ -207,8 +208,6 @@ FileManager::FileManager(XeenEngine *vm) { _archives[2] = new CCArchive("intro.cc", "intro", true); SearchMan.add("intro", _archives[2]); } - - File::_currentArchive = GAME_ARCHIVE; } void FileManager::setGameCc(bool isDarkCc) { @@ -220,11 +219,20 @@ void FileManager::setGameCc(bool isDarkCc) { ArchiveType File::_currentArchive; +File::File(const Common::String &filename) { + File::open(filename); +} + +File::File(const Common::String &filename, ArchiveType archiveType) { + File::open(filename, archiveType); +} + +File::File(const Common::String &filename, Common::Archive &archive) { + File::open(filename, archive); +} + bool File::open(const Common::String &filename) { - CCArchive &arc = *FileManager::_archives[_currentArchive]; - if (!Common::File::open(filename)) - error("Could not open file - %s", filename.c_str()); - return true; + return File::open(filename, _currentArchive); } bool File::open(const Common::String &filename, ArchiveType archiveType) { @@ -232,7 +240,10 @@ bool File::open(const Common::String &filename, ArchiveType archiveType) { Common::File::open(filename); } else { CCArchive &archive = *FileManager::_archives[archiveType]; - Common::File::open(filename, archive); + if (!Common::File::open(filename, archive)) + // If not in the designated archive, try opening from any archive, + // or as a standalone file in the filesystem + Common::File::open(filename); } if (!isOpen()) @@ -243,6 +254,7 @@ bool File::open(const Common::String &filename, ArchiveType archiveType) { bool File::open(const Common::String &filename, Common::Archive &archive) { if (!Common::File::open(filename, archive)) error("Could not open file - %s", filename.c_str()); + return true; } Common::String File::readString() { diff --git a/engines/xeen/files.h b/engines/xeen/files.h index 75389ff60e..fa595976f4 100644 --- a/engines/xeen/files.h +++ b/engines/xeen/files.h @@ -81,15 +81,16 @@ public: class File : public Common::File { public: static ArchiveType _currentArchive; + + /** + * Sets which archive is used by default + */ + static void setCurrentArchive(ArchiveType arcType) { _currentArchive = arcType; } public: File() : Common::File() {} - File(const Common::String &filename) { File::open(filename); } - File(const Common::String &filename, ArchiveType archiveType) { - File::open(filename, archiveType); - } - File(const Common::String &filename, Common::Archive &archive) { - open(filename, archive); - } + File(const Common::String &filename); + File(const Common::String &filename, ArchiveType archiveType); + File(const Common::String &filename, Common::Archive &archive); virtual ~File() {} /** diff --git a/engines/xeen/music.cpp b/engines/xeen/music.cpp index 19a836b12f..ef6bb6237a 100644 --- a/engines/xeen/music.cpp +++ b/engines/xeen/music.cpp @@ -34,7 +34,7 @@ namespace Xeen { MusicDriver::MusicDriver() : _musicPlaying(false), _fxPlaying(false), _musCountdownTimer(0), _fxCountdownTimer(0), _musDataPtr(nullptr), _fxDataPtr(nullptr), _fxStartPtr(nullptr), _musStartPtr(nullptr), - _exclude7(0), _frameCtr(0) { + _exclude7(false), _frameCtr(0) { _channels.resize(CHANNEL_COUNT); } @@ -204,13 +204,21 @@ void MusicDriver::playFX(uint effectId, const byte *data) { _fxDataPtr = _fxStartPtr = data; _fxCountdownTimer = 0; _channels[7]._changeFrequency = _channels[8]._changeFrequency = false; - stopFX(); + resetFX(); _fxPlaying = true; } debugC(1, kDebugSound, "Starting FX %d", effectId); } +void MusicDriver::stopFX() { + if (_fxPlaying) { + resetFX(); + _fxPlaying = false; + _fxStartPtr = _fxDataPtr = nullptr; + } +} + void MusicDriver::playSong(const byte *data) { _musDataPtr = _musStartPtr = data; _musSubroutines.clear(); @@ -283,7 +291,7 @@ void AdlibMusicDriver::initialize() { write(0xBD, 0); resetFrequencies(); - AdlibMusicDriver::stopFX(); + AdlibMusicDriver::resetFX(); } void AdlibMusicDriver::playFX(uint effectId, const byte *data) { @@ -387,7 +395,7 @@ void AdlibMusicDriver::pausePostProcess() { } } -void AdlibMusicDriver::stopFX() { +void AdlibMusicDriver::resetFX() { if (!_exclude7) { _channels[7]._frequency = 0; setFrequency(7, 0); @@ -399,7 +407,6 @@ void AdlibMusicDriver::stopFX() { setFrequency(8, 0); _channels[8]._volume = 63; setOutputLevel(8, 63); - _fxPlaying = false; } void AdlibMusicDriver::resetFrequencies() { @@ -604,7 +611,8 @@ bool AdlibMusicDriver::fxStartNote(const byte *&srcP, byte param) { debugC(3, kDebugSound, "fxStartNote %x -> %x", note, freq); setFrequency(param, freq); - _channels[param]._frequency = freq | 0x2000; + freq |= 0x2000; + _channels[param]._frequency = freq; setFrequency(param, freq); } else { ++srcP; @@ -626,7 +634,7 @@ bool AdlibMusicDriver::fxPlayInstrument(const byte *&srcP, byte param) { byte instrument = *srcP++; debugC(3, kDebugSound, "fxPlayInstrument %d, %d", param, instrument); - if (_exclude7 != 2 || param != 7) + if (!_exclude7 || param != 7) playInstrument(param, _fxInstrumentPtrs[instrument]); return false; @@ -667,27 +675,35 @@ void Music::loadEffectsData() { return; // Stop any prior FX - _musicDriver->stopFX(); - + stopFX(); + delete[] _effectsData; + _archiveType = File::_currentArchive; - // Load in the entire driver so we have quick access to the effects data + // Load in an entire driver so we have quick access to the effects data // that's hardcoded within it - File file("promus"); + File file("blastmus"); byte *effectsData = new byte[file.size()]; file.seek(0); file.read(effectsData, file.size()); file.close(); _effectsData = effectsData; + // Locate the playFX routine + const byte *playFX = effectsData + READ_LE_UINT16(effectsData + 10) + 12; + assert(READ_BE_UINT16(playFX + 28) == 0x81FB); + uint numEffects = READ_LE_UINT16(playFX + 30); + + assert(READ_BE_UINT16(playFX + 36) == 0x8B87); + const byte *table = effectsData + READ_LE_UINT16(playFX + 38); + // Extract the effects offsets - _effectsOffsets.resize(180); - const int EFFECTS_OFFSET = 0x91D; - for (int idx = 0; idx < 180; ++idx) - _effectsOffsets[idx] = READ_LE_UINT16(&effectsData[EFFECTS_OFFSET + idx * 2]); + _effectsOffsets.resize(numEffects); + for (uint idx = 0; idx < numEffects; ++idx) + _effectsOffsets[idx] = READ_LE_UINT16(&table[idx * 2]); } void Music::playFX(uint effectId) { - _musicDriver->stopFX(); + stopFX(); loadEffectsData(); if (effectId < _effectsOffsets.size()) { @@ -696,6 +712,10 @@ void Music::playFX(uint effectId) { } } +void Music::stopFX() { + _musicDriver->stopFX(); +} + int Music::songCommand(uint commandId, byte volume) { int result = _musicDriver->songCommand(commandId, volume); if (commandId == STOP_SONG) { diff --git a/engines/xeen/music.h b/engines/xeen/music.h index 1182be4377..d675a37d08 100644 --- a/engines/xeen/music.h +++ b/engines/xeen/music.h @@ -91,7 +91,7 @@ private: bool command(const byte *&srcP); protected: Common::Array<Channel> _channels; - int _exclude7; + bool _exclude7; bool _musicPlaying; bool _fxPlaying; protected: @@ -136,6 +136,11 @@ protected: * Post-processing done when a pause countdown starts or is in progress */ virtual void pausePostProcess() = 0; + + /** + * Does a reset of any sound effect + */ + virtual void resetFX() = 0; public: /** * Constructor @@ -153,9 +158,9 @@ public: virtual void playFX(uint effectId, const byte *data); /** - * Does a reset of any sound effect + * Stop any playing FX */ - virtual void stopFX() = 0; + void stopFX(); /** * Plays a song @@ -262,6 +267,11 @@ protected: * Post-processing done when a pause countdown starts or is in progress */ virtual void pausePostProcess(); + + /** + * Does a reset of any sound effect + */ + virtual void resetFX(); public: /** * Constructor @@ -279,11 +289,6 @@ public: virtual void playFX(uint effectId, const byte *data); /** - * Does a reset of any sound effect - */ - virtual void stopFX(); - - /** * Plays a song */ virtual void playSong(const byte *data); @@ -322,6 +327,11 @@ public: void playFX(uint effectId); /** + * Stops any currently playing FX + */ + void stopFX(); + + /** * Executes special music command */ int songCommand(uint commandId, byte volume = 0); diff --git a/engines/xeen/worldofxeen/darkside_cutscenes.cpp b/engines/xeen/worldofxeen/darkside_cutscenes.cpp index d9c4fe90d9..68e3913e17 100644 --- a/engines/xeen/worldofxeen/darkside_cutscenes.cpp +++ b/engines/xeen/worldofxeen/darkside_cutscenes.cpp @@ -54,9 +54,7 @@ bool DarkSideCutscenes::showDarkSideTitle() { screen.fadeIn(4); sound.setMusicVolume(0x5f); - sound.playFX(2); - events.wait(1000, true); - int64 v = 0; + sound.playFX(1); // Initial loop for dragon roaring int nwcIndex = 0, nwcFrame = 0; diff --git a/engines/xeen/worldofxeen/worldofxeen.cpp b/engines/xeen/worldofxeen/worldofxeen.cpp index 86a6ee3da7..a71efbb162 100644 --- a/engines/xeen/worldofxeen/worldofxeen.cpp +++ b/engines/xeen/worldofxeen/worldofxeen.cpp @@ -34,6 +34,8 @@ WorldOfXeenEngine::WorldOfXeenEngine(OSystem *syst, const XeenGameDescription *g } void WorldOfXeenEngine::showIntro() { + File::setCurrentArchive(INTRO_ARCHIVE); + // **DEBUG** if (gDebugLevel == 0) return; diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 153228cefb..a07bf1b8af 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -123,6 +123,7 @@ Common::Error XeenEngine::run() { showIntro(); if (shouldQuit()) return Common::kNoError; + File::setCurrentArchive(GAME_ARCHIVE); showMainMenu(); if (shouldQuit()) |