[Scummvm-cvs-logs] CVS: scummvm/saga game.cpp,1.82,1.83 music.cpp,1.60,1.61 rscfile.cpp,1.26,1.27 rscfile.h,1.12,1.13 saga.h,1.108,1.109 sndres.cpp,1.46,1.47 sndres.h,1.21,1.22 sound.cpp,1.30,1.31 sound.h,1.22,1.23

Andrew Kurushin h00ligan at users.sourceforge.net
Tue Jul 26 12:42:04 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19806

Modified Files:
	game.cpp music.cpp rscfile.cpp rscfile.h saga.h sndres.cpp 
	sndres.h sound.cpp sound.h 
Log Message:
fixed sound in many variation
some version should be tested

Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/game.cpp,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- game.cpp	21 Jul 2005 01:33:28 -0000	1.82
+++ game.cpp	26 Jul 2005 19:40:57 -0000	1.83
@@ -200,7 +200,12 @@
 }; 
 
 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 @@
 	{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 @@
 	{"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 @@
 	{"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 @@
 	{"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 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 GameSoundInfo ITECD_GameSound = {
-	GAME_SOUND_PCM,
+	kSoundPCM,
 	22050,
 	16,
-	false
+	false,
+	false,
+	true
 };
 
 static GamePatchDescription ITEWinPatch1_Files[] = {
@@ -356,7 +449,7 @@
 	{ "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 @@
 	{ "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 @@
 	{ "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 @@
 	{"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 @@
 	{"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 GameSoundInfo IHNM_GameSound = {
-	GAME_SOUND_WAV, 0, 0, 0
+	kSoundWAV,
+	-1,
+	-1,
+	false,
+	false,
+	true
 };
 
 struct GameMD5 {
@@ -667,6 +765,7 @@
 
 static GameDescription gameDescriptions[] = {
 	// Inherit the earth - DOS Demo version
+	// sound unchecked
 	{
 		"ite-demo",
 		GType_ITE,
@@ -680,6 +779,8 @@
 		ARRAYSIZE(ITEDEMO_GameFonts),
 		ITEDEMO_GameFonts,
 		&ITEDEMO_GameSound,
+		&ITEDEMO_GameSound,
+		NULL,
 		0,
 		NULL,
 		0, // features
@@ -698,10 +799,12 @@
 		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 @@
 		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 @@
 		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 @@
 		&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 @@
 		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 @@
 		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 @@
 		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 @@
 		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 @@
 		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 @@
 		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 @@
 		ARRAYSIZE(ITECD_GameFonts),
 		ITECD_GameFonts,
 		&ITECD_GameSound,
+		&ITECD_GameSound,
+		NULL,
 		0,
 		NULL,
 		GF_LANG_DE | GF_CD_FX
@@ -910,12 +1038,15 @@
 		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 @@
 		ARRAYSIZE(ITEDISK_GameFonts),
 		ITEDISK_GameFonts,
 		&ITEDISK_GameSound,
+		&ITEDISK_GameSound,
+		NULL,
 		0,
 		NULL,
 		GF_LANG_DE
@@ -948,6 +1081,8 @@
 		ARRAYSIZE(ITEDISK_GameFonts),
 		ITEDISK_GameFonts,
 		&ITEDISK_GameSound,
+		&ITEDISK_GameSound,
+		NULL,
 		0,
 		NULL,
 		0
@@ -967,6 +1102,8 @@
 		ARRAYSIZE(IHNMCD_GameFonts),
 		IHNMCD_GameFonts,
 		&IHNM_GameSound,
+		&IHNM_GameSound,
+		NULL,
 		0,
 		NULL,
 		GF_DEFAULT_TO_1X_SCALER
@@ -986,6 +1123,8 @@
 		ARRAYSIZE(IHNMCD_GameFonts),
 		IHNMCD_GameFonts,
 		&IHNM_GameSound,
+		&IHNM_GameSound,
+		NULL,
 		0,
 		NULL,
 		GF_DEFAULT_TO_1X_SCALER
@@ -1005,6 +1144,8 @@
 		ARRAYSIZE(IHNMCD_GameFonts),
 		IHNMCD_GameFonts,
 		&IHNM_GameSound,
+		&IHNM_GameSound,
+		NULL,
 		0,
 		NULL,
 		GF_DEFAULT_TO_1X_SCALER

Index: music.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/music.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- music.cpp	19 Jul 2005 21:48:59 -0000	1.60
+++ music.cpp	26 Jul 2005 19:40:57 -0000	1.61
@@ -52,6 +52,7 @@
 	int16 _buf[BUFFER_SIZE];
 	const int16 *_bufferEnd;
 	const int16 *_pos;
+	const GameSoundInfo *_musicInfo;
 
 	void refill();
 	bool eosIntern() const {
@@ -64,8 +65,8 @@
 	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 @@
 
 	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;

Index: rscfile.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/rscfile.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- rscfile.cpp	23 Jul 2005 15:23:01 -0000	1.26
+++ rscfile.cpp	26 Jul 2005 19:40:58 -0000	1.27
@@ -55,10 +55,6 @@
 	
 	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 @@
 			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 @@
 		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);

Index: rscfile.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/rscfile.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- rscfile.h	23 Jul 2005 15:23:01 -0000	1.12
+++ rscfile.h	26 Jul 2005 19:40:58 -0000	1.13
@@ -38,10 +38,23 @@
 
 //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 @@
 	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;
 		}

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- saga.h	19 Jul 2005 21:15:56 -0000	1.108
+++ saga.h	26 Jul 2005 19:40:58 -0000	1.109
@@ -293,20 +293,18 @@
 };
 
 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 @@
 	long frequency;
 	int sampleBits;
 	bool stereo;
+	bool isBigEndian;
+	bool isSigned;
 };
 
 struct GameFontDescription {
@@ -357,6 +357,7 @@
 	const char *fileName;
 	uint16 fileType;
 	uint32 resourceId;
+	GameSoundInfo * soundInfo;
 };
 
 struct PanelButton {
@@ -467,7 +468,9 @@
 	GameFileDescription *filesDescriptions;
 	int fontsCount;
 	GameFontDescription *fontDescriptions;
-	GameSoundInfo *soundInfo;
+	GameSoundInfo *voiceInfo;
+	GameSoundInfo *sfxInfo;
+	GameSoundInfo *musicInfo;
 	int patchsCount;
 	GamePatchDescription *patchDescriptions;
 	uint32 features;
@@ -643,7 +646,9 @@
 	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);

Index: sndres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- sndres.cpp	19 Jul 2005 21:34:46 -0000	1.46
+++ sndres.cpp	26 Jul 2005 19:40:58 -0000	1.47
@@ -46,13 +46,23 @@
 		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 @@
 	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 @@
 		}
 		free(soundResource);
 		break;
-	case GAME_SOUND_WAV:
+	case kSoundWAV:
 		if (loadWAVFromStream(readS, size, rate, flags)) {
 			buffer.frequency = rate;
 			buffer.sampleBits = 16;

Index: sndres.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- sndres.h	19 Jul 2005 19:05:51 -0000	1.21
+++ sndres.h	26 Jul 2005 19:40:58 -0000	1.22
@@ -39,16 +39,16 @@
 	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;
 };

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sound.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- sound.cpp	19 Jul 2005 19:05:51 -0000	1.30
+++ sound.cpp	26 Jul 2005 19:40:58 -0000	1.31
@@ -38,7 +38,7 @@
 	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 @@
 
 	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::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::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);
 }

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sound.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- sound.h	19 Jul 2005 19:05:51 -0000	1.22
+++ sound.h	26 Jul 2005 19:40:58 -0000	1.23
@@ -39,10 +39,10 @@
 	int sampleBits;
 	bool stereo;
 	bool isSigned;
-
+	
 	byte *buffer;
 	size_t size;
-	//big endianess flag!!!
+	bool isBigEndian;
 };
 
 class Sound {
@@ -63,7 +63,7 @@
 
  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;





More information about the Scummvm-git-logs mailing list