aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kurushin2005-07-26 19:40:58 +0000
committerAndrew Kurushin2005-07-26 19:40:58 +0000
commitc4f0d024ef22dc760c4ec29eee1f50de523414aa (patch)
tree59b60b883355ee89f1a6452cf186abbe5248c770
parente175e68b992ac355fe2bcaa1eededc1361f11ffc (diff)
downloadscummvm-rg350-c4f0d024ef22dc760c4ec29eee1f50de523414aa.tar.gz
scummvm-rg350-c4f0d024ef22dc760c4ec29eee1f50de523414aa.tar.bz2
scummvm-rg350-c4f0d024ef22dc760c4ec29eee1f50de523414aa.zip
fixed sound in many variation
some version should be tested svn-id: r18585
-rw-r--r--saga/game.cpp193
-rw-r--r--saga/music.cpp10
-rw-r--r--saga/rscfile.cpp18
-rw-r--r--saga/rscfile.h19
-rw-r--r--saga/saga.h31
-rw-r--r--saga/sndres.cpp106
-rw-r--r--saga/sndres.h6
-rw-r--r--saga/sound.cpp10
-rw-r--r--saga/sound.h6
9 files changed, 287 insertions, 112 deletions
diff --git a/saga/game.cpp b/saga/game.cpp
index f3281df625..52ceb17c25 100644
--- a/saga/game.cpp
+++ b/saga/game.cpp
@@ -200,7 +200,12 @@ static GameFontDescription ITEDEMO_GameFonts[] = {
};
static GameSoundInfo ITEDEMO_GameSound = {
- GAME_SOUND_VOC, 0, 0, 0
+ kSoundVOC,
+ -1,
+ -1,
+ false,
+ false,
+ true
};
// Inherit the Earth - Wyrmkeep Win32 Demo version
@@ -216,6 +221,33 @@ static GameFontDescription ITEWINDEMO_GameFonts[] = {
{0}
};
+static GameSoundInfo ITEWINDEMO1_GameSound = {
+ kSoundPCM,
+ 22050,
+ 8,
+ false,
+ false,
+ false
+};
+
+static GameSoundInfo ITEWINDEMO2_GameVoice = {
+ kSoundVOX,
+ 22050,
+ 16,
+ false,
+ false,
+ true
+};
+
+static GameSoundInfo ITEWINDEMO2_GameSound = {
+ kSoundPCM,
+ 22050,
+ 16,
+ false,
+ false,
+ true
+};
+
// Inherit the Earth - Wyrmkeep Mac Demo version
static GameFileDescription ITEMACDEMO_GameFiles[] = {
{"ited.rsc", GAME_RESOURCEFILE},
@@ -225,6 +257,33 @@ static GameFileDescription ITEMACDEMO_GameFiles[] = {
{"musicd.rsc", GAME_MUSICFILE}
};
+static GameSoundInfo ITEMACDEMO_GameVoice = {
+ kSoundVOX,
+ 22050,
+ 16,
+ false,
+ false,
+ true
+};
+
+static GameSoundInfo ITEMACDEMO_GameSound = {
+ kSoundPCM,
+ 22050,
+ 16,
+ false,
+ true,
+ true
+};
+
+static GameSoundInfo ITEMACDEMO_GameMusic = {
+ kSoundPCM,
+ 11025,
+ 16,
+ false,
+ false,
+ true
+};
+
// Inherit the Earth - Wyrmkeep Linux Demo version
static GameFileDescription ITELINDEMO_GameFiles[] = {
{"ited.rsc", GAME_RESOURCEFILE},
@@ -234,6 +293,15 @@ static GameFileDescription ITELINDEMO_GameFiles[] = {
{"musicd.rsc", GAME_MUSICFILE}
};
+static GameSoundInfo ITELINDEMO_GameMusic = {
+ kSoundPCM,
+ 11025,
+ 16,
+ true,
+ false,
+ true
+};
+
// Inherit the Earth - Wyrmkeep Linux version
static GameFileDescription ITELINCD_GameFiles[] = {
{"ite.rsc", GAME_RESOURCEFILE},
@@ -266,6 +334,24 @@ static GameFileDescription ITEMACCD_GameFiles[] = {
{"music.rsc", GAME_MUSICFILE}
};
+static GameSoundInfo ITEMACCD_GameSound = {
+ kSoundPCM,
+ 22050,
+ 16,
+ false,
+ true,
+ true
+};
+
+static GameSoundInfo ITEMACCD_GameMusic = {
+ kSoundPCM,
+ 11025,
+ 16,
+ true,
+ false,
+ true
+};
+
// Inherit the Earth - Diskette version
static GameFileDescription ITEDISK_GameFiles[] = {
{"ite.rsc", GAME_RESOURCEFILE},
@@ -280,7 +366,12 @@ static GameFontDescription ITEDISK_GameFonts[] = {
};
static GameSoundInfo ITEDISK_GameSound = {
- GAME_SOUND_VOC, 0, 0, 0
+ kSoundVOC,
+ -1,
+ -1,
+ false,
+ false,
+ true
};
// Inherit the Earth - CD Enhanced version
@@ -298,10 +389,12 @@ static GameFontDescription ITECD_GameFonts[] = {
};
static GameSoundInfo ITECD_GameSound = {
- GAME_SOUND_PCM,
+ kSoundPCM,
22050,
16,
- false
+ false,
+ false,
+ true
};
static GamePatchDescription ITEWinPatch1_Files[] = {
@@ -356,7 +449,7 @@ static GamePatchDescription ITEWinPatch2_Files[] = {
{ "wyrm1.dlt", GAME_RESOURCEFILE, 1530},
{ "wyrm2.dlt", GAME_RESOURCEFILE, 1531},
{ "wyrm3.dlt", GAME_RESOURCEFILE, 1532},
- { "p2_a.iaf", GAME_VOICEFILE, 4}
+ { "p2_a.iaf", GAME_VOICEFILE, 4, &ITECD_GameSound}
/* boarhall.bbm
elkenter.bbm
ferrets.bbm
@@ -373,7 +466,7 @@ static GamePatchDescription ITEMacPatch_Files[] = {
{ "wyrm4.dlt", GAME_RESOURCEFILE, 1533},
{ "credit3m.dlt", GAME_RESOURCEFILE, 1796},
{ "credit4m.dlt", GAME_RESOURCEFILE, 1797},
- { "p2_a.iaf", GAME_VOICEFILE, 4}
+ { "p2_a.iaf", GAME_VOICEFILE, 4, &ITEMACCD_GameSound}
};
static GamePatchDescription ITELinPatch_Files[] = {
@@ -383,7 +476,7 @@ static GamePatchDescription ITELinPatch_Files[] = {
{ "wyrm3.dlt", GAME_RESOURCEFILE, 1532},
{ "credit3n.dlt", GAME_RESOURCEFILE, 1796},
{ "credit4n.dlt", GAME_RESOURCEFILE, 1797},
- { "P2_A.iaf", GAME_VOICEFILE, 4}
+ { "P2_A.iaf", GAME_VOICEFILE, 4, &ITECD_GameSound}
};
// IHNM section
@@ -502,7 +595,7 @@ static GameFileDescription IHNMCD_GameFiles[] = {
{"patch.re_", GAME_PATCHFILE},
{"scripts.res", GAME_SCRIPTFILE},
{"sfx.res", GAME_SOUNDFILE},
- {"voicess.res", GAME_VOICEFILE},
+ {"voicess.res", GAME_VOICEFILE}, //order of voice bank file is important
{"voices1.res", GAME_VOICEFILE},
{"voices2.res", GAME_VOICEFILE},
{"voices3.res", GAME_VOICEFILE},
@@ -519,7 +612,7 @@ static GameFileDescription IHNMCDDE_GameFiles[] = {
{"scripts.res", GAME_SCRIPTFILE},
{"patch.re_", GAME_PATCHFILE},
{"sfx.res", GAME_SOUNDFILE},
- {"voicess.res", GAME_VOICEFILE},
+ {"voicess.res", GAME_VOICEFILE}, //order of voice bank file is important
{"voices1.res", GAME_VOICEFILE},
{"voices2.res", GAME_VOICEFILE},
{"voices3.res", GAME_VOICEFILE},
@@ -538,7 +631,12 @@ static GameFontDescription IHNMCD_GameFonts[] = {
};
static GameSoundInfo IHNM_GameSound = {
- GAME_SOUND_WAV, 0, 0, 0
+ kSoundWAV,
+ -1,
+ -1,
+ false,
+ false,
+ true
};
struct GameMD5 {
@@ -667,6 +765,7 @@ static GameMD5 gameMD5[] = {
static GameDescription gameDescriptions[] = {
// Inherit the earth - DOS Demo version
+ // sound unchecked
{
"ite-demo",
GType_ITE,
@@ -680,6 +779,8 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITEDEMO_GameFonts),
ITEDEMO_GameFonts,
&ITEDEMO_GameSound,
+ &ITEDEMO_GameSound,
+ NULL,
0,
NULL,
0, // features
@@ -698,10 +799,12 @@ static GameDescription gameDescriptions[] = {
ITEMACDEMO_GameFiles,
ARRAYSIZE(ITEWINDEMO_GameFonts),
ITEWINDEMO_GameFonts,
- &ITECD_GameSound,
+ &ITEMACDEMO_GameVoice,
+ &ITEMACDEMO_GameSound,
+ &ITEMACDEMO_GameMusic,
ARRAYSIZE(ITEMacPatch_Files),
ITEMacPatch_Files,
- GF_VOX_VOICES | GF_BIG_ENDIAN_DATA | GF_MAC_RESOURCES | GF_WYRMKEEP | GF_CD_FX
+ GF_BIG_ENDIAN_DATA | GF_MAC_RESOURCES | GF_WYRMKEEP | GF_CD_FX
},
// Inherit the earth - early MAC Demo version
@@ -717,10 +820,12 @@ static GameDescription gameDescriptions[] = {
ITEMACDEMO_GameFiles,
ARRAYSIZE(ITEWINDEMO_GameFonts),
ITEWINDEMO_GameFonts,
- &ITECD_GameSound,
+ &ITEMACDEMO_GameVoice,
+ &ITEMACDEMO_GameSound,
+ &ITEMACCD_GameMusic,
ARRAYSIZE(ITEMacPatch_Files),
ITEMacPatch_Files,
- GF_VOX_VOICES | GF_BIG_ENDIAN_DATA | GF_MAC_RESOURCES | GF_WYRMKEEP | GF_CD_FX
+ GF_BIG_ENDIAN_DATA | GF_MAC_RESOURCES | GF_WYRMKEEP | GF_CD_FX
},
// Inherit the earth - MAC CD Wyrmkeep version
@@ -736,7 +841,9 @@ static GameDescription gameDescriptions[] = {
ITEMACCD_GameFiles,
ARRAYSIZE(ITEWINDEMO_GameFonts),
ITEWINDEMO_GameFonts,
- &ITECD_GameSound,
+ &ITEMACCD_GameSound,
+ &ITEMACCD_GameSound,
+ &ITEMACCD_GameMusic,
ARRAYSIZE(ITEMacPatch_Files),
ITEMacPatch_Files,
GF_BIG_ENDIAN_DATA | GF_MAC_RESOURCES | GF_WYRMKEEP | GF_CD_FX
@@ -754,12 +861,14 @@ static GameDescription gameDescriptions[] = {
&ITE_Resources,
ARRAYSIZE(ITELINDEMO_GameFiles),
ITELINDEMO_GameFiles,
- ARRAYSIZE(ITECD_GameFonts),
- ITECD_GameFonts,
- &ITECD_GameSound,
- 0,
- NULL,
- GF_VOX_VOICES | GF_WYRMKEEP | GF_CD_FX
+ ARRAYSIZE(ITEWINDEMO_GameFonts),
+ ITEWINDEMO_GameFonts,
+ &ITEWINDEMO2_GameVoice,
+ &ITEWINDEMO2_GameSound,
+ &ITELINDEMO_GameMusic,
+ ARRAYSIZE(ITELinPatch_Files),
+ ITELinPatch_Files,
+ GF_WYRMKEEP | GF_CD_FX
},
// Inherit the earth - Win32 Demo version
@@ -775,10 +884,12 @@ static GameDescription gameDescriptions[] = {
ITEWINDEMO_GameFiles,
ARRAYSIZE(ITEWINDEMO_GameFonts),
ITEWINDEMO_GameFonts,
- &ITECD_GameSound,
+ &ITEWINDEMO2_GameVoice,
+ &ITEWINDEMO2_GameSound,
+ NULL,
ARRAYSIZE(ITEWinPatch2_Files),
ITEWinPatch2_Files,
- GF_VOX_VOICES | GF_WYRMKEEP | GF_CD_FX
+ GF_WYRMKEEP | GF_CD_FX
},
// Inherit the earth - early Win32 Demo version
@@ -794,13 +905,16 @@ static GameDescription gameDescriptions[] = {
ITEWINDEMO_GameFiles,
ARRAYSIZE(ITEWINDEMO_GameFonts),
ITEWINDEMO_GameFonts,
- &ITECD_GameSound,
+ &ITEWINDEMO1_GameSound,
+ &ITEWINDEMO1_GameSound,
+ NULL,
ARRAYSIZE(ITEWinPatch1_Files),
ITEWinPatch1_Files,
- GF_VOX_VOICES | GF_WYRMKEEP | GF_CD_FX
+ GF_WYRMKEEP | GF_CD_FX
},
// Inherit the earth - Wyrmkeep combined Windows/Mac/Linux CD
+ // sound unchecked
{
"ite",
GType_ITE,
@@ -814,13 +928,16 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITECD_GameFonts),
ITECD_GameFonts,
&ITECD_GameSound,
+ &ITECD_GameSound,
+ NULL,
0,
NULL,
- GF_WYRMKEEP | GF_BIG_ENDIAN_VOICES | GF_CD_FX
+ GF_WYRMKEEP | GF_CD_FX
},
// Inherit the earth - Wyrmkeep Linux CD version
// should be before GID_ITE_CD_G
+ // sound unchecked
{
"ite",
GType_ITE,
@@ -834,12 +951,15 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITECD_GameFonts),
ITECD_GameFonts,
&ITECD_GameSound,
+ &ITECD_GameSound,
+ NULL,
ARRAYSIZE(ITELinPatch_Files),
ITELinPatch_Files,
GF_WYRMKEEP | GF_CD_FX
},
// Inherit the earth - Wyrmkeep Windows CD version
+ // sound unchecked
{
"ite",
GType_ITE,
@@ -853,12 +973,15 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITECD_GameFonts),
ITECD_GameFonts,
&ITECD_GameSound,
+ &ITECD_GameSound,
+ NULL,
ARRAYSIZE(ITEWinPatch1_Files),
ITEWinPatch1_Files,
GF_WYRMKEEP | GF_CD_FX
},
// Inherit the earth - DOS CD version
+ // sound unchecked
{
"ite",
GType_ITE,
@@ -872,12 +995,15 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITECD_GameFonts),
ITECD_GameFonts,
&ITECD_GameSound,
+ &ITECD_GameSound,
+ NULL,
0,
NULL,
GF_CD_FX
},
// Inherit the earth - DOS CD German version
+ // sound unchecked
{
"ite",
GType_ITE,
@@ -891,6 +1017,8 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITECD_GameFonts),
ITECD_GameFonts,
&ITECD_GameSound,
+ &ITECD_GameSound,
+ NULL,
0,
NULL,
GF_LANG_DE | GF_CD_FX
@@ -910,12 +1038,15 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITECD_GameFonts),
ITECD_GameFonts,
&ITECD_GameSound,
+ &ITECD_GameSound,
+ NULL,
0,
NULL,
GF_CD_FX
},
// Inherit the earth - German Floppy version
+ // sound unchecked
{
"ite",
GType_ITE,
@@ -929,6 +1060,8 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITEDISK_GameFonts),
ITEDISK_GameFonts,
&ITEDISK_GameSound,
+ &ITEDISK_GameSound,
+ NULL,
0,
NULL,
GF_LANG_DE
@@ -948,6 +1081,8 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(ITEDISK_GameFonts),
ITEDISK_GameFonts,
&ITEDISK_GameSound,
+ &ITEDISK_GameSound,
+ NULL,
0,
NULL,
0
@@ -967,6 +1102,8 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(IHNMCD_GameFonts),
IHNMCD_GameFonts,
&IHNM_GameSound,
+ &IHNM_GameSound,
+ NULL,
0,
NULL,
GF_DEFAULT_TO_1X_SCALER
@@ -986,6 +1123,8 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(IHNMCD_GameFonts),
IHNMCD_GameFonts,
&IHNM_GameSound,
+ &IHNM_GameSound,
+ NULL,
0,
NULL,
GF_DEFAULT_TO_1X_SCALER
@@ -1005,6 +1144,8 @@ static GameDescription gameDescriptions[] = {
ARRAYSIZE(IHNMCD_GameFonts),
IHNMCD_GameFonts,
&IHNM_GameSound,
+ &IHNM_GameSound,
+ NULL,
0,
NULL,
GF_DEFAULT_TO_1X_SCALER
diff --git a/saga/music.cpp b/saga/music.cpp
index f536663e4d..7f58027592 100644
--- a/saga/music.cpp
+++ b/saga/music.cpp
@@ -52,6 +52,7 @@ private:
int16 _buf[BUFFER_SIZE];
const int16 *_bufferEnd;
const int16 *_pos;
+ const GameSoundInfo *_musicInfo;
void refill();
bool eosIntern() const {
@@ -64,8 +65,8 @@ public:
int readBuffer(int16 *buffer, const int numSamples);
bool endOfData() const { return eosIntern(); }
- bool isStereo() const { return true; }
- int getRate() const { return 11025; }
+ bool isStereo() const { return _musicInfo->stereo; }
+ int getRate() const { return _musicInfo->frequency; }
};
RAWInputStream::RAWInputStream(SagaEngine *vm, ResourceContext *context, uint32 resourceId, bool looping)
@@ -75,6 +76,11 @@ RAWInputStream::RAWInputStream(SagaEngine *vm, ResourceContext *context, uint32
resourceData = vm->_resource->getResourceData(context, resourceId);
_file = context->getFile(resourceData);
+ _musicInfo = vm->getMusicInfo();
+
+ if (_musicInfo == NULL) {
+ error("RAWInputStream() wrong musicInfo");
+ }
// Determine the end position
_startPos = resourceData->offset;
diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp
index f9d2afb4aa..12fce1fb64 100644
--- a/saga/rscfile.cpp
+++ b/saga/rscfile.cpp
@@ -55,10 +55,6 @@ bool Resource::loadContext(ResourceContext *context) {
context->isBigEndian = _vm->isBigEndian();
- if (!context->isBigEndian) {
- context->isBigEndian = ((_vm->getFeatures() & GF_BIG_ENDIAN_VOICES) != 0) && ((context->fileType & GAME_VOICEFILE) != 0);
- }
-
if (context->file->size() < RSC_MIN_FILESIZE) {
return false;
}
@@ -113,16 +109,14 @@ bool Resource::loadContext(ResourceContext *context) {
patchDescription = &_vm->getGameDescription()->patchDescriptions[j];
if ((patchDescription->fileType & context->fileType) != 0) {
if (patchDescription->resourceId < context->count) {
- //TODO|fix: should we convert this ID? or make separate patch list for MAC version?
resourceData = &context->table[patchDescription->resourceId];
- resourceData->patchFile = new Common::File();
- if (resourceData->patchFile->open(patchDescription->fileName)) {
+ resourceData->patchData = new PatchData(patchDescription);
+ if (resourceData->patchData->_patchFile->open(patchDescription->fileName)) {
resourceData->offset = 0;
- resourceData->size = resourceData->patchFile->size();
+ resourceData->size = resourceData->patchData->_patchFile->size();
} else {
- warning("loadContext: patch file not found %s", patchDescription->fileName);
- delete resourceData->patchFile;
- resourceData->patchFile = NULL;
+ delete resourceData->patchData;
+ resourceData->patchData = NULL;
}
}
}
@@ -177,7 +171,7 @@ void Resource::clearContexts() {
delete context->file;
if (context->table != NULL) {
for(j = 0; j < context->count; j++) {
- delete context->table[j].patchFile;
+ delete context->table[j].patchData;
}
}
free(context->table);
diff --git a/saga/rscfile.h b/saga/rscfile.h
index 343e25b0c7..63d8ef79f9 100644
--- a/saga/rscfile.h
+++ b/saga/rscfile.h
@@ -38,10 +38,23 @@ namespace Saga {
//TODO: good PATCH.RE_ support
+struct PatchData {
+ Common::File *_patchFile;
+ GamePatchDescription *_patchDescription;
+
+ PatchData(GamePatchDescription *patchDescription): _patchDescription(patchDescription) {
+ _patchFile = new Common::File();
+ }
+
+ ~PatchData() {
+ delete _patchFile;
+ }
+};
+
struct ResourceData {
size_t offset;
size_t size;
- Common::File *patchFile;
+ PatchData *patchData;
};
struct ResourceContext {
@@ -55,8 +68,8 @@ struct ResourceContext {
size_t count;
Common::File *getFile(ResourceData *resourceData) const {
- if (resourceData->patchFile != NULL) {
- return resourceData->patchFile;
+ if (resourceData->patchData != NULL) {
+ return resourceData->patchData->_patchFile;
} else {
return file;
}
diff --git a/saga/saga.h b/saga/saga.h
index 9a586ebf77..82ffda3eaa 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -293,20 +293,18 @@ enum GameFileTypes {
};
enum GameSoundTypes {
- GAME_SOUND_PCM = 0,
- GAME_SOUND_VOC,
- GAME_SOUND_WAV,
- GAME_SOUND_VOX
+ kSoundPCM = 0,
+ kSoundVOX = 1,
+ kSoundVOC = 2,
+ kSoundWAV = 3
};
enum GameFeatures {
- GF_VOX_VOICES = 1 << 0,
- GF_BIG_ENDIAN_VOICES = 1 << 1,
- GF_BIG_ENDIAN_DATA = 1 << 2,
- GF_MAC_RESOURCES = 1 << 3,
- GF_LANG_DE = 1 << 4,
- GF_WYRMKEEP = 1 << 5,
- GF_CD_FX = 1 << 6
+ GF_BIG_ENDIAN_DATA = 1 << 0,
+ GF_MAC_RESOURCES = 1 << 1,
+ GF_LANG_DE = 1 << 2,
+ GF_WYRMKEEP = 1 << 3,
+ GF_CD_FX = 1 << 4
};
enum FontId {
@@ -329,6 +327,8 @@ struct GameSoundInfo {
long frequency;
int sampleBits;
bool stereo;
+ bool isBigEndian;
+ bool isSigned;
};
struct GameFontDescription {
@@ -357,6 +357,7 @@ struct GamePatchDescription {
const char *fileName;
uint16 fileType;
uint32 resourceId;
+ GameSoundInfo * soundInfo;
};
struct PanelButton {
@@ -467,7 +468,9 @@ struct GameDescription {
GameFileDescription *filesDescriptions;
int fontsCount;
GameFontDescription *fontDescriptions;
- GameSoundInfo *soundInfo;
+ GameSoundInfo *voiceInfo;
+ GameSoundInfo *sfxInfo;
+ GameSoundInfo *musicInfo;
int patchsCount;
GamePatchDescription *patchDescriptions;
uint32 features;
@@ -643,7 +646,9 @@ public:
const bool isBigEndian() const { return (_gameDescription->features & GF_BIG_ENDIAN_DATA) != 0; }
const bool isMacResources() const { return (_gameDescription->features & GF_MAC_RESOURCES) != 0; }
const GameResourceDescription *getResourceDescription() { return _gameDescription->resourceDescription; }
- const GameSoundInfo *getSoundInfo() { return _gameDescription->soundInfo; }
+ const GameSoundInfo *getVoiceInfo() const { return _gameDescription->voiceInfo; }
+ const GameSoundInfo *getSfxInfo() const { return _gameDescription->sfxInfo; }
+ const GameSoundInfo *getMusicInfo() const { return _gameDescription->musicInfo; }
const GameFontDescription *getFontDescription(int index) {
assert(index < _gameDescription->fontsCount);
diff --git a/saga/sndres.cpp b/saga/sndres.cpp
index 46ca5aa1d1..cb10f57627 100644
--- a/saga/sndres.cpp
+++ b/saga/sndres.cpp
@@ -46,13 +46,23 @@ SndRes::SndRes(SagaEngine *vm) : _vm(vm) {
error("SndRes::SndRes resource context not found");
}
- _voiceContext = _vm->_resource->getContext(GAME_VOICEFILE);
+ _voiceSerial = -1;
+
+ setVoiceBank(0);
+}
+
+void SndRes::setVoiceBank(int serial)
+{
+ if (_voiceSerial == serial) return;
+
+ _voiceSerial = serial;
+
+ _voiceContext = _vm->_resource->getContext(GAME_VOICEFILE, _voiceSerial);
if (_voiceContext == NULL) {
error("SndRes::SndRes resource context not found");
}
- // Grab sound resource information for the current game
- _soundInfo = *_vm->getSoundInfo();
+
}
void SndRes::playSound(uint32 resourceId, int volume, bool loop) {
@@ -91,71 +101,77 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
int rate;
int size;
byte flags;
- bool voxPcm;
size_t voxSize;
+ const GameSoundInfo *soundInfo;
if (resourceId == (int32)-1) {
return false;
}
+
_vm->_resource->loadResource(context, resourceId, soundResource, soundResourceLength);
+ if ((context->fileType & GAME_VOICEFILE) != 0) {
+ soundInfo = _vm->getVoiceInfo();
+ } else {
+ soundInfo = _vm->getSfxInfo();
+ }
+ if (context->table[resourceId].patchData != NULL) {
+ if (context->table[resourceId].patchData->_patchDescription->soundInfo != NULL) {
+ soundInfo = context->table[resourceId].patchData->_patchDescription->soundInfo;
+ }
+ }
+
MemoryReadStream readS(soundResource, soundResourceLength);
- //TODO: check soundResource header - game may have GAME_SOUND_PCM, but patch file can be GAME_SOUND_VOC
- resourceType = _soundInfo.resourceType;
+ resourceType = soundInfo->resourceType;
+ buffer.isBigEndian = soundInfo->isBigEndian;
if (soundResourceLength >= 8) {
if (!memcmp(&soundResource, "Creative", 8)) {
- resourceType = GAME_SOUND_VOC;
+ resourceType = kSoundVOC;
} else if (!memcmp(soundResource, "RIFF", 4) != 0) {
- resourceType = GAME_SOUND_WAV;
+ resourceType = kSoundWAV;
}
}
+
switch (resourceType) {
- case GAME_SOUND_PCM:
- buffer.frequency = _soundInfo.frequency;
- buffer.isSigned = true;
- voxPcm = (_vm->getFeatures() & GF_VOX_VOICES);
- if (voxPcm) {
- if (_vm->getGameType() == GType_ITE) {
- //.iaf is not vox
- if (_vm->_resource->getResourceData(context, resourceId)->patchFile != NULL) {
- voxPcm = false;
- }
- }
+ case kSoundPCM:
+ buffer.frequency = soundInfo->frequency;
+ buffer.isSigned = soundInfo->isSigned;
+ buffer.sampleBits = soundInfo->sampleBits;
+ buffer.size = soundResourceLength;
+ buffer.stereo = soundInfo->stereo;
+ if (onlyHeader) {
+ buffer.buffer = NULL;
+ free(soundResource);
+ } else {
+ buffer.buffer = soundResource;
}
- if (voxPcm) {
- buffer.sampleBits = 16;
- buffer.stereo = false;
- buffer.size = soundResourceLength * 4;
- if (onlyHeader) {
- buffer.buffer = NULL;
- free(soundResource);
- } else {
- voxStream = makeADPCMStream(readS, soundResourceLength, kADPCMOki);
- buffer.buffer = (byte *)malloc(buffer.size);
- voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
- if (voxSize != soundResourceLength * 2) {
- error("SndRes::load() wrong VOX output size");
- }
- delete voxStream;
- }
+ result = true;
+ break;
+ case kSoundVOX:
+ buffer.frequency = soundInfo->frequency;
+ buffer.isSigned = soundInfo->isSigned;
+ buffer.sampleBits = soundInfo->sampleBits;
+ buffer.stereo = soundInfo->stereo;
+ buffer.size = soundResourceLength * 4;
+ if (onlyHeader) {
+ buffer.buffer = NULL;
+ free(soundResource);
} else {
- buffer.sampleBits = _soundInfo.sampleBits;
- buffer.size = soundResourceLength;
- buffer.stereo = _soundInfo.stereo;
- if (onlyHeader) {
- buffer.buffer = NULL;
- free(soundResource);
- } else {
- buffer.buffer = soundResource;
+ voxStream = makeADPCMStream(readS, soundResourceLength, kADPCMOki);
+ buffer.buffer = (byte *)malloc(buffer.size);
+ voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
+ if (voxSize != soundResourceLength * 2) {
+ error("SndRes::load() wrong VOX output size");
}
+ delete voxStream;
}
result = true;
break;
- case GAME_SOUND_VOC:
+ case kSoundVOC:
data = loadVOCFromStream(readS, size, rate);
if (data) {
buffer.frequency = rate;
@@ -173,7 +189,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
}
free(soundResource);
break;
- case GAME_SOUND_WAV:
+ case kSoundWAV:
if (loadWAVFromStream(readS, size, rate, flags)) {
buffer.frequency = rate;
buffer.sampleBits = 16;
diff --git a/saga/sndres.h b/saga/sndres.h
index 083b5377e4..feb822ddd6 100644
--- a/saga/sndres.h
+++ b/saga/sndres.h
@@ -39,16 +39,16 @@ public:
void playSound(uint32 resourceId, int volume, bool loop);
void playVoice(uint32 resourceId);
int getVoiceLength(uint32 resourceId);
-
+ void setVoiceBank(int serial);
private:
bool load(ResourceContext *context, uint32 resourceId, SoundBuffer &buffer, bool onlyHeader);
bool loadVocSound(byte *soundResource, size_t soundResourceLength, SoundBuffer &buffer);
bool loadWavSound(byte *soundResource, size_t soundResourceLength, SoundBuffer &buffer);
-
+
ResourceContext *_sfxContext;
ResourceContext *_voiceContext;
- GameSoundInfo _soundInfo;
+ int _voiceSerial; // voice bank number
SagaEngine *_vm;
};
diff --git a/saga/sound.cpp b/saga/sound.cpp
index 2303548182..963305feed 100644
--- a/saga/sound.cpp
+++ b/saga/sound.cpp
@@ -38,7 +38,7 @@ Sound::~Sound() {
delete _voxStream;
}
-void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop, bool forceBigEndian) {
+void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop) {
byte flags;
flags = Audio::Mixer::FLAG_AUTOFREE;
@@ -48,7 +48,8 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int
if (buffer.sampleBits == 16) {
flags |= Audio::Mixer::FLAG_16BITS;
- if (!(_vm->isBigEndian()) && !forceBigEndian)
+
+ if (!buffer.isBigEndian)
flags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
}
if (buffer.stereo)
@@ -60,7 +61,7 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int
}
void Sound::playSound(SoundBuffer &buffer, int volume, bool loop) {
- playSoundBuffer(&_effectHandle, buffer, 2 * volume, loop, false);
+ playSoundBuffer(&_effectHandle, buffer, 2 * volume, loop);
}
void Sound::pauseSound() {
@@ -76,10 +77,9 @@ void Sound::stopSound() {
}
void Sound::playVoice(SoundBuffer &buffer) {
- playSoundBuffer(&_voiceHandle, buffer, 255, false, (_vm->getFeatures() & GF_BIG_ENDIAN_VOICES) != 0);
+ playSoundBuffer(&_voiceHandle, buffer, 255, false);
}
-
void Sound::pauseVoice() {
_mixer->pauseHandle(_voiceHandle, true);
}
diff --git a/saga/sound.h b/saga/sound.h
index 6a95e0535a..33c22dace3 100644
--- a/saga/sound.h
+++ b/saga/sound.h
@@ -39,10 +39,10 @@ struct SoundBuffer {
int sampleBits;
bool stereo;
bool isSigned;
-
+
byte *buffer;
size_t size;
- //big endianess flag!!!
+ bool isBigEndian;
};
class Sound {
@@ -63,7 +63,7 @@ public:
private:
- void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop, bool forceBigEndian);
+ void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop);
int _enabled;
SagaEngine *_vm;