[Scummvm-cvs-logs] SF.net SVN: scummvm: [28256] scummvm/trunk

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Sat Jul 28 09:52:25 CEST 2007


Revision: 28256
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28256&view=rev
Author:   Kirben
Date:     2007-07-28 00:52:24 -0700 (Sat, 28 Jul 2007)

Log Message:
-----------
Add support for multi-tune Protracker modules used in the Amiga version of Waxworks.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/res_snd.cpp
    scummvm/trunk/engines/parallaction/disk.h
    scummvm/trunk/engines/parallaction/disk_br.cpp
    scummvm/trunk/engines/parallaction/disk_ns.cpp
    scummvm/trunk/engines/parallaction/sound.cpp
    scummvm/trunk/sound/mods/module.cpp
    scummvm/trunk/sound/mods/module.h
    scummvm/trunk/sound/mods/protracker.cpp
    scummvm/trunk/sound/mods/protracker.h

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/engines/agos/agos.cpp	2007-07-28 07:52:24 UTC (rev 28256)
@@ -820,7 +820,7 @@
 	_numTextBoxes = 10;
 	_numVars = 255;
 
-	_numMusic = 9;
+	_numMusic = 26;
 
 	AGOSEngine::setupGame();
 }

Modified: scummvm/trunk/engines/agos/res_snd.cpp
===================================================================
--- scummvm/trunk/engines/agos/res_snd.cpp	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/engines/agos/res_snd.cpp	2007-07-28 07:52:24 UTC (rev 28256)
@@ -139,10 +139,57 @@
 	_nextMusicToPlay = -1;
 }
 
+struct ModuleOffs {
+	uint8 tune;
+	uint8 fileNum;
+	uint32 offs;
+};
+
+static const ModuleOffs amigaWaxworksOffs[20] = {
+	// Pyramid
+	{2,   2, 0,   },
+	{3,   2, 50980},
+	{4,   2, 56160},
+	{5,   2, 62364},
+	{6,   2, 73688},
+
+	// Zombie
+	{8,   8, 0},
+	{11,  8, 51156},
+	{12,  8, 56336},
+	{13,  8, 65612},
+	{14,  8, 68744},
+
+	// Mine
+	{9,   9, 0},
+	{15,  9, 47244},
+	{16,  9, 52424},
+	{17,  9, 59652},
+	{18,  9, 62784},
+
+	// Jack
+	{10, 10, 0},
+	{19, 10, 42054},
+	{20, 10, 47234},
+	{21, 10, 49342},
+	{22, 10, 51450},
+};
+
 void AGOSEngine::playModule(uint16 music) {
 	char filename[15];
 	File f;
+	uint32 offs = 0;
 
+	if (getPlatform() == Common::kPlatformAmiga && getGameType() == GType_WW) {
+		// Multiple tunes are stored in music files for main locations
+		for (uint i = 0; i < 20; i++) {
+			if (amigaWaxworksOffs[i].tune == music) {
+				music = amigaWaxworksOffs[i].fileNum;
+				offs = amigaWaxworksOffs[i].offs;
+			}
+		}
+	}
+
 	if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO)
 		sprintf(filename, "elvira2");
 	else if (getPlatform() == Common::kPlatformAcorn)
@@ -159,21 +206,21 @@
 	if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) &&
 		getFeatures() & GF_CRUNCHED) {
 
-		uint srcSize = f.size();
+		uint32 srcSize = f.size();
 		byte *srcBuf = (byte *)malloc(srcSize);
 		if (f.read(srcBuf, srcSize) != srcSize)
 			error("playModule: Read failed");
 
-		uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
+		uint32 dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
 		byte *dstBuf = (byte *)malloc(dstSize);
 		decrunchFile(srcBuf, dstBuf, srcSize);
 		free(srcBuf);
 
 		Common::MemoryReadStream stream(dstBuf, dstSize);
-		audioStream = Audio::makeProtrackerStream(&stream, _mixer->getOutputRate());
+		audioStream = Audio::makeProtrackerStream(&stream, offs);
 		free(dstBuf);
 	} else {
-		audioStream = Audio::makeProtrackerStream(&f, _mixer->getOutputRate());
+		audioStream = Audio::makeProtrackerStream(&f);
 	}
 
 	_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_modHandle, audioStream);

Modified: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/engines/parallaction/disk.h	2007-07-28 07:52:24 UTC (rev 28256)
@@ -62,7 +62,7 @@
 	virtual void loadSlide(const char *filename) = 0;
 	virtual void loadScenery(const char* background, const char* mask) = 0;
 	virtual Table* loadTable(const char* name) = 0;
-	virtual Common::ReadStream* loadMusic(const char* name) = 0;
+	virtual Common::SeekableReadStream* loadMusic(const char* name) = 0;
 	virtual Common::ReadStream* loadSound(const char* name) = 0;
 };
 
@@ -154,7 +154,7 @@
 	void loadSlide(const char *filename);
 	void loadScenery(const char* background, const char* mask);
 	Table* loadTable(const char* name);
-	Common::ReadStream* loadMusic(const char* name);
+	Common::SeekableReadStream* loadMusic(const char* name);
 	Common::ReadStream* loadSound(const char* name);
 };
 
@@ -188,7 +188,7 @@
 	void loadSlide(const char *filename);
 	void loadScenery(const char* background, const char* mask);
 	Table* loadTable(const char* name);
-	Common::ReadStream* loadMusic(const char* name);
+	Common::SeekableReadStream* loadMusic(const char* name);
 	Common::ReadStream* loadSound(const char* name);
 };
 
@@ -222,7 +222,7 @@
 	void loadSlide(const char *filename);
 	void loadScenery(const char* background, const char* mask);
 	Table* loadTable(const char* name);
-	Common::ReadStream* loadMusic(const char* name);
+	Common::SeekableReadStream* loadMusic(const char* name);
 	Common::ReadStream* loadSound(const char* name);
 };
 

Modified: scummvm/trunk/engines/parallaction/disk_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_br.cpp	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/engines/parallaction/disk_br.cpp	2007-07-28 07:52:24 UTC (rev 28256)
@@ -119,7 +119,7 @@
 	return 0;
 }
 
-Common::ReadStream* DosDisk_br::loadMusic(const char* name) {
+Common::SeekableReadStream* DosDisk_br::loadMusic(const char* name) {
 	debugC(5, kDebugDisk, "DosDisk_br::loadMusic");
 	return 0;
 }

Modified: scummvm/trunk/engines/parallaction/disk_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_ns.cpp	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/engines/parallaction/disk_ns.cpp	2007-07-28 07:52:24 UTC (rev 28256)
@@ -674,7 +674,7 @@
 	return t;
 }
 
-Common::ReadStream* DosDisk_ns::loadMusic(const char* name) {
+Common::SeekableReadStream* DosDisk_ns::loadMusic(const char* name) {
 	char path[PATH_LEN];
 	sprintf(path, "%s.mid", name);
 
@@ -1427,7 +1427,7 @@
 }
 
 
-Common::ReadStream* AmigaDisk_ns::loadMusic(const char* name) {
+Common::SeekableReadStream* AmigaDisk_ns::loadMusic(const char* name) {
 	return openArchivedFile(name);
 }
 

Modified: scummvm/trunk/engines/parallaction/sound.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/sound.cpp	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/engines/parallaction/sound.cpp	2007-07-28 07:52:24 UTC (rev 28256)
@@ -379,7 +379,7 @@
 
 	debugC(1, kDebugAudio, "AmigaSoundMan::playMusic()");
 
-	Common::ReadStream *stream = _vm->_disk->loadMusic(_musicFile);
+	Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile);
 	_musicStream = Audio::makeProtrackerStream(stream);
 	delete stream;
 

Modified: scummvm/trunk/sound/mods/module.cpp
===================================================================
--- scummvm/trunk/sound/mods/module.cpp	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/sound/mods/module.cpp	2007-07-28 07:52:24 UTC (rev 28256)
@@ -113,7 +113,9 @@
 	 216 , 203 , 192 , 181 , 171 , 161 , 152 , 144 , 136 , 128 , 121 , 114,
 	 108 , 101 , 96  , 90  , 85  , 80  , 76  , 72  , 68  , 64  , 60  , 57 }};
 
-bool Module::load(Common::ReadStream &st) {
+bool Module::load(Common::SeekableReadStream &st, int offs) {
+	st.seek(offs);
+
 	st.read(songname, 20);
 	songname[20] = '\0';
 
@@ -160,17 +162,33 @@
 	}
 
 	for (int i = 0; i < NUM_SAMPLES; ++i) {
-		if (!sample[i].len)
+		if (offs == 0) {
+			// Store locations for modules that use common samples
+			memcpy(commonSamples[i].name, sample[i].name, 22);
+			commonSamples[i].len = sample[i].len;
+			commonSamples[i].offs = st.pos();
+
+		}
+
+		if (!sample[i].len) {
 			sample[i].data = 0;
-		else {
+		} else {
+			if (offs != 0) {		
+				// For modules that use common samples
+				for (int j = 0; j < NUM_SAMPLES; ++j) {
+					if (!scumm_stricmp((const char *)commonSamples[j].name, (const char *)sample[i].name)) {
+						sample[i].len = commonSamples[i].len;
+						st.seek(commonSamples[j].offs);
+						break;
+					}
+				}
+			}
+
 			sample[i].data = new int8[sample[i].len];
 			st.read((byte *)sample[i].data, sample[i].len);
 		}
 	}
 
-	if (!st.eos())
-		warning("Expected EOS on module stream");
-
 	return true;
 }
 

Modified: scummvm/trunk/sound/mods/module.h
===================================================================
--- scummvm/trunk/sound/mods/module.h	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/sound/mods/module.h	2007-07-28 07:52:24 UTC (rev 28256)
@@ -53,12 +53,19 @@
 	int8 *data;
 };
 
+struct sample_offs {
+	byte name[23];
+	uint16 len;
+	uint32 offs;
+};
+
 class Module {
 public:
 	byte songname[21];
 
 	static const int NUM_SAMPLES = 31;
 	sample_t sample[NUM_SAMPLES];
+	sample_offs commonSamples[NUM_SAMPLES];
 
 	byte songlen;
 	byte undef;
@@ -69,7 +76,7 @@
 	Module();
 	~Module();
 
-	bool load(Common::ReadStream &stream);
+	bool load(Common::SeekableReadStream &stream, int offs);
 	static byte periodToNote(int16 period, byte finetune = 0);
 	static int16 noteToPeriod(byte note, byte finetune = 0);
 

Modified: scummvm/trunk/sound/mods/protracker.cpp
===================================================================
--- scummvm/trunk/sound/mods/protracker.cpp	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/sound/mods/protracker.cpp	2007-07-28 07:52:24 UTC (rev 28256)
@@ -90,7 +90,7 @@
 	} _track[4];
 
 public:
-	ProtrackerStream(Common::ReadStream *stream, int rate, bool stereo);
+	ProtrackerStream(Common::SeekableReadStream *stream, int offs, int rate, bool stereo);
 
 private:
 	void interrupt();
@@ -145,9 +145,9 @@
 	-180, -161, -141, -120,  -97,  -74,  -49,  -24
 };
 
-ProtrackerStream::ProtrackerStream(Common::ReadStream *stream, int rate, bool stereo) :
+ProtrackerStream::ProtrackerStream(Common::SeekableReadStream *stream, int offs, int rate, bool stereo) :
 		Paula(stereo, rate, rate/50) {
-	bool result = _module.load(*stream);
+	bool result = _module.load(*stream, offs);
 	assert(result);
 
 	_tick = _row = _pos = 0;
@@ -461,8 +461,8 @@
 
 namespace Audio {
 
-AudioStream *makeProtrackerStream(Common::ReadStream *stream, int rate, bool stereo) {
-	return new Modules::ProtrackerStream(stream, rate, stereo);
+AudioStream *makeProtrackerStream(Common::SeekableReadStream *stream, int offs, int rate, bool stereo) {
+	return new Modules::ProtrackerStream(stream, offs, rate, stereo);
 }
 
 } // End of namespace Audio

Modified: scummvm/trunk/sound/mods/protracker.h
===================================================================
--- scummvm/trunk/sound/mods/protracker.h	2007-07-28 02:25:09 UTC (rev 28255)
+++ scummvm/trunk/sound/mods/protracker.h	2007-07-28 07:52:24 UTC (rev 28256)
@@ -44,7 +44,7 @@
  * @param stereo	TODO
  * @return	a new AudioStream, or NULL, if an error occured
  */
-AudioStream *makeProtrackerStream(Common::ReadStream *stream, int rate = 44100, bool stereo = true);
+AudioStream *makeProtrackerStream(Common::SeekableReadStream *stream, int offs = 0, int rate = 44100, bool stereo = true);
 
 } // End of namespace Audio
 


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