[Scummvm-cvs-logs] CVS: scummvm/simon simon.cpp,1.541,1.542 simon.h,1.162,1.163 sound.cpp,1.94,1.95 sound.h,1.29,1.30 vga.cpp,1.155,1.156

kirben kirben at users.sourceforge.net
Mon Nov 14 04:02:13 CET 2005


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

Modified Files:
	simon.cpp simon.h sound.cpp sound.h vga.cpp 
Log Message:

Initial sound support for FF.


Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.541
retrieving revision 1.542
diff -u -d -r1.541 -r1.542
--- simon.cpp	13 Nov 2005 11:53:57 -0000	1.541
+++ simon.cpp	14 Nov 2005 12:01:31 -0000	1.542
@@ -432,6 +432,7 @@
 
 	_curVgaFile1 = 0;
 	_curVgaFile2 = 0;
+	_curSfxFile = 0;
 
 	_timer1 = 0;
 	_timer5 = 0;
@@ -2275,8 +2276,9 @@
 	if (vpe->vgaFile1 != NULL)
 		return;
 
-	vpe->vgaFile2 = read_vga_from_datfile_2(vga_res * 2 + 1);
-	vpe->vgaFile1 = read_vga_from_datfile_2(vga_res * 2);
+	vpe->vgaFile1 = read_vga_from_datfile_2(vga_res * 2, 1);
+	vpe->vgaFile2 = read_vga_from_datfile_2(vga_res * 2 + 1, 2);
+	vpe->sfxFile = read_vga_from_datfile_2(vga_res * 2, 3);
 
 }
 
@@ -2358,7 +2360,7 @@
 	do {
 		if (_vgaBufFreeStart <= vpe->vgaFile1 && end >= vpe->vgaFile1 ||
 				_vgaBufFreeStart <= vpe->vgaFile2 && end >= vpe->vgaFile2) {
-			vpe->dd = 0;
+			vpe->sfxFile = NULL;
 			vpe->vgaFile1 = NULL;
 			vpe->vgaFile2 = NULL;
 		}
@@ -2386,7 +2388,7 @@
 
 	vpe = &_vgaBufferPointers[a];
 
-	vpe->dd = 0;
+	vpe->sfxFile = NULL;
 	vpe->vgaFile1 = NULL;
 	vpe->vgaFile2 = NULL;
 }
@@ -2428,6 +2430,7 @@
 
 		_curVgaFile1 = vpe->vgaFile1;
 		_curVgaFile2 = vpe->vgaFile2;
+		_curSfxFile = vpe->sfxFile;
 
 		if (vpe->vgaFile1 != NULL)
 			break;
@@ -2617,6 +2620,7 @@
 
 	_curVgaFile1 = vpe->vgaFile1;
 	_curVgaFile2 = vpe->vgaFile2;
+	_curSfxFile = vpe->sfxFile;
 
 	_vcPtr = code_ptr;
 
@@ -2728,6 +2732,7 @@
 		vpe = &_vgaBufferPointers[vsp->fileId];
 		_curVgaFile1 = vpe->vgaFile1;
 		_curVgaFile2 = vpe->vgaFile2;
+		_curSfxFile = vpe->sfxFile;
 		_windowNum = vsp->windowNum;
 		_vgaCurSpriteId = vsp->id;
 
@@ -2806,6 +2811,7 @@
 		vpe = &_vgaBufferPointers[vsp->fileId];
 		_curVgaFile1 = vpe->vgaFile1;
 		_curVgaFile2 = vpe->vgaFile2;
+		_curSfxFile = vpe->sfxFile;
 		_windowNum = vsp->windowNum;
 		_vgaCurSpriteId = vsp->id;
 
@@ -3698,7 +3704,7 @@
 	}
 }
 
-byte *SimonEngine::read_vga_from_datfile_2(uint id) {
+byte *SimonEngine::read_vga_from_datfile_2(uint id, uint type) {
 	// !!! HACK !!!
 	// allocate more space for text to cope with foreign languages that use
 	// up more space than english. I hope 6400 bytes are enough. This number
@@ -3709,20 +3715,24 @@
 		File in;
 		char buf[15];
 		uint32 size;
-		byte *dst;
+		byte *dst = NULL;
 
 		if (getPlatform() == Common::kPlatformAmiga) {
 			if (getFeatures() & GF_TALKIE)
-				sprintf(buf, "%.3d%d.out", id / 2, (id & 1) + 1);
+				sprintf(buf, "%.3d%d.out", id / 2, type);
 			else 
-				sprintf(buf, "%.3d%d.pkd", id / 2, (id & 1) + 1);
+				sprintf(buf, "%.3d%d.pkd", id / 2, type);
 		} else {
-			sprintf(buf, "%.3d%d.VGA", id / 2, (id & 1) + 1);
+			sprintf(buf, "%.3d%d.VGA", id / 2, type);
 		}
 
 		in.open(buf);
-		if (in.isOpen() == false)
-			error("read_vga_from_datfile_2: can't open %s", buf);
+		if (in.isOpen() == false) {
+			if (type == 3) 
+				return NULL;
+			else
+				error("read_vga_from_datfile_2: can't open %s", buf);
+		}
 		size = in.size();
 
 		if (getFeatures() & GF_CRUNCHED) {

Index: simon.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.h,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -d -r1.162 -r1.163
--- simon.h	14 Nov 2005 10:31:19 -0000	1.162
+++ simon.h	14 Nov 2005 12:01:31 -0000	1.163
@@ -72,7 +72,7 @@
 struct VgaPointersEntry {
 	byte *vgaFile1;
 	byte *vgaFile2;
-	uint32 dd;
+	byte *sfxFile;
 	VgaPointersEntry() { memset(this, 0, sizeof(*this)); }
 };
 
@@ -336,6 +336,7 @@
 
 	byte *_curVgaFile1;
 	byte *_curVgaFile2;
+	byte *_curSfxFile;
 
 	uint16 _timer1, _timer5, _timer4;
 
@@ -797,7 +798,7 @@
 	byte *dx_lock_attached();
 	void dx_unlock_attached();
 
-	byte *read_vga_from_datfile_2(uint id);
+	byte *read_vga_from_datfile_2(uint id, uint type);
 
 	void resfile_read(void *dst, uint32 offs, uint32 size);
 

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.cpp,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- sound.cpp	13 Nov 2005 10:01:40 -0000	1.94
+++ sound.cpp	14 Nov 2005 12:01:31 -0000	1.95
@@ -450,6 +450,36 @@
 	_voice->playSound(sound, &_voiceHandle, (_vm->getGameId() == GID_SIMON1CD32) ? 0 : Audio::Mixer::FLAG_UNSIGNED);
 }
 
+void Sound::playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient) {
+	byte flags;
+	int rate;
+
+	if (ambient) {
+		if (_ambientPaused || sound == _ambientPlaying)
+			return;
+	} else {
+		if (_effectsPaused)
+			return;
+	}
+
+	// TODO: Use sound offsets
+	soundData += 8;
+	int32 size = READ_LE_UINT32(soundData + 4);
+	Common::MemoryReadStream stream(soundData, size);
+	if (!loadWAVFromStream(stream, size, rate, flags)) {
+		error("playSoundData: Not a valid WAV data");
+	}
+
+	byte *buffer = (byte *)malloc(size);
+	memcpy(buffer, soundData + stream.pos(), size);
+
+	if (ambient && sound == _ambientPlaying) {
+		_mixer->playRaw(&_effectsHandle, buffer, size, rate, flags);
+	} else {
+		_mixer->playRaw(&_ambientHandle, buffer, size, rate, Audio::Mixer::FLAG_LOOP|flags);
+	}
+}
+
 void Sound::playEffects(uint sound) {
 	if (!_effects)
 		return;

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- sound.h	12 Nov 2005 06:01:24 -0000	1.29
+++ sound.h	14 Nov 2005 12:01:31 -0000	1.30
@@ -65,6 +65,7 @@
 	void playVoice(uint sound);
 	void playEffects(uint sound);
 	void playAmbient(uint sound);
+	void playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient);
 
 	bool hasVoice() const;
 	bool isVoiceActive() const;

Index: vga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/vga.cpp,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -d -r1.155 -r1.156
--- vga.cpp	14 Nov 2005 10:52:18 -0000	1.155
+++ vga.cpp	14 Nov 2005 12:01:31 -0000	1.156
@@ -1606,23 +1606,31 @@
 }
 
 void SimonEngine::vc52_playSound() {
-	uint16 sound_id = vc_read_next_word();
+	bool ambient = false;
+
+	uint16 sound = vc_read_next_word();
+	if (sound >= 0x8000) {
+		ambient = true;
+		sound = -sound;
+	}
 
 	if (getGameType() == GType_FF) {
 		uint16 pan = vc_read_next_word();
 		uint16 vol = vc_read_next_word();
-		debug(0, "STUB: vc52_playSound: snd %d pan %d vol %d", sound_id, pan, vol);
+		debug(0, "STUB: vc52_playSound: snd %d pan %d vol %d", sound, pan, vol);
+
+		_sound->playSoundData(_curSfxFile, sound, pan, vol, ambient);
+
 	} else if (getGameType() == GType_SIMON2) {
-		if (sound_id >= 0x8000) {
-			sound_id = -sound_id;
-			_sound->playAmbient(sound_id);
+		if (ambient) {
+			_sound->playAmbient(sound);
 		} else {
-			_sound->playEffects(sound_id);
+			_sound->playEffects(sound);
 		}
 	} else if (getFeatures() & GF_TALKIE) {
-		_sound->playEffects(sound_id);
+		_sound->playEffects(sound);
 	} else {
-		playSting(sound_id);
+		playSting(sound);
 	}
 }
 





More information about the Scummvm-git-logs mailing list