aboutsummaryrefslogtreecommitdiff
path: root/engines/saga
diff options
context:
space:
mode:
authorFilippos Karapetis2009-01-04 14:38:03 +0000
committerFilippos Karapetis2009-01-04 14:38:03 +0000
commit203358bcb70a8fe0954feccd2c7559ea7d9ade35 (patch)
tree7964da5c3b0bb9de3edc7e3b31dd5c04c847a0a3 /engines/saga
parentf2b495ba2d31fc6cdfd07130c9491dea026c07cb (diff)
downloadscummvm-rg350-203358bcb70a8fe0954feccd2c7559ea7d9ade35.tar.gz
scummvm-rg350-203358bcb70a8fe0954feccd2c7559ea7d9ade35.tar.bz2
scummvm-rg350-203358bcb70a8fe0954feccd2c7559ea7d9ade35.zip
Improved handling of sound resources
svn-id: r35724
Diffstat (limited to 'engines/saga')
-rw-r--r--engines/saga/detection.cpp3
-rw-r--r--engines/saga/detection_tables.h4
-rw-r--r--engines/saga/music.cpp7
-rw-r--r--engines/saga/resource.cpp19
-rw-r--r--engines/saga/resource.h1
-rw-r--r--engines/saga/saga.cpp1
-rw-r--r--engines/saga/saga.h13
-rw-r--r--engines/saga/sndres.cpp14
-rw-r--r--engines/saga/sound.cpp2
-rw-r--r--engines/saga/sound.h1
10 files changed, 35 insertions, 30 deletions
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp
index c54953737c..8dc1e91eea 100644
--- a/engines/saga/detection.cpp
+++ b/engines/saga/detection.cpp
@@ -84,9 +84,6 @@ uint32 SagaEngine::getFeatures() const {
if (_gf_wyrmkeep)
result |= GF_WYRMKEEP;
- if (_gf_compressed_sounds)
- result |= GF_COMPRESSED_SOUNDS;
-
return result;
}
diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h
index 747882f916..ae9d8b5148 100644
--- a/engines/saga/detection_tables.h
+++ b/engines/saga/detection_tables.h
@@ -229,7 +229,7 @@ static const SAGAGameDescription gameDescriptions[] = {
Common::ADGF_DEMO
},
GID_ITE,
- GF_WYRMKEEP | GF_SCENE_SUBSTITUTES | GF_MONO_MUSIC,
+ GF_WYRMKEEP | GF_SCENE_SUBSTITUTES | GF_MONO_MUSIC | GF_LE_VOICES,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEWINDEMO_GameFonts),
@@ -256,7 +256,7 @@ static const SAGAGameDescription gameDescriptions[] = {
Common::ADGF_DEMO
},
GID_ITE,
- GF_WYRMKEEP | GF_NON_INTERACTIVE,
+ GF_WYRMKEEP | GF_NON_INTERACTIVE | GF_LE_VOICES,
ITE_DEFAULT_SCENE,
&ITE_Resources,
ARRAYSIZE(ITEWINDEMO_GameFonts),
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index 8ed978791f..cbe7a9113c 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -96,12 +96,7 @@ DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext
_compressedStream = NULL;
- // FIXME: It is a bad idea to use the File::getName() method to distinguish
- // files here (note that it is for debugging purposes only, though that was
- // not correctly documented in the past).
- // A better way is to keep track of this via some flag, which indicates
- // whether the music file contains compressed data.
- if (scumm_stricmp(_file->getName(), "music.cmp") == 0 || scumm_stricmp(_file->getName(), "musicd.cmp") == 0) {
+ if (context->isCompressed) {
// Read compressed header to determine compression type
_file->seek((long)resourceData->offset, SEEK_SET);
_file->read(compressedHeader, 9);
diff --git a/engines/saga/resource.cpp b/engines/saga/resource.cpp
index 163a049595..755caa2946 100644
--- a/engines/saga/resource.cpp
+++ b/engines/saga/resource.cpp
@@ -205,6 +205,8 @@ bool Resource::createContexts() {
bool soundFileInArray = false;
bool multipleVoices = false;
bool censoredVersion = false;
+ bool compressedSounds = false;
+ bool compressedMusic = false;
uint16 voiceFileType = GAME_VOICEFILE;
bool fileFound = false;
int maxFile = 0;
@@ -284,7 +286,7 @@ bool Resource::createContexts() {
_contextsCount++;
soundFileIndex = _contextsCount - 1;
strcpy(soundFileName, curSoundfiles[i].fileName);
- _vm->_gf_compressed_sounds = curSoundfiles[i].isCompressed;
+ compressedSounds = curSoundfiles[i].isCompressed;
fileFound = true;
break;
}
@@ -358,7 +360,7 @@ bool Resource::createContexts() {
_contextsCount++;
voicesFileIndex = _contextsCount - 1;
strcpy(_voicesFileName[0], curSoundfiles[i].fileName);
- _vm->_gf_compressed_sounds = curSoundfiles[i].isCompressed;
+ compressedSounds = curSoundfiles[i].isCompressed;
fileFound = true;
// Special cases
@@ -406,11 +408,10 @@ bool Resource::createContexts() {
}
//// Detect and add ITE music files /////////////////////////////////////////
- // We don't set the compressed flag here
SoundFileInfo musicFilesITE[] = {
- { "music.rsc", true },
+ { "music.rsc", false },
{ "music.cmp", true },
- { "musicd.rsc", true },
+ { "musicd.rsc", false },
{ "musicd.cmp", true },
};
@@ -422,6 +423,7 @@ bool Resource::createContexts() {
if (Common::File::exists(musicFilesITE[i].fileName)) {
_contextsCount++;
digitalMusic = true;
+ compressedMusic = musicFilesITE[i].isCompressed;
fileFound = true;
strcpy(musicFileName, musicFilesITE[i].fileName);
break;
@@ -445,27 +447,32 @@ bool Resource::createContexts() {
if (_vm->getGameId() == GID_ITE && digitalMusic && i == _contextsCount - 1) {
context->fileName = musicFileName;
context->fileType = GAME_MUSICFILE;
+ context->isCompressed = compressedMusic;
} else if (!soundFileInArray && i == soundFileIndex) {
context->fileName = soundFileName;
context->fileType = GAME_SOUNDFILE;
+ context->isCompressed = compressedSounds;
} else if (_vm->_voiceFilesExist && i == voicesFileIndex && !(_vm->getGameId() == GID_IHNM && _vm->isMacResources())) {
context->fileName = _voicesFileName[0];
// can be GAME_VOICEFILE or GAME_SOUNDFILE | GAME_VOICEFILE or GAME_VOICEFILE | GAME_SWAPENDIAN
context->fileType = voiceFileType;
+ context->isCompressed = compressedSounds;
} else {
if (!(_vm->_voiceFilesExist && multipleVoices && (i > voicesFileIndex))) {
context->fileName = _vm->getFilesDescriptions()[i].fileName;
context->fileType = _vm->getFilesDescriptions()[i].fileType;
+ context->isCompressed = compressedSounds;
} else {
int token = (censoredVersion && (i - voicesFileIndex >= 4)) ? 1 : 0; // censored versions don't have voice4
- if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS)
+ if (compressedSounds)
sprintf(_voicesFileName[i - voicesFileIndex + token], "voices%i.cmp", i - voicesFileIndex + token);
else
sprintf(_voicesFileName[i - voicesFileIndex + token], "voices%i.res", i - voicesFileIndex + token);
context->fileName = _voicesFileName[i - voicesFileIndex + token];
context->fileType = GAME_VOICEFILE;
+ context->isCompressed = compressedSounds;
// IHNM has several different voice files, so we need to allow
// multiple resource contexts of the same type. We tell them
diff --git a/engines/saga/resource.h b/engines/saga/resource.h
index 90afee78d9..f861f0f52e 100644
--- a/engines/saga/resource.h
+++ b/engines/saga/resource.h
@@ -71,6 +71,7 @@ struct ResourceContext {
Common::File *file;
int serial; // IHNM speech files
+ bool isCompressed;
bool isBigEndian;
ResourceData *table;
size_t count;
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index b24ae7a8fb..263119645b 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -157,7 +157,6 @@ Common::Error SagaEngine::init() {
_readingSpeed = getTalkspeed();
_copyProtection = ConfMan.getBool("copy_protection");
_gf_wyrmkeep = false;
- _gf_compressed_sounds = false;
_musicWasPlaying = false;
if (_readingSpeed > 3)
diff --git a/engines/saga/saga.h b/engines/saga/saga.h
index 62c88f693d..2a9faed883 100644
--- a/engines/saga/saga.h
+++ b/engines/saga/saga.h
@@ -118,12 +118,12 @@ enum GameFeatures {
GF_WYRMKEEP = 1 << 0,
GF_ITE_FLOPPY = 1 << 1,
GF_SCENE_SUBSTITUTES = 1 << 2,
- GF_COMPRESSED_SOUNDS = 1 << 3,
- GF_NON_INTERACTIVE = 1 << 4,
- GF_OLD_ITE_DOS = 1 << 5,
- GF_MONO_MUSIC = 1 << 6,
- GF_EXTRA_ITE_CREDITS = 1 << 7,
- GF_IHNM_DEMO = 1 << 8
+ GF_NON_INTERACTIVE = 1 << 3,
+ GF_OLD_ITE_DOS = 1 << 4,
+ GF_MONO_MUSIC = 1 << 5,
+ GF_EXTRA_ITE_CREDITS = 1 << 6,
+ GF_IHNM_DEMO = 1 << 7,
+ GF_LE_VOICES = 1 << 8
};
enum VerbTypeIds {
@@ -495,7 +495,6 @@ public:
bool _copyProtection;
bool _gf_wyrmkeep;
- bool _gf_compressed_sounds;
bool _musicWasPlaying;
SndRes *_sndRes;
diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp
index f7c3b07beb..d21dcb92e2 100644
--- a/engines/saga/sndres.cpp
+++ b/engines/saga/sndres.cpp
@@ -130,6 +130,8 @@ void SndRes::setVoiceBank(int serial) {
_voiceContext->fileType = GAME_VOICEFILE;
_voiceContext->count = 0;
_voiceContext->serial = 0;
+ _voiceContext->isBigEndian = true;
+ _voiceContext->isCompressed = false;
return;
}
#endif
@@ -219,6 +221,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
file->open(soundFileName);
soundResourceLength = file->size();
+ context->isBigEndian = true;
} else
#endif
{
@@ -231,7 +234,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
Common::SeekableReadStream& readS = *file;
- if ((context->fileType & GAME_VOICEFILE) != 0) {
+ if (context->fileType & GAME_VOICEFILE) {
soundInfo = _vm->getVoiceInfo();
} else {
soundInfo = _vm->getSfxInfo();
@@ -265,7 +268,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
if (_vm->getGameId() == GID_IHNM && (context->fileType & GAME_SOUNDFILE))
uncompressedSound = true;
- if ((_vm->getFeatures() & GF_COMPRESSED_SOUNDS) && !uncompressedSound) {
+ if (context->isCompressed && !uncompressedSound) {
if (header[0] == char(0)) {
resourceType = kSoundMP3;
} else if (header[0] == char(1)) {
@@ -277,7 +280,10 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
}
- buffer.isBigEndian = _vm->isMacResources();
+ buffer.isBigEndian = context->isBigEndian;
+ if ((context->fileType & GAME_VOICEFILE) && (_vm->getFeatures() & GF_LE_VOICES))
+ buffer.isBigEndian = false;
+ buffer.isCompressed = context->isCompressed;
buffer.soundType = resourceType;
buffer.originalSize = 0;
buffer.stereo = false;
@@ -398,7 +404,7 @@ int SndRes::getVoiceLength(uint32 resourceId) {
return -1;
}
- if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS) || buffer.originalSize == 0)
+ if (!_voiceContext->isCompressed || buffer.originalSize == 0)
msDouble = (double)buffer.size;
else
msDouble = (double)buffer.originalSize;
diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp
index 50d4a2a766..fb7acaca8c 100644
--- a/engines/saga/sound.cpp
+++ b/engines/saga/sound.cpp
@@ -83,7 +83,7 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int
if (!buffer.isSigned)
flags |= Audio::Mixer::FLAG_UNSIGNED;
- if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) {
+ if (!buffer.isCompressed) {
if (handleType == kVoiceHandle)
_mixer->playRaw(Audio::Mixer::kSpeechSoundType, handle, buffer.buffer,
buffer.size, buffer.frequency, flags, -1, volume);
diff --git a/engines/saga/sound.h b/engines/saga/sound.h
index cf6ca4a1a0..b61cbbbe90 100644
--- a/engines/saga/sound.h
+++ b/engines/saga/sound.h
@@ -47,6 +47,7 @@ struct SoundBuffer {
int sampleBits;
bool stereo;
bool isSigned;
+ bool isCompressed;
byte *buffer;
size_t size;