aboutsummaryrefslogtreecommitdiff
path: root/engines/hopkins/sound.cpp
diff options
context:
space:
mode:
authorStrangerke2012-12-03 07:48:37 +0100
committerStrangerke2012-12-03 07:48:37 +0100
commit5dd1776228555bdc698cae2261ace5ebc3dafa12 (patch)
treebdbb56d0fd2308f14622768df0f95e68a974a843 /engines/hopkins/sound.cpp
parent542d7fd068d0718b3e74c21251c4d28680f50b84 (diff)
downloadscummvm-rg350-5dd1776228555bdc698cae2261ace5ebc3dafa12.tar.gz
scummvm-rg350-5dd1776228555bdc698cae2261ace5ebc3dafa12.tar.bz2
scummvm-rg350-5dd1776228555bdc698cae2261ace5ebc3dafa12.zip
HOPKINS: Win95 demo is now completable
Diffstat (limited to 'engines/hopkins/sound.cpp')
-rw-r--r--engines/hopkins/sound.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp
index 08f6f4abff..6b2f5b3053 100644
--- a/engines/hopkins/sound.cpp
+++ b/engines/hopkins/sound.cpp
@@ -426,8 +426,11 @@ void SoundManager::checkVoices() {
void SoundManager::LOAD_MSAMPLE(int mwavIndex, const Common::String &file) {
if (!Mwav[mwavIndex]._active) {
Common::File f;
- if (!f.open(file))
- error("Could not open %s for reading", file.c_str());
+ if (!f.open(file)) {
+ // Fallback from WAV to APC...
+ if (!f.open(setExtension(file, ".APC")))
+ error("Could not open %s for reading", file.c_str());
+ }
Mwav[mwavIndex]._audioStream = makeSoundStream(f.readStream(f.size()));
Mwav[mwavIndex]._active = true;
@@ -722,8 +725,11 @@ bool SoundManager::DEL_SAMPLE_SDL(int wavIndex) {
bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffset, size_t entryLength, SwavItem &item) {
Common::File f;
- if (!f.open(filename))
- error("Could not open %s for reading", filename.c_str());
+ if (!f.open(filename)) {
+ // Fallback from WAV to APC...
+ if (!f.open(setExtension(filename, ".APC")))
+ error("Could not open %s for reading", filename.c_str());
+ }
f.seek(fileOffset);
item._audioStream = makeSoundStream(f.readStream((entryLength == 0) ? f.size() : entryLength));
@@ -836,4 +842,15 @@ Audio::RewindableAudioStream *SoundManager::makeSoundStream(Common::SeekableRead
return Audio::makeWAVStream(stream, DisposeAfterUse::YES);
}
+// Blatant rip from gob engine. Hi DrMcCoy!
+Common::String SoundManager::setExtension(const Common::String &str, const Common::String &ext) {
+ if (str.empty())
+ return str;
+
+ const char *dot = strrchr(str.c_str(), '.');
+ if (dot)
+ return Common::String(str.c_str(), dot - str.c_str()) + ext;
+
+ return str + ext;
+}
} // End of namespace Hopkins