[Scummvm-cvs-logs] CVS: scummvm/saga game.cpp,1.21,1.22 game.h,1.8,1.9 game_mod.h,1.7,1.8 music.cpp,1.23,1.24 saga.cpp,1.49,1.50 sndres.cpp,1.20,1.21 sound.cpp,1.10,1.11 sound.h,1.7,1.8

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Thu Sep 30 23:46:04 CEST 2004


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

Modified Files:
	game.cpp game.h game_mod.h music.cpp saga.cpp sndres.cpp 
	sound.cpp sound.h 
Log Message:
Set up file paths to handle the differences between the file layout of the
Windows and Linux versions. (TODO: Handle game detection.)

Added preliminary support for the P2_A.aif file that the Linux version
uses, where the Windows version uses p2_a.voc. Someone will have to verify
the actual format of it, and we have a silly bug in playVoice() which will
have to be fixed before things work properly.


Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/game.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- game.cpp	27 Aug 2004 01:32:10 -0000	1.21
+++ game.cpp	1 Oct 2004 06:45:13 -0000	1.22
@@ -268,27 +268,11 @@
 
 static R_GAMEMODULE GameModule;
 
-void GAME_setGameDirectory(const char *gamedir) {
-	assert(gamedir != NULL);
-
-	debug(0, "Using game data path: %s", gamedir);
-
-	strcpy(GameModule.game_dir, gamedir);
-}
-
 int GAME_Register() {
 	return R_SUCCESS;
 
-	// Register "gamedir" cfg cvar
-	strncpy(GameModule.game_dir, "./", R_MAXPATH);
-
-	if (CVAR_Register_S(GameModule.game_dir,
-		"gamedir", NULL, R_CVAR_CFG, R_MAXPATH) != R_SUCCESS) {
-		return R_FAILURE;
-	}
-
 	// Register "g_language" cfg cvar
-	strncpy(GameModule.game_dir, "us", R_MAXPATH);
+	strncpy(GameModule.game_language, "us", R_MAXPATH);
 
 	if (CVAR_Register_S(GameModule.game_language, "g_language",
 						NULL, R_CVAR_CFG, R_GAME_LANGSTR_LIMIT) != R_SUCCESS) {
@@ -305,16 +289,13 @@
 
 int GAME_Init() {
 	uint16 game_n;
-	char *game_dir;
 
-	game_dir = GameModule.game_dir;
-
-	if (DetectGame(game_dir, &game_n) != R_SUCCESS) {
+	if (DetectGame(&game_n) != R_SUCCESS) {
 		warning("No valid games were found in the specified directory.");
 		return R_FAILURE;
 	}
 
-	if (LoadGame(game_dir, game_n) != R_SUCCESS) {
+	if (LoadGame(game_n) != R_SUCCESS) {
 		warning("Error loading game resource files.");
 		return R_FAILURE;
 	}
@@ -432,7 +413,7 @@
 	return detectedGames;
 }
 
-int DetectGame(const char *game_dir, uint16 *game_n_p) {
+int DetectGame(uint16 *game_n_p) {
 	uint16 game_count = ARRAYSIZE(GameDescs);
 	uint16 game_n;
 
@@ -442,7 +423,7 @@
 
 	int file_missing = 0;
 
-	if ((game_dir == NULL) || (game_n_p == NULL)) {
+	if (game_n_p == NULL) {
 		return R_FAILURE;
 	}
 
@@ -473,14 +454,14 @@
 	return R_FAILURE;
 }
 
-int LoadGame(const char *game_dir, uint16 game_n) {
+int LoadGame(uint16 game_n) {
 	R_RSCFILE_CONTEXT *load_ctxt;
 	uint16 game_count = ARRAYSIZE(GameDescs);
 	const char *game_fname;
 	uint16 game_filect;
 	uint16 i;
 
-	if ((game_dir == NULL) || (game_n >= game_count)) {
+	if (game_n >= game_count) {
 		return R_FAILURE;
 	}
 
@@ -491,7 +472,6 @@
 		return R_MEM;
 	}
 
-	File::addDefaultDirectory(game_dir);
 	GameModule.gfile_n = game_filect;
 
 	// Load game resource files

Index: game.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/game.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- game.h	27 Aug 2004 01:32:10 -0000	1.8
+++ game.h	1 Oct 2004 06:45:13 -0000	1.9
@@ -79,7 +79,6 @@
 	int game_number;
 	R_GAMEDESC *gamedesc;
 	int g_skipintro;
-	char game_dir[R_MAXPATH];
 	char game_language[R_GAME_LANGSTR_LIMIT];
 	uint16 gfile_n;
 	R_GAME_FILEDATA *gfile_data;
@@ -90,8 +89,8 @@
 };
 
 int LoadLanguage();
-int LoadGame(const char *game_dir, uint16 game_n_p);
-int DetectGame(const char *game_dir, uint16 *game_n_p);
+int LoadGame(uint16 game_n_p);
+int DetectGame(uint16 *game_n_p);
 
 } // End of namespace Saga
 

Index: game_mod.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/game_mod.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- game_mod.h	27 Aug 2004 01:32:10 -0000	1.7
+++ game_mod.h	1 Oct 2004 06:45:13 -0000	1.8
@@ -104,7 +104,6 @@
 int GAME_GetSceneInfo(R_GAME_SCENEDESC *);
 int GAME_GetGame();
 int GAME_GetGameType();
-void GAME_setGameDirectory(const char *gamedir);
 GameList GAME_GameList();
 DetectedGameList GAME_ProbeGame(const FSList &fslist);
 

Index: music.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/music.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- music.cpp	27 Aug 2004 01:32:10 -0000	1.23
+++ music.cpp	1 Oct 2004 06:45:13 -0000	1.24
@@ -165,32 +165,32 @@
 // reset.mid seems to be unused.
 
 const MUSIC_MIDITABLE Music::_midiTableITECD[26] = {
-	{"cave", R_MUSIC_LOOP},		// 9
-	{"intro", R_MUSIC_LOOP},	// 10
-	{"fvillage", R_MUSIC_LOOP},	// 11
-	{"elkhall", R_MUSIC_LOOP},	// 12
-	{"mouse", 0},				// 13
-	{"darkclaw", R_MUSIC_LOOP},	// 14
-	{"birdchrp", R_MUSIC_LOOP},	// 15
-	{"orbtempl", R_MUSIC_LOOP},	// 16
-	{"spooky", R_MUSIC_LOOP},	// 17
-	{"catfest", R_MUSIC_LOOP},	// 18
-	{"elkfanfare", 0},			// 19
-	{"bcexpl", R_MUSIC_LOOP},	// 20
-	{"boargtnt", R_MUSIC_LOOP},	// 21
-	{"boarking", R_MUSIC_LOOP},	// 22
-	{"explorea", R_MUSIC_LOOP},	// 23
-	{"exploreb", R_MUSIC_LOOP},	// 24
-	{"explorec", R_MUSIC_LOOP},	// 25
-	{"sunstatm", R_MUSIC_LOOP},	// 26
-	{"nitstrlm", R_MUSIC_LOOP},	// 27
-	{"humruinm", R_MUSIC_LOOP},	// 28
-	{"damexplm", R_MUSIC_LOOP},	// 29
-	{"tychom", R_MUSIC_LOOP},	// 30
-	{"kitten", R_MUSIC_LOOP},	// 31
-	{"sweet", R_MUSIC_LOOP},	// 32
-	{"brutalmt", R_MUSIC_LOOP},	// 33
-	{"shiala", R_MUSIC_LOOP}	// 34
+	{"cave.mid", R_MUSIC_LOOP},		// 9
+	{"intro.mid", R_MUSIC_LOOP},	// 10
+	{"fvillage.mid", R_MUSIC_LOOP},	// 11
+	{"elkhall.mid", R_MUSIC_LOOP},	// 12
+	{"mouse.mid", 0},				// 13
+	{"darkclaw.mid", R_MUSIC_LOOP},	// 14
+	{"birdchrp.mid", R_MUSIC_LOOP},	// 15
+	{"orbtempl.mid", R_MUSIC_LOOP},	// 16
+	{"spooky.mid", R_MUSIC_LOOP},	// 17
+	{"catfest.mid", R_MUSIC_LOOP},	// 18
+	{"elkfanfare.mid", 0},			// 19
+	{"bcexpl.mid", R_MUSIC_LOOP},	// 20
+	{"boargtnt.mid", R_MUSIC_LOOP},	// 21
+	{"boarking.mid", R_MUSIC_LOOP},	// 22
+	{"explorea.mid", R_MUSIC_LOOP},	// 23
+	{"exploreb.mid", R_MUSIC_LOOP},	// 24
+	{"explorec.mid", R_MUSIC_LOOP},	// 25
+	{"sunstatm.mid", R_MUSIC_LOOP},	// 26
+	{"nitstrlm.mid", R_MUSIC_LOOP},	// 27
+	{"humruinm.mid", R_MUSIC_LOOP},	// 28
+	{"damexplm.mid", R_MUSIC_LOOP},	// 29
+	{"tychom.mid", R_MUSIC_LOOP},	// 30
+	{"kitten.mid", R_MUSIC_LOOP},	// 31
+	{"sweet.mid", R_MUSIC_LOOP},	// 32
+	{"brutalmt.mid", R_MUSIC_LOOP},	// 33
+	{"shiala.mid", R_MUSIC_LOOP}	// 34
 };
 
 int Music::play(uint32 music_rn, uint16 flags) {
@@ -212,9 +212,7 @@
 
 	if (GAME_GetGameType() == GID_ITE) {
 		if (music_rn >= 9 && music_rn <= 34) {
-			char file_name[20];
-			sprintf(file_name, "music/%s.mid", _midiTableITECD[music_rn - 9].filename);
-			f_midi.open(file_name);
+			f_midi.open(_midiTableITECD[music_rn - 9].filename);
 		}
 	}
 

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- saga.cpp	28 Sep 2004 20:19:27 -0000	1.49
+++ saga.cpp	1 Oct 2004 06:45:13 -0000	1.50
@@ -83,7 +83,15 @@
 SagaEngine::SagaEngine(GameDetector *detector, OSystem *syst)
 	: Engine(syst) {
 
-	GAME_setGameDirectory(getGameDataPath());
+	// The Linux version of Inherit the Earth puts all data files in an
+	// 'itedata' sub-directory, except for voices.rsc
+	File::addDefaultDirectory(_gameDataPath + "/itedata/");
+
+	// The Windows version of Inherit the Earth puts various data files in
+	// other subdirectories.
+	File::addDefaultDirectory(_gameDataPath + "/graphics/");
+	File::addDefaultDirectory(_gameDataPath + "/music/");
+	File::addDefaultDirectory(_gameDataPath + "/sound/");
 
 	// Setup mixer
 	if (!_mixer->isReady()) {

Index: sndres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- sndres.cpp	27 Aug 2004 01:32:10 -0000	1.20
+++ sndres.cpp	1 Oct 2004 06:45:13 -0000	1.21
@@ -61,22 +61,50 @@
 
 	debug(0, "SndRes::playVoice(%ld)", voice_rn);
 
-	// The Wyrmkeep release of Inherit the Earth provides a separate VOC
-	// file, sound/p2_a.voc, to correct voice 4 in the intro. Use that, if
-	// available.
-	// 
-	// FIXME: There's a nasty 'pop' at the beginning of the sound, and a
-	// smaller one at the end. I don't know if that's in the file, or in
-	// our playback code.
+	if (GAME_GetGameType() == GID_ITE && voice_rn == 4) {
+		// The Windows version of the Wyrmkeep release of Inherit the
+		// Earth provides a separate VOC file, sound/p2_a.voc, to
+		// correct voice 4 in the intro. In the Linux version, it's
+		// called P2_A.iaf and appears to be plain raw data.
+		//
+		// In either case, use the file if available.
+		// 
+		// FIXME: In the VOC case there's a nasty 'pop' at the
+		// beginning of the sound, , and a smaller one at the end. In
+		// the IAF case, the next voice will overlap. At least part of
+		// this is because of an obvious bug in playVoice(). See the
+		// FIXME comment there.
 
-	File f;
+		File f;
+		uint32 size;
+		bool voc = false;
 
-	if (GAME_GetGameType() == GID_ITE && voice_rn == 4 && f.open("sound/p2_a.voc")) {
-		uint32 size = f.size();
+		if (f.open("p2_a.voc"))
+			voc = true;
+		else
+			f.open("P2_A.iaf");
+
+		if (!f.isOpen())
+			return R_FAILURE;
+
+		size = f.size();
 		byte *snd_res = (byte *)malloc(size);
 		f.read(snd_res, size);
-		result = loadVocSound(snd_res, size, &snd_buffer);
 		f.close();
+
+		if (!voc) {
+			// FIXME: Verify this!
+			snd_buffer.s_stereo = 0;
+			snd_buffer.s_samplebits = 16;
+			snd_buffer.s_freq = 22050;
+			snd_buffer.res_data = snd_res;
+			snd_buffer.res_len = size;
+			snd_buffer.s_buf = snd_res + 16760;
+			snd_buffer.s_buf_len = size - 16760;
+			snd_buffer.s_signed = 1;
+			result = R_SUCCESS;
+		} else
+			result = loadVocSound(snd_res, size, &snd_buffer);
 	} else
 		result = load(_voice_ctxt, voice_rn, &snd_buffer);
 

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sound.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- sound.cpp	2 Aug 2004 16:20:35 -0000	1.10
+++ sound.cpp	1 Oct 2004 06:45:13 -0000	1.11
@@ -130,6 +130,11 @@
 	}
 #endif
 
+	// FIXME: No, no, NO! We should use buf->s_buf and buf->s_buf_len, not
+	//        buf->res_data and buf->res_len. Right now, we're playing the
+	//        resource header as if it was a sound! But we can't just
+	//        change it without also removing FLAG_AUTOFREE...
+
 	_mixer->playRaw(&_voiceHandle, buf->res_data, buf->res_len, buf->s_freq, flags);
 
 	return R_SUCCESS;

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sound.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sound.h	2 Aug 2004 16:20:35 -0000	1.7
+++ sound.h	1 Oct 2004 06:45:13 -0000	1.8
@@ -41,7 +41,7 @@
 	int s_stereo;
 	int s_signed;
 
-	const byte *s_buf;
+	byte *s_buf;
 	size_t s_buf_len;
 };
 





More information about the Scummvm-git-logs mailing list