aboutsummaryrefslogtreecommitdiff
path: root/engines/saga
diff options
context:
space:
mode:
authorFilippos Karapetis2009-01-01 16:02:43 +0000
committerFilippos Karapetis2009-01-01 16:02:43 +0000
commit41dce61a30c30487d09020137176ceff504d0dff (patch)
treec8bd19e618758fb6800a22b5667b32fb69bbc1a0 /engines/saga
parent696897b0583ad52ebc6f7666525277847619a8ce (diff)
downloadscummvm-rg350-41dce61a30c30487d09020137176ceff504d0dff.tar.gz
scummvm-rg350-41dce61a30c30487d09020137176ceff504d0dff.tar.bz2
scummvm-rg350-41dce61a30c30487d09020137176ceff504d0dff.zip
Simplified sound resource loading
svn-id: r35649
Diffstat (limited to 'engines/saga')
-rw-r--r--engines/saga/detection_tables.h5
-rw-r--r--engines/saga/saga.h11
-rw-r--r--engines/saga/sndres.cpp97
3 files changed, 36 insertions, 77 deletions
diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h
index da0874bf0d..2381f59681 100644
--- a/engines/saga/detection_tables.h
+++ b/engines/saga/detection_tables.h
@@ -118,7 +118,6 @@ static const GameFontDescription IHNMCD_GameFonts[] = { {2}, {3}, {4}, {5},
// sampleBits, isSigned
static const GameSoundInfo ITE_GameSound = { kSoundPCM, 16, true };
static const GameSoundInfo ITEWINDEMO1_GameSound = { kSoundPCM, 8, false };
-static const GameSoundInfo ITEMACCD_G_GameSound = { kSoundMacPCM, 8, false };
static const GameSoundInfo ITEDEMO_GameVoice = { kSoundVOX, 16, true };
// Patch files. Files not found will be ignored
@@ -350,8 +349,8 @@ static const SAGAGameDescription gameDescriptions[] = {
&ITE_Resources,
ARRAYSIZE(ITEWINDEMO_GameFonts),
ITEWINDEMO_GameFonts,
- &ITEMACCD_G_GameSound,
- &ITEMACCD_G_GameSound,
+ &ITE_GameSound,
+ &ITE_GameSound,
NULL,
},
diff --git a/engines/saga/saga.h b/engines/saga/saga.h
index 3d6d9b9db3..397f262736 100644
--- a/engines/saga/saga.h
+++ b/engines/saga/saga.h
@@ -196,12 +196,11 @@ enum GameSoundTypes {
kSoundVOX = 1,
kSoundVOC = 2,
kSoundWAV = 3,
- kSoundMacPCM = 4,
- kSoundMP3 = 5,
- kSoundOGG = 6,
- kSoundFLAC = 7,
- kSoundAIFF = 8,
- kSoundShorten = 9
+ kSoundMP3 = 4,
+ kSoundOGG = 5,
+ kSoundFLAC = 6,
+ kSoundAIFF = 7,
+ kSoundShorten = 8
};
enum TextStringIds {
diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp
index 38dacf0667..03e93a54e2 100644
--- a/engines/saga/sndres.cpp
+++ b/engines/saga/sndres.cpp
@@ -178,10 +178,10 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
size_t soundResourceLength;
bool result = false;
GameSoundTypes resourceType;
- byte *data;
+ byte *data = 0;
int rate;
int size;
- byte flags;
+ byte flags = 0;
size_t voxSize;
const GameSoundInfo *soundInfo = 0;
Common::File* file;
@@ -270,35 +270,30 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
buffer.soundType = resourceType;
buffer.originalSize = 0;
buffer.stereo = false;
+ buffer.frequency = 22050; // default for PCM and VOX
+ buffer.buffer = NULL;
+
+ // Older Mac versions of ITE were Macbinary packed
+ int soundOffset = (context->fileType & GAME_MACBINARY) ? 36 : 0;
switch (resourceType) {
case kSoundPCM:
- case kSoundMacPCM:
- {
- int soundOffset = (resourceType == kSoundMacPCM) ? 36 : 0;
- buffer.frequency = 22050;
buffer.isSigned = soundInfo->isSigned;
buffer.sampleBits = soundInfo->sampleBits;
buffer.size = soundResourceLength - soundOffset;
- if (onlyHeader) {
- buffer.buffer = NULL;
- } else {
+ if (!onlyHeader) {
buffer.buffer = (byte *) malloc(buffer.size);
if (soundOffset > 0)
readS.seek(soundOffset, SEEK_CUR);
readS.read(buffer.buffer, buffer.size);
}
result = true;
- }
break;
case kSoundVOX:
- buffer.frequency = 22050;
buffer.isSigned = soundInfo->isSigned;
buffer.sampleBits = soundInfo->sampleBits;
buffer.size = soundResourceLength * 4;
- if (onlyHeader) {
- buffer.buffer = NULL;
- } else {
+ if (!onlyHeader) {
voxStream = Audio::makeADPCMStream(&readS, false, soundResourceLength, Audio::kADPCMOki);
buffer.buffer = (byte *)malloc(buffer.size);
voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
@@ -309,68 +304,36 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
}
result = true;
break;
- case kSoundVOC:
- data = Audio::loadVOCFromStream(readS, size, rate);
- if (data) {
- buffer.frequency = rate;
- buffer.sampleBits = 8;
- buffer.isSigned = false;
- buffer.size = size;
- if (onlyHeader) {
- buffer.buffer = NULL;
- free(data);
- } else {
- buffer.buffer = data;
- }
- result = true;
- }
- break;
case kSoundWAV:
- if (Audio::loadWAVFromStream(readS, size, rate, flags)) {
- buffer.frequency = rate;
- buffer.sampleBits = (flags & Audio::Mixer::FLAG_16BITS) ? 16 : 8;
- buffer.stereo = flags & Audio::Mixer::FLAG_STEREO;
- buffer.isSigned = !(flags & Audio::Mixer::FLAG_UNSIGNED);
- buffer.size = size;
- if (onlyHeader) {
- buffer.buffer = NULL;
- } else {
- buffer.buffer = (byte *)malloc(size);
- readS.read(buffer.buffer, size);
- }
- result = true;
- }
- break;
case kSoundAIFF:
- if (Audio::loadAIFFFromStream(readS, size, rate, flags)) {
- buffer.frequency = rate;
- buffer.sampleBits = (flags & Audio::Mixer::FLAG_16BITS) ? 16 : 8;
- buffer.stereo = flags & Audio::Mixer::FLAG_STEREO;
- buffer.isSigned = true;
- buffer.size = size;
- if (onlyHeader) {
- buffer.buffer = NULL;
- } else {
- buffer.buffer = (byte *)malloc(size);
- readS.read(buffer.buffer, size);
- }
- result = true;
- }
- break;
case kSoundShorten:
- if (Audio::loadShortenFromStream(readS, size, rate, flags)) {
+ case kSoundVOC:
+ if (resourceType == kSoundWAV) {
+ result = Audio::loadWAVFromStream(readS, size, rate, flags);
+ } else if (resourceType == kSoundAIFF) {
+ result = Audio::loadAIFFFromStream(readS, size, rate, flags);
+ } else if (resourceType == kSoundShorten) {
+ result = Audio::loadShortenFromStream(readS, size, rate, flags);
+ } else if (resourceType == kSoundVOC) {
+ data = Audio::loadVOCFromStream(readS, size, rate);
+ result = (data != 0);
+ if (onlyHeader)
+ free(data);
+ }
+
+ if (result) {
buffer.frequency = rate;
buffer.sampleBits = (flags & Audio::Mixer::FLAG_16BITS) ? 16 : 8;
buffer.stereo = flags & Audio::Mixer::FLAG_STEREO;
- buffer.isSigned = !(flags & Audio::Mixer::FLAG_UNSIGNED);
+ buffer.isSigned = (resourceType == kSoundVOC) ? false : !(flags & Audio::Mixer::FLAG_UNSIGNED);
buffer.size = size;
- if (onlyHeader) {
- buffer.buffer = NULL;
- } else {
+
+ if (!onlyHeader && resourceType != kSoundVOC) {
buffer.buffer = (byte *)malloc(size);
readS.read(buffer.buffer, size);
+ } else if (!onlyHeader && resourceType == kSoundVOC) {
+ buffer.buffer = data;
}
- result = true;
}
break;
case kSoundMP3:
@@ -391,8 +354,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
buffer.soundFile = context->getFile(resourceData);
buffer.fileOffset = resourceData->offset + 9; // skip compressed sfx header: byte + uint16 + uint32 + byte + byte
- buffer.buffer = NULL;
-
result = true;
break;
default: