[Scummvm-cvs-logs] CVS: scummvm/sword1 sound.cpp,1.27,1.28 sound.h,1.13,1.14 sword1.cpp,1.50,1.51 sword1.h,1.13,1.14

Travis Howell kirben at users.sourceforge.net
Tue Aug 31 00:54:03 CEST 2004


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

Modified Files:
	sound.cpp sound.h sword1.cpp sword1.h 
Log Message:

Add eriktorbjorn's patch for separate target for Broken Sword 1 demo. Avoids sound regressions in full game.


Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- sound.cpp	27 Jul 2004 03:47:49 -0000	1.27
+++ sound.cpp	31 Aug 2004 07:52:46 -0000	1.28
@@ -31,7 +31,7 @@
 #define SOUND_SPEECH_ID 1
 #define SPEECH_FLAGS (SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LITTLE_ENDIAN)
 
-Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan) {
+Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan, bool isDemo) {
 	strcpy(_filePath, searchPath);
 	_mixer = mixer;
 	_resMan = pResMan;
@@ -39,6 +39,7 @@
 	_endOfQueue = 0;
 	_currentCowFile = 0;
 	_speechVolL = _speechVolR = _sfxVolL = _sfxVolR = 192;
+	_isDemo = isDemo;
 }
 
 int Sound::addToQueue(int32 fxNo) {
@@ -185,13 +186,13 @@
 	while ((READ_BE_UINT32(fBuf + headerPos) != 'data') && (headerPos < 100))
 		headerPos++;
 	if (headerPos < 100) {
-		uint32 resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
+		int32 resSize;
 		// Demo uses slightly different headers
-		if (resSize > cSize) {
+		if (_isDemo) {
 			resSize = READ_LE_UINT32(fBuf + headerPos + 6) >> 1;
 			headerPos += 2;
-		}
-
+		} else
+			resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
 		int16 *srcData = (int16*)(fBuf + headerPos + 8);
 		int16 *dstData = (int16*)malloc(resSize * 2);
 		uint32 srcPos = 0;

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- sound.h	11 Jan 2004 15:47:41 -0000	1.13
+++ sound.h	31 Aug 2004 07:52:47 -0000	1.14
@@ -60,7 +60,7 @@
 
 class Sound {
 public:
-	Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan);
+	Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan, bool isDemo);
 	~Sound(void);
 	void setSpeechVol(uint8 volL, uint8 volR) { _speechVolL = volL; _speechVolR = volR; };
 	void setSfxVol(uint8 volL, uint8 volR) { _sfxVolL = volL; _sfxVolR = volR; };
@@ -100,6 +100,7 @@
 	uint8		 _endOfQueue;
 	SoundMixer *_mixer;
 	ResMan *_resMan;
+	bool _isDemo;
 	char _filePath[100];
 	static const char _musicList[270];
 	static const uint16 _roomsFixedFx[TOTAL_ROOMS][TOTAL_FX_PER_ROOM];

Index: sword1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- sword1.cpp	11 Aug 2004 21:49:58 -0000	1.50
+++ sword1.cpp	31 Aug 2004 07:52:47 -0000	1.51
@@ -47,29 +47,43 @@
 using namespace Sword1;
 
 /* Broken Sword 1 */
-static const GameSettings sword1_setting =
-	{"sword1", "Broken Sword I", GF_DEFAULT_TO_1X_SCALER};
+static const GameSettings sword1_settings[] = {
+	{"sword1", "Broken Sword I", GF_DEFAULT_TO_1X_SCALER},
+	{"sword1demo", "Broken Sword I (Demo)", GF_DEFAULT_TO_1X_SCALER | Sword1::GF_DEMO },
+	{ NULL, NULL, 0 }
+};
 
 GameList Engine_SWORD1_gameList() {
+	const GameSettings *g = sword1_settings;
 	GameList games;
-	games.push_back(sword1_setting);
+	while (g->name) {	
+		games.push_back(*g);
+		g++;
+	}
 	return games;
 }
 
 DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) {
 	DetectedGameList detectedGames;
+	const GameSettings *g = sword1_settings;
 
-	// Iterate over all files in the given directory
-	for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
-		const char *gameName = file->displayName().c_str();
+	// TODO: It would be nice if we had code here which distinguishes
+	// between the 'sword1' and 'sword1demo' targets.
 
-		if ((0 == scumm_stricmp("swordres.rif", gameName)) ||
-			(0 == scumm_stricmp("cd1.id", gameName)) ||
-			(0 == scumm_stricmp("cd2.id", gameName))) {
-			// Match found, add to list of candidates, then abort inner loop.
-			detectedGames.push_back(sword1_setting);
-			break;
+	while (g->name) {
+		// Iterate over all files in the given directory
+		for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
+			const char *gameName = file->displayName().c_str();
+
+			if ((0 == scumm_stricmp("swordres.rif", gameName)) ||
+				(0 == scumm_stricmp("cd1.id", gameName)) ||
+				(0 == scumm_stricmp("cd2.id", gameName))) {
+				// Match found, add to list of candidates, then abort inner loop.
+				detectedGames.push_back(*g);
+				break;
+			}
 		}
+		g++;
 	}
 
 	return detectedGames;
@@ -92,6 +106,8 @@
 SwordEngine::SwordEngine(GameDetector *detector, OSystem *syst)
 	: Engine(syst) {
 
+	_features = detector->_game.features;
+
 	if (!_mixer->isReady())
 		warning("Sound initialization failed");
 }
@@ -122,7 +138,7 @@
 	_mouse = new Mouse(_system, _resMan, _objectMan);
 	_screen = new Screen(_system, _resMan, _objectMan);
 	_music = new Music(_system, _mixer);
-	_sound = new Sound("", _mixer, _resMan);
+	_sound = new Sound("", _mixer, _resMan, (_features & GF_DEMO) != 0);
 	_menu = new Menu(_screen, _mouse);
 	_logic = new Logic(_objectMan, _resMan, _screen, _mouse, _sound, _music, _menu, _system, _mixer);
 	_mouse->useLogicAndMenu(_logic, _menu);

Index: sword1.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- sword1.h	11 Jan 2004 15:47:41 -0000	1.13
+++ sword1.h	31 Aug 2004 07:52:47 -0000	1.14
@@ -29,6 +29,10 @@
 
 namespace Sword1 {
 
+enum {
+	GF_DEMO = 1 << 0
+};
+
 class Screen;
 class Sound;
 class Logic;
@@ -61,6 +65,8 @@
 	virtual ~SwordEngine();
 	static SystemVars _systemVars;
 	void reinitialize(void);
+
+	uint32 _features;
 protected:
 	void go();
 private:





More information about the Scummvm-git-logs mailing list