[Scummvm-cvs-logs] SF.net SVN: scummvm: [33018] scummvm/branches/gsoc2008-tfmx/sound/mods

marwanhilmi at users.sourceforge.net marwanhilmi at users.sourceforge.net
Sun Jul 13 02:58:57 CEST 2008


Revision: 33018
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33018&view=rev
Author:   marwanhilmi
Date:     2008-07-12 17:58:56 -0700 (Sat, 12 Jul 2008)

Log Message:
-----------
Added sample loading and interrupt frequency setup.
Note: Some files from trunk are still not versioned/missing so the branch won't compile.  

Modified Paths:
--------------
    scummvm/branches/gsoc2008-tfmx/sound/mods/tfmx.cpp
    scummvm/branches/gsoc2008-tfmx/sound/mods/tfmx.h

Modified: scummvm/branches/gsoc2008-tfmx/sound/mods/tfmx.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/sound/mods/tfmx.cpp	2008-07-12 20:35:44 UTC (rev 33017)
+++ scummvm/branches/gsoc2008-tfmx/sound/mods/tfmx.cpp	2008-07-13 00:58:56 UTC (rev 33018)
@@ -46,8 +46,31 @@
 		delete[] _data;
 	if (_trackData)
 		delete[] _trackData;
+	if (_sampleData)
+		delete[] _sampleData;
 }
+void Tfmx::loadSamples() {
+	// FIXME: temporary loader - just creates seekablereadstream from c:\mk.smpl
+	Common::SeekableReadStream *stream = NULL;
+	Common::File myfile;
+	myfile.addDefaultDirectory("C:");
+	myfile.open("mk.smpl");
+	stream = myfile.readStream(myfile.size());
+	myfile.close();
+	//FIXME: end temporary loader. normally the seekablereadstream will be function parameter
 
+	_sampleSize = stream->size();
+	_sampleData = new uint8[_sampleSize];
+	stream->seek(0);
+	stream->read(_sampleData, _sampleSize);
+
+	//sample data should now be initialized
+}
+
+bool Tfmx::loadSamples(Common::SeekableReadStream &stream) {
+	return true;
+}
+
 void Tfmx::load() {
 	// FIXME: temporary loader - just creates seekablereadstream from c:\mk.mdat
 	Common::SeekableReadStream *stream = NULL;
@@ -165,6 +188,12 @@
 			
 	}
 
+	if (_tempo >= 0x10) {
+	setInterruptFreq( (int)( getRate() / (_tempo * 0.4)));
+	}
+	else {
+	setInterruptFreq( (int)( getRate() / (1 / _tempo * 24)));
+	}
 	//StartPaula()
 	// and trigger updateTrackstep() cycle, called at each interrupt
 
@@ -349,7 +378,7 @@
 		_tracks[trackNumber].pattern.note.channelNumber = (byte3 & 0xF0) >> 4;
 		_tracks[trackNumber].pattern.note.volume = (byte3 & 0x0F);
 		_tracks[trackNumber].pattern.note.wait = byte4; //should set pattern wait to this
-		//updateNote();
+		//doMacros(trackNumber);
 	}
 
 	_tracks[trackNumber].pattern.data++;

Modified: scummvm/branches/gsoc2008-tfmx/sound/mods/tfmx.h
===================================================================
--- scummvm/branches/gsoc2008-tfmx/sound/mods/tfmx.h	2008-07-12 20:35:44 UTC (rev 33017)
+++ scummvm/branches/gsoc2008-tfmx/sound/mods/tfmx.h	2008-07-13 00:58:56 UTC (rev 33018)
@@ -40,9 +40,12 @@
 
 		//temporary loader function, will be moved to one below
 		void load();
+		void loadSamples();
+
 		//load function loads file from stream, performs checks, initializes some variables
 		bool load(Common::SeekableReadStream &stream);
-		
+		bool loadSamples(Common::SeekableReadStream &stream);
+
 		//generic function to start playback
 		//will likely change to playSong(uint8 songNumber)
 		bool play();
@@ -52,6 +55,10 @@
 		uint8 *_data;      
 		uint32 _dataSize; 
 
+		//uint8 stream for sample data from SMPL file
+		uint8 *_sampleData;
+		uint32 _sampleSize;
+
 		//addresses of tables in MDAT file
 		uint32 _trackTableOffset;
 		uint32 _patternTableOffset;
@@ -85,6 +92,7 @@
 			uint8 channelNumber;
 			uint8 volume;
 			uint8 wait;
+			uint8 type; //4 types of notes
 		};
 
 		//Pattern structure; contains note
@@ -105,12 +113,21 @@
 		//	uint16 loopCount;
 		};
 
+		//Sample structure; initialized by macro commands
+		struct Sample {
+			int8 *data;
+			uint32 offset; //offset into sample file
+			uint32 length; //length of sample
+
+		};
+
 		//Track structure; contains pattern
 		//Setup as 8-track array, each track gets updated on interrupt
 		struct Track {
 			uint16 data;
 			bool updateFlag;
 			bool activeFlag;
+			Sample sample;
 			Pattern pattern;
 		//	uint16 volume;
 		//	bool loopFlag;
@@ -128,7 +145,7 @@
 
 		//functions used in playback (in order by relationship)
 		void playSong(uint8 songNumber);
-		void updateTrackstep( );
+		void updateTrackstep();
 		void updatePattern(uint8 trackNumber);
 		void updateNote(uint8 trackNumber);
 		void doMacros(uint8 trackNumber);


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