[Scummvm-cvs-logs] SF.net SVN: scummvm:[43047] scummvm/branches/gsoc2009-mods/sound/mods

nolange at users.sourceforge.net nolange at users.sourceforge.net
Tue Aug 4 19:12:19 CEST 2009


Revision: 43047
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43047&view=rev
Author:   nolange
Date:     2009-08-04 17:12:19 +0000 (Tue, 04 Aug 2009)

Log Message:
-----------
moved helper functions from the header file into the cpp file

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

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-08-04 17:03:35 UTC (rev 43046)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-08-04 17:12:19 UTC (rev 43047)
@@ -730,6 +730,90 @@
 	}
 }
 
+void Tfmx::initMacroProgramm(ChannelContext &channel) {
+	channel.macroStep = 0;
+	channel.macroWait = 0;
+	channel.macroRun = true;
+	channel.macroSfxRun = 0;
+	channel.macroLoopCount = 0xFF;
+	channel.dmaIntCount = 0;
+	channel.deferWait = false;
+
+	channel.macroReturnOffset = 0;
+	channel.macroReturnStep = 0;
+}
+
+void Tfmx::clearEffects(ChannelContext &channel) {
+	channel.addBeginLength = 0;
+	channel.envSkip = 0;
+	channel.vibLength = 0;
+	channel.portaDelta = 0;
+}
+
+void Tfmx::haltMacroProgramm(ChannelContext &channel) {
+	channel.macroRun = false;
+	channel.dmaIntCount = 0;
+}
+
+void Tfmx::unlockMacroChannel(ChannelContext &channel) {
+	channel.customMacro = 0;
+	channel.customMacroPrio = false;
+	channel.sfxLocked = false;
+	channel.sfxLockTime = -1;
+}
+
+void Tfmx::initPattern(PatternContext &pattern, uint8 cmd, int8 expose, uint32 offset) {
+	pattern.command = cmd;
+	pattern.offset = offset;
+	pattern.expose = expose;
+	pattern.step = 0;
+	pattern.wait = 0;
+	pattern.loopCount = 0xFF;
+
+	pattern.savedOffset = 0;
+	pattern.savedStep = 0;
+}
+
+void Tfmx::stopSongImpl(bool stopAudio) {
+	 _playerCtx.song = -1;
+	for (int i = 0; i < kNumChannels; ++i) {
+		_patternCtx[i].command = 0xFF;
+		_patternCtx[i].expose = 0;
+	}
+	if (stopAudio) {
+		stopPaula();
+		for (int i = 0; i < kNumVoices; ++i) {
+			clearEffects(_channelCtx[i]);
+			unlockMacroChannel(_channelCtx[i]);
+			haltMacroProgramm(_channelCtx[i]);
+			_channelCtx[i].note = 0;
+			_channelCtx[i].volume = 0;
+			Paula::disableChannel(i);
+		}
+	}
+}
+
+void Tfmx::setNoteMacro(ChannelContext &channel, uint note, int fineTune) {
+	const uint16 noteInt = noteIntervalls[note & 0x3F];
+	const uint16 finetune = (uint16)(fineTune + channel.fineTune + (1 << 8));
+	channel.refPeriod = ((uint32)noteInt * finetune >> 8);
+	if (!channel.portaDelta)
+		channel.period = channel.refPeriod;
+}
+
+void Tfmx::initFadeCommand(const uint8 fadeTempo, const int8 endVol) {
+	_playerCtx.fadeCount = _playerCtx.fadeSkip = fadeTempo;
+	_playerCtx.fadeEndVolume = endVol;
+
+	if (fadeTempo) {
+		const int diff = _playerCtx.fadeEndVolume - _playerCtx.volume;
+		_playerCtx.fadeDelta = (diff != 0) ? ((diff > 0) ? 1 : -1) : 0;
+	} else {
+		_playerCtx.volume = endVol;
+		_playerCtx.fadeDelta = 0;
+	}
+}
+
 void Tfmx::setModuleData(Tfmx &otherPlayer) {
 	setModuleData(otherPlayer._resource, otherPlayer._resourceSample.sampleData, otherPlayer._resourceSample.sampleLen, false);
 }
@@ -765,7 +849,8 @@
 
 void Tfmx::setModuleData(const MdatResource *resource, const int8 *sampleData, uint32 sampleLen, bool autoDelete) {
 	Common::StackLock lock(_mutex);
-	// TODO: stop sound and deallocate previous resources
+	stopSongImpl(true);
+	freeResourceDataImpl();
 	_resource = resource;
 	_resourceSample.sampleData = sampleData;
 	_resourceSample.sampleLen = sampleData ? sampleLen : 0;

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h	2009-08-04 17:03:35 UTC (rev 43046)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h	2009-08-04 17:12:19 UTC (rev 43047)
@@ -256,90 +256,14 @@
 		return sample;
 	}
 
-	static void initMacroProgramm(ChannelContext &channel) {
-		channel.macroStep = 0;
-		channel.macroWait = 0;
-		channel.macroRun = true;
-		channel.macroSfxRun = 0;
-		channel.macroLoopCount = 0xFF;
-		channel.dmaIntCount = 0;
-		channel.deferWait = false;
-
-		channel.macroReturnOffset = 0;
-		channel.macroReturnStep = 0;
-	}
-
-	static void clearEffects(ChannelContext &channel) {
-		channel.addBeginLength = 0;
-		channel.envSkip = 0;
-		channel.vibLength = 0;
-		channel.portaDelta = 0;
-	}
-
-	static void haltMacroProgramm(ChannelContext &channel) {
-		channel.macroRun = false;
-		channel.dmaIntCount = 0;
-	}
-
-	static void unlockMacroChannel(ChannelContext &channel) {
-		channel.customMacro = 0;
-		channel.customMacroPrio = false;
-		channel.sfxLocked = false;
-		channel.sfxLockTime = -1;
-	}
-
-	static void initPattern(PatternContext &pattern, uint8 cmd, int8 expose, uint32 offset) {
-		pattern.command = cmd;
-		pattern.offset = offset;
-		pattern.expose = expose;
-		pattern.step = 0;
-		pattern.wait = 0;
-		pattern.loopCount = 0xFF;
-
-		pattern.savedOffset = 0;
-		pattern.savedStep = 0;
-	}
-
-	void stopSongImpl(bool stopAudio = true) {
-		 _playerCtx.song = -1;
-		for (int i = 0; i < kNumChannels; ++i) {
-			_patternCtx[i].command = 0xFF;
-			_patternCtx[i].expose = 0;
-		}
-		if (stopAudio) {
-			stopPaula();
-			for (int i = 0; i < kNumVoices; ++i) {
-				clearEffects(_channelCtx[i]);
-				unlockMacroChannel(_channelCtx[i]);
-				haltMacroProgramm(_channelCtx[i]);
-				_channelCtx[i].note = 0;
-				_channelCtx[i].volume = 0;
-				Paula::disableChannel(i);
-			}
-		}
-	}
-
-	static void setNoteMacro(ChannelContext &channel, uint note, int fineTune) {
-		const uint16 noteInt = noteIntervalls[note & 0x3F];
-		const uint16 finetune = (uint16)(fineTune + channel.fineTune + (1 << 8));
-		channel.refPeriod = ((uint32)noteInt * finetune >> 8);
-		if (!channel.portaDelta)
-			channel.period = channel.refPeriod;
-	}
-
-	void initFadeCommand(const uint8 fadeTempo, const int8 endVol) {
-		_playerCtx.fadeCount = _playerCtx.fadeSkip = fadeTempo;
-		_playerCtx.fadeEndVolume = endVol;
-
-		if (fadeTempo) {
-			const int diff = _playerCtx.fadeEndVolume - _playerCtx.volume;
-			_playerCtx.fadeDelta = (diff != 0) ? ((diff > 0) ? 1 : -1) : 0;
-		} else {
-			_playerCtx.volume = endVol;
-			_playerCtx.fadeDelta = 0;
-		}
-	}
-
+	static inline void initMacroProgramm(ChannelContext &channel);
+	static inline void clearEffects(ChannelContext &channel);
+	static inline void haltMacroProgramm(ChannelContext &channel);
+	static inline void unlockMacroChannel(ChannelContext &channel);
+	static inline void initPattern(PatternContext &pattern, uint8 cmd, int8 expose, uint32 offset);
+	void stopSongImpl(bool stopAudio = true);
+	static void inline setNoteMacro(ChannelContext &channel, uint note, int fineTune);
+	void initFadeCommand(const uint8 fadeTempo, const int8 endVol);
 	void setModuleData(const MdatResource *resource, const int8 *sampleData, uint32 sampleLen, bool autoDelete = true);
 	static const MdatResource *loadMdatFile(Common::SeekableReadStream &musicData);
 	static const int8 *loadSampleFile(uint32 &sampleLen, Common::SeekableReadStream &sampleStream);	


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