[Scummvm-cvs-logs] SF.net SVN: scummvm:[35352] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Dec 14 04:44:40 CET 2008


Revision: 35352
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35352&view=rev
Author:   drmccoy
Date:     2008-12-14 03:44:39 +0000 (Sun, 14 Dec 2008)

Log Message:
-----------
Background "music" for Urban Runner, though only 8bit for now

Modified Paths:
--------------
    scummvm/trunk/engines/gob/inter_bargon.cpp
    scummvm/trunk/engines/gob/inter_v4.cpp
    scummvm/trunk/engines/gob/inter_v6.cpp
    scummvm/trunk/engines/gob/map_v1.cpp
    scummvm/trunk/engines/gob/sound/sound.cpp
    scummvm/trunk/engines/gob/sound/sound.h
    scummvm/trunk/engines/gob/sound/sounddesc.cpp
    scummvm/trunk/engines/gob/sound/sounddesc.h

Modified: scummvm/trunk/engines/gob/inter_bargon.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_bargon.cpp	2008-12-14 03:08:02 UTC (rev 35351)
+++ scummvm/trunk/engines/gob/inter_bargon.cpp	2008-12-14 03:44:39 UTC (rev 35352)
@@ -771,7 +771,7 @@
 		return;
 
 	for (i = 0; i < 4; i++)
-		_vm->_sound->sampleLoad(&samples[i], sndFiles[i]);
+		_vm->_sound->sampleLoad(&samples[i], SOUND_SND, sndFiles[i]);
 	_vm->_sound->blasterPlayComposition(comp, 0, samples, 4);
 	_vm->_sound->blasterWaitEndPlay(true, false);
 	_vm->_palAnim->fade(0, 0, 0);
@@ -790,7 +790,7 @@
 	static const char *palFiles[] = {"2ou2.clt", "2ou3.clt", "2ou4.clt", "2ou5.clt"};
 
 	for (int i = 0; i < 2; i++)
-		_vm->_sound->sampleLoad(&samples[i], sndFiles[i]);
+		_vm->_sound->sampleLoad(&samples[i], SOUND_SND, sndFiles[i]);
 	for (int i = 0; i < 4; i++)
 		palettes[i] = _vm->_dataIO->getData(palFiles[i]);
 	palBak = _vm->_global->_pPaletteDesc->vgaPal;

Modified: scummvm/trunk/engines/gob/inter_v4.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v4.cpp	2008-12-14 03:08:02 UTC (rev 35351)
+++ scummvm/trunk/engines/gob/inter_v4.cpp	2008-12-14 03:44:39 UTC (rev 35352)
@@ -871,7 +871,7 @@
 	} else if (lastFrame == -9) {
 		_vm->_sound->bgStop();
 		_vm->_sound->bgSetPlayMode(BackgroundAtmosphere::kPlayModeRandom);
-		_vm->_sound->bgPlay(fileName, palStart);
+		_vm->_sound->bgPlay(fileName, "SND", SOUND_SND, palStart);
 		return;
 	} else if (lastFrame < 0) {
 		warning("Unknown Video/Music command: %d, %s", lastFrame, fileName);

Modified: scummvm/trunk/engines/gob/inter_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v6.cpp	2008-12-14 03:08:02 UTC (rev 35351)
+++ scummvm/trunk/engines/gob/inter_v6.cpp	2008-12-14 03:44:39 UTC (rev 35352)
@@ -686,10 +686,11 @@
 	if (lastFrame == -1) {
 		close = true;
 	} else if (lastFrame == -5) {
-		warning("Urban Stub: Stopping background music \"%s\"", fileName);
+		_vm->_sound->bgStop();
 		return;
 	} else if (lastFrame == -9) {
-		warning("Urban Stub: Starting background music \"%s\"", fileName);
+		_vm->_sound->bgStop();
+		_vm->_sound->bgPlay(fileName, SOUND_WAV);
 		return;
 	} else if (lastFrame == -10) {
 		_vm->_vidPlayer->primaryClose();

Modified: scummvm/trunk/engines/gob/map_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/map_v1.cpp	2008-12-14 03:08:02 UTC (rev 35351)
+++ scummvm/trunk/engines/gob/map_v1.cpp	2008-12-14 03:44:39 UTC (rev 35352)
@@ -159,7 +159,7 @@
 		strcpy(sndNames[i], buf);
 	}
 
-	_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[14], "diamant1.snd");
+	_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[14], SOUND_SND, "diamant1.snd");
 
 	for (int i = 0; i < count; i++) {
 		handle = _vm->_dataIO->openData(sndNames[i]);
@@ -167,7 +167,7 @@
 			continue;
 
 		_vm->_dataIO->closeData(handle);
-		_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[i], sndNames[i]);
+		_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[i], SOUND_SND, sndNames[i]);
 	}
 }
 

Modified: scummvm/trunk/engines/gob/sound/sound.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound/sound.cpp	2008-12-14 03:08:02 UTC (rev 35351)
+++ scummvm/trunk/engines/gob/sound/sound.cpp	2008-12-14 03:44:39 UTC (rev 35352)
@@ -50,6 +50,8 @@
 		_cdrom = new CDROM;
 	if (_vm->getGameType() == kGameTypeWoodruff)
 		_bgatmos = new BackgroundAtmosphere(*_vm->_mixer);
+	if (_vm->getGameType() == kGameTypeUrban)
+		_bgatmos = new BackgroundAtmosphere(*_vm->_mixer);
 }
 
 Sound::~Sound() {
@@ -91,7 +93,7 @@
 	return -1;
 }
 
-bool Sound::sampleLoad(SoundDesc *sndDesc, const char *fileName, bool tryExist) {
+bool Sound::sampleLoad(SoundDesc *sndDesc, SoundType type, const char *fileName, bool tryExist) {
 	if (!sndDesc)
 		return false;
 
@@ -113,9 +115,7 @@
 		return false;
 
 	size = _vm->_dataIO->getDataSize(fileName);
-	sndDesc->load(SOUND_SND, SOUND_FILE, data, size);
-
-	return true;
+	return sndDesc->load(type, SOUND_FILE, data, size);
 }
 
 void Sound::sampleFree(SoundDesc *sndDesc, bool noteAdlib, int index) {
@@ -520,7 +520,7 @@
 	_cdrom->testCD(trySubst, label);
 }
 
-void Sound::bgPlay(const char *file) {
+void Sound::bgPlay(const char *file, SoundType type) {
 	if (!_bgatmos)
 		return;
 
@@ -530,7 +530,7 @@
 	_bgatmos->queueClear();
 
 	SoundDesc *sndDesc = new SoundDesc;
-	if (!sampleLoad(sndDesc, file)) {
+	if (!sampleLoad(sndDesc, type, file)) {
 		delete sndDesc;
 		return;
 	}
@@ -539,7 +539,7 @@
 	_bgatmos->play();
 }
 
-void Sound::bgPlay(const char *base, int count) {
+void Sound::bgPlay(const char *base, const char *ext, SoundType type, int count) {
 	if (!_bgatmos)
 		return;
 
@@ -553,10 +553,10 @@
 	SoundDesc *sndDesc;
 
 	for (int i = 1; i <= count; i++) {
-		snprintf(fileName, length, "%s%02d.SND", base, i);
+		snprintf(fileName, length, "%s%02d.%s", base, i, ext);
 
 		sndDesc = new SoundDesc;
-		if (sampleLoad(sndDesc, fileName))
+		if (sampleLoad(sndDesc, type, fileName))
 			_bgatmos->queueSample(*sndDesc);
 		else
 			delete sndDesc;

Modified: scummvm/trunk/engines/gob/sound/sound.h
===================================================================
--- scummvm/trunk/engines/gob/sound/sound.h	2008-12-14 03:08:02 UTC (rev 35351)
+++ scummvm/trunk/engines/gob/sound/sound.h	2008-12-14 03:44:39 UTC (rev 35352)
@@ -50,7 +50,7 @@
 	const SoundDesc *sampleGetBySlot(int slot) const;
 	int sampleGetNextFreeSlot() const;
 
-	bool sampleLoad(SoundDesc *sndDesc, const char *fileName, bool tryExist = true);
+	bool sampleLoad(SoundDesc *sndDesc, SoundType type, const char *fileName, bool tryExist = true);
 	void sampleFree(SoundDesc *sndDesc, bool noteAdlib = false, int index = -1);
 
 
@@ -121,8 +121,8 @@
 
 
 	// Background Atmosphere
-	void bgPlay(const char *file);
-	void bgPlay(const char *base, int count);
+	void bgPlay(const char *file, SoundType type);
+	void bgPlay(const char *base, const char *ext, SoundType type, int count);
 	void bgStop();
 
 	void bgSetPlayMode(BackgroundAtmosphere::PlayMode mode);

Modified: scummvm/trunk/engines/gob/sound/sounddesc.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound/sounddesc.cpp	2008-12-14 03:08:02 UTC (rev 35351)
+++ scummvm/trunk/engines/gob/sound/sounddesc.cpp	2008-12-14 03:44:39 UTC (rev 35352)
@@ -24,6 +24,9 @@
  */
 
 #include "common/util.h"
+#include "common/stream.h"
+#include "sound/mixer.h"
+#include "sound/wave.h"
 
 #include "gob/sound/sounddesc.h"
 
@@ -57,7 +60,7 @@
 	_size = dSize;
 }
 
-void SoundDesc::load(SoundType type, SoundSource src,
+bool SoundDesc::load(SoundType type, SoundSource src,
 		byte *data, uint32 dSize) {
 
 	free();
@@ -65,12 +68,14 @@
 	_source = src;
 	switch (type) {
 	case SOUND_ADL:
-		loadADL(data, dSize);
-		break;
+		return loadADL(data, dSize);
 	case SOUND_SND:
-		loadSND(data, dSize);
-		break;
+		return loadSND(data, dSize);
+	case SOUND_WAV:
+		return loadWAV(data, dSize);
 	}
+
+	return false;
 }
 
 void SoundDesc::free() {
@@ -81,7 +86,7 @@
 }
 
 void SoundDesc::convToSigned() {
-	if ((_type == SOUND_SND) && _data && _dataPtr)
+	if (((_type == SOUND_SND) || (_type == SOUND_WAV)) && _data && _dataPtr)
 		for (uint32 i = 0; i < _size; i++)
 			_dataPtr[i] ^= 0x80;
 }
@@ -95,7 +100,7 @@
 	return ((_size * repCount - fadeSize) * 1000) / frequency;
 }
 
-void SoundDesc::loadSND(byte *data, uint32 dSize) {
+bool SoundDesc::loadSND(byte *data, uint32 dSize) {
 	assert(dSize > 6);
 
 	_type = SOUND_SND;
@@ -105,12 +110,47 @@
 	_flag = data[0] ? (data[0] & 0x7F) : 8;
 	data[0] = 0;
 	_size = MIN(READ_BE_UINT32(data), dSize - 6);
+
+	return true;
 }
 
-void SoundDesc::loadADL(byte *data, uint32 dSize) {
+bool SoundDesc::loadWAV(byte *data, uint32 dSize) {
+	Common::MemoryReadStream stream(data, dSize);
+
+	int wavSize, wavRate;
+	byte wavFlags;
+	uint16 wavtype;
+
+	if (!Audio::loadWAVFromStream(stream, wavSize, wavRate, wavFlags, &wavtype, 0))
+		return false;
+
+	if (wavFlags & Audio::Mixer::FLAG_16BITS) {
+		warning("TODO: SoundDesc::loadWAV() - 16bit");
+		return false;
+	}
+
+	if (wavFlags & Audio::Mixer::FLAG_STEREO) {
+		warning("TODO: SoundDesc::loadWAV() - stereo");
+		return false;
+	}
+
+	_data = data;
+	_dataPtr = data + stream.pos();
+	_size = wavSize;
+	_frequency = wavRate;
+
+	if (wavFlags & Audio::Mixer::FLAG_UNSIGNED)
+		convToSigned();
+
+	return true;
+}
+
+bool SoundDesc::loadADL(byte *data, uint32 dSize) {
 	_type = SOUND_ADL;
 	_data = _dataPtr = data;
 	_size = dSize;
+
+	return true;
 }
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/sound/sounddesc.h
===================================================================
--- scummvm/trunk/engines/gob/sound/sounddesc.h	2008-12-14 03:08:02 UTC (rev 35351)
+++ scummvm/trunk/engines/gob/sound/sounddesc.h	2008-12-14 03:44:39 UTC (rev 35352)
@@ -32,6 +32,7 @@
 
 enum SoundType {
 	SOUND_SND,
+	SOUND_WAV,
 	SOUND_ADL
 };
 
@@ -57,7 +58,7 @@
 	bool isId(int16 id) const { return _dataPtr && (_id == id); }
 
 	void set(SoundType type, SoundSource src, byte *data, uint32 dSize);
-	void load(SoundType type, SoundSource src, byte *data, uint32 dSize);
+	bool load(SoundType type, SoundSource src, byte *data, uint32 dSize);
 	void free();
 	void convToSigned();
 
@@ -76,8 +77,9 @@
 	SoundType _type;
 	SoundSource _source;
 
-	void loadSND(byte *data, uint32 dSize);
-	void loadADL(byte *data, uint32 dSize);
+	bool loadSND(byte *data, uint32 dSize);
+	bool loadWAV(byte *data, uint32 dSize);
+	bool loadADL(byte *data, uint32 dSize);
 };
 
 } // End of namespace Gob


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list