[Scummvm-cvs-logs] CVS: scummvm/simon simon.cpp,1.96,1.97 simonsound.cpp,1.2,1.3 simonsound.h,1.2,1.3

Oliver Kiehl olki at users.sourceforge.net
Tue Nov 26 08:36:06 CET 2002


Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv4143

Modified Files:
	simon.cpp simonsound.cpp simonsound.h 
Log Message:
cleanup


Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- simon.cpp	24 Nov 2002 14:47:07 -0000	1.96
+++ simon.cpp	26 Nov 2002 16:35:18 -0000	1.97
@@ -818,8 +818,7 @@
 				if (_game == GAME_SIMON1WIN )
 					_sound->readSfxFile(filename, _gameDataPath);
 				else if (_game & GAME_SIMON2) {
-					int set = atoi(filename + 6) - 1;
-					_sound->loadSfxTable(_game_file, _game_offsets_ptr[set + gss->SOUND_INDEX_BASE], set);
+					_sound->loadSfxTable(_game_file, _game_offsets_ptr[atoi(filename + 6) - 1 + gss->SOUND_INDEX_BASE]);
 				}
 
 				alignTableMem();

Index: simonsound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simonsound.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- simonsound.cpp	24 Nov 2002 13:21:31 -0000	1.2
+++ simonsound.cpp	26 Nov 2002 16:35:20 -0000	1.3
@@ -45,7 +45,7 @@
 			if (file->isOpen() == false) {
 				warning("Cannot open voice file %s", s);
 			} else	{
-				_voice = new WavSound(_mixer, file, gss->NUM_VOICE_RESOURCES);
+				_voice = new WavSound(_mixer, file);
 			}
 		} else if (_game & GAME_TALKIE) {
 			s = gss->voc_filename;
@@ -53,12 +53,12 @@
 			if (file->isOpen() == false) {
 				warning("Cannot open voice file %s", s);
 			} else {
-				_voice = new VocSound(_mixer, file, gss->NUM_VOICE_RESOURCES);
+				_voice = new VocSound(_mixer, file);
 			}
 		}
 #ifdef USE_MAD
 	} else {
-		_voice = new MP3Sound(_mixer, file, gss->NUM_VOICE_RESOURCES);
+		_voice = new MP3Sound(_mixer, file);
 	}
 #endif
 
@@ -72,11 +72,11 @@
 			if (file2->isOpen() == false) {
 				warning("Cannot open effects file %s", s);
 			} else {
-				_effects = new VocSound(_mixer, file2, gss->NUM_VOICE_RESOURCES);
+				_effects = new VocSound(_mixer, file2);
 			}
 #ifdef USE_MAD
 		} else {
-			_effects = new MP3Sound(_mixer, file2, gss->NUM_VOICE_RESOURCES);
+			_effects = new MP3Sound(_mixer, file2);
 		}
 #endif
 	}
@@ -97,17 +97,14 @@
 	_effects = new WavSound(_mixer, file);
 }
 
-void SimonSound::loadSfxTable(File *gameFile, uint32 offs, int set) 
+void SimonSound::loadSfxTable(File *gameFile, uint32 base) 
 {
-	if (!set)
-		return;
-
 	stopAll();
 
 	if (_game & GAME_WIN)
-		_effects = new WavSound(_mixer, gameFile, offs, set);
+		_effects = new WavSound(_mixer, gameFile, base);
 	else
-		_effects = new VocSound(_mixer, gameFile, offs, set);
+		_effects = new VocSound(_mixer, gameFile, base);
 }
 
 void SimonSound::playVoice(uint sound)
@@ -115,7 +112,7 @@
 	if (!_voice)
 		return;
 	
-	_voice->playSound(sound, &_voice_handle, 0);
+	_voice->playSound(sound, &_voice_handle);
 }
 
 void SimonSound::playEffects(uint sound)
@@ -126,7 +123,7 @@
 	if (_effects_paused)
 		return;
 
-	_effects->playSound(sound, &_effects_handle, 0);
+	_effects->playSound(sound, &_effects_handle);
 }
 
 void SimonSound::playAmbient(uint sound)
@@ -179,131 +176,37 @@
 
 /******************************************************************************/
 
-SimonSound::WavSound::WavSound(SoundMixer *mixer, File *file, uint resources)
-{
-	_mixer = mixer;
-	_file = file;
-	loadOffsets(resources);
-}
-
-SimonSound::WavSound::WavSound(SoundMixer *mixer, File *file) /* only used in simon1win */
-{
-	_mixer = mixer;
-	_file = file;
-	loadOffsets();
-}
-
-SimonSound::WavSound::WavSound(SoundMixer *mixer, File *file, uint32 offs, int set) /* only used in simon2 */
-{
-	_mixer = mixer;
-	_file = file;
-	loadOffsets(offs, set);
-}
-
-SimonSound::VocSound::VocSound(SoundMixer *mixer, File *file, uint resources)
-{
-	_mixer = mixer;
-	_file = file;
-	loadOffsets(resources);
-}
-
-SimonSound::VocSound::VocSound(SoundMixer *mixer, File *file, uint32 offs, int set) /* only used in simon2 */
-{
-	_mixer = mixer;
-	_file = file;
-	loadOffsets(offs, set);
-}
-
-#ifdef USE_MAD
-SimonSound::MP3Sound::MP3Sound(SoundMixer *mixer, File *file, uint resources)
+SimonSound::Sound::Sound(SoundMixer *mixer, File *file, uint32 base)
 {
 	_mixer = mixer;
 	_file = file;
 
-	_offsets = (uint32 *)malloc((resources + 1) * sizeof(uint32));
-
-	if (_offsets == NULL)
-		error("Out of memory for voice offsets");
-	
-	if (_file->read(_offsets, resources * sizeof(uint32)) != resources * sizeof(uint32))
-		error("Cannot read offsets");
-
-#ifdef SCUMM_BIG_ENDIAN
-	for (uint i = 0; i < resources; i++)
-		_offsets[i] = FROM_LE_32(_offsets[i]);
-#endif
-	_file->seek(0, SEEK_END);
-	_offsets[resources] = _file->pos();
-}
-#endif
-
-/******************************************************************************/
-
-void SimonSound::Sound::loadOffsets(uint resources)
-{
-	_offsets = (uint32 *)malloc(resources * sizeof(uint32));
-
-	if (_offsets == NULL)
-		error("Out of memory for offsets");
-
-	if (_file->read(_offsets, resources * sizeof(uint32)) != resources * sizeof(uint32))
-		error("Cannot read offsets");
-
-#ifdef SCUMM_BIG_ENDIAN
-	for (uint i = 0; i < resources; i++)
-		_offsets[i] = FROM_LE_32(_offsets[i]);
-#endif
-}
-
-void SimonSound::Sound::loadOffsets()
-{
-	uint num = 0;
-
+	uint res = 0;
 	uint32 size;
 
-	_file->seek(4, SEEK_SET);
+	_file->seek(base + 4, SEEK_SET);
 	size = _file->readUint32LE();
 
-	num = size / sizeof(uint32);
-
-	_offsets = (uint32 *)malloc(size);
-
-	_file->seek(0, SEEK_SET);
-	_file->read(_offsets, size);
-
-#if defined(SCUMM_BIG_ENDIAN)
-	for (uint r = 0; r < num; r++)
-		_offsets[r] = FROM_LE_32(_offsets[r]);
-#endif
-}
-
-void SimonSound::Sound::loadOffsets(uint32 offs, int set)
-{
-	int num_per_set[] = {0, 188, 223, 217, 209, 179, 187, 189, 116, 174, 203,
-			173, 176, 38, 205, 134, 213, 212, 167, 141};
-
-	uint num;
-	uint i;
-
-	num = num_per_set[set];
+	res = size / sizeof(uint32);
 
-	if (num == 0)
-		return;
+	_offsets = (uint32 *)malloc(size + 1);
 
-	_offsets = (uint32 *)malloc(num * sizeof(uint32));
+	_file->seek(base, SEEK_SET);
 
-	_file->seek(offs, SEEK_SET);
-	_file->read(_offsets, num * sizeof(uint32));
+	if (_file->read(_offsets, size) != size)
+		error("Cannot read offsets");
 
-	for (i = 0; i < num; i++) {
+	for (uint i = 0; i < res; i++) {
 #if defined(SCUMM_BIG_ENDIAN)
 		_offsets[i] = FROM_LE_32(_offsets[i]);
 #endif
-		_offsets[i] += offs;
+		_offsets[i] += base;
 	}
-}
 
-/******************************************************************************/
+	/* only needed for mp3 */
+	_file->seek(0, SEEK_END);
+	_offsets[res] = _file->pos();
+}
 
 #if !defined(__GNUC__)
 #pragma START_PACK_STRUCTS

Index: simonsound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simonsound.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- simonsound.h	24 Nov 2002 13:21:31 -0000	1.2
+++ simonsound.h	26 Nov 2002 16:35:20 -0000	1.3
@@ -9,36 +9,27 @@
 		uint32 *_offsets;
 		SoundMixer *_mixer;
 
-		void loadOffsets(uint resources);
-		void loadOffsets();
-		void loadOffsets(uint32 offs, int set);
-
 	public:
-		virtual int playSound(uint sound, PlayingSoundHandle *handle, byte flags) = 0;
+		SimonSound::Sound::Sound(SoundMixer *mixer, File *file, uint32 base = 0);
+		virtual int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0) = 0;
 	};
 
-
 	class WavSound : public Sound {
 	public:
-		WavSound(SoundMixer *mixer, File *file, uint resources);
-		WavSound(SoundMixer *mixer, File *file);
-		WavSound(SoundMixer *mixer, File *file, uint32 offs, int set);
-
-		int playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+		WavSound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
+		int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
 	};
 
 	class VocSound : public Sound {
 	public:
-		VocSound(SoundMixer *mixer, File *file, uint resources);
-		VocSound(SoundMixer *mixer, File *file, uint32 offs, int set);
-		
-		int playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+		VocSound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
+		int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
 	};
 
 	class MP3Sound : public Sound {
 	public:
-		MP3Sound(SoundMixer *mixer, File *file, uint resources);
-		int playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+		MP3Sound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
+		int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
 	};
 
 	byte _game;
@@ -61,7 +52,7 @@
 	SimonSound(const byte game, const GameSpecificSettings *gss, const char *gameDataPath, SoundMixer *mixer);
 
 	void readSfxFile(const char *filename, const char *gameDataPath);
-	void loadSfxTable(File *gameFile, uint32 offs, int set);
+	void loadSfxTable(File *gameFile, uint32 base);
 
 	void playVoice(uint sound);
 	void playEffects(uint sound);





More information about the Scummvm-git-logs mailing list