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

nolange at users.sourceforge.net nolange at users.sourceforge.net
Fri Jun 19 22:41:33 CEST 2009


Revision: 41686
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41686&view=rev
Author:   nolange
Date:     2009-06-19 20:41:32 +0000 (Fri, 19 Jun 2009)

Log Message:
-----------
more cleanups, got rid of pendingTrackstep variable

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

Modified: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp	2009-06-19 20:17:53 UTC (rev 41685)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp	2009-06-19 20:41:32 UTC (rev 41686)
@@ -75,7 +75,6 @@
 	debug("player_v4a: setMusicVolume %i", vol);
 }
 
-
 void Player_V4A::stopAllSounds() {
 	if (_musicId)
 		stopSound(_musicId);
@@ -133,13 +132,11 @@
 		_tfmxPlay->doSong(index);
 		_musicId = nr;
 
-
 		if (!_mixer->isSoundHandleActive(_musicHandle))
 			_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxPlay, -1, Audio::Mixer::kMaxChannelVolume, 0, false, false);
 	}
 }
 
-
 int Player_V4A::getMusicTimer() const {
 	if (_musicId) {
 		// TODO: The titlesong is running with ~70 ticks per second and the scale seems to be based on that. 

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-06-19 20:17:53 UTC (rev 41685)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-06-19 20:41:32 UTC (rev 41686)
@@ -90,10 +90,6 @@
 			channel.sfxLocked = (channel.customMacroPrio != 0);
 		}
 
-
-
-		// TODO: Sometimes a macro will be executed here
-
 		// apply timebased effects on Parameters 
 		effects(channel);
 
@@ -473,12 +469,7 @@
 }
 
 void Tfmx::advancePatterns() {
-doTrackstep:
-	if (_playerCtx.pendingTrackstep) {
-		while (trackStep())
-			;
-		_playerCtx.pendingTrackstep = false;
-	}
+startPatterns:
 	int runningPatterns = 0;
 
 	for (int i = 0; i < kNumChannels; ++i) {
@@ -486,9 +477,22 @@
 		if (pattCmd < 0x90) {	// execute Patternstep
 			++runningPatterns;
 			if (_patternCtx[i].wait == 0) {
+				bool pendingTrackstep = false;
 				// issue all Steps for this tick
-				while (patternStep(_patternCtx[i]))
+				while (patternStep(_patternCtx[i], pendingTrackstep))
 					;
+				if (pendingTrackstep) {
+					// we load the next Trackstep Command and then process all Channels again
+					// TODO Optionally disable looping
+					if (_trackCtx.posInd == _trackCtx.stopInd)
+						_trackCtx.posInd = _trackCtx.startInd;
+					else
+						++_trackCtx.posInd;
+					while (trackStep())
+						;
+					goto startPatterns;
+				}
+
 			} else 
 				--_patternCtx[i].wait;
 
@@ -496,16 +500,6 @@
 			_patternCtx[i].command = 0xFF;
 			stopChannel(_channelCtx[_patternCtx[i].expose % kNumVoices]);
 		} // else this pattern-Channel is stopped
-
-		if (_playerCtx.pendingTrackstep) {
-			// we load the next Trackstep Command and then process all Channels again
-			// TODO Optionally disable looping
-			if (_trackCtx.posInd == _trackCtx.stopInd)
-				_trackCtx.posInd = _trackCtx.startInd;
-			else
-				++_trackCtx.posInd;
-			goto doTrackstep;
-		}
 	}
 	if (_playerCtx.stopWithLastPattern && !runningPatterns) {
 		_playerCtx.enabled = 0;
@@ -526,7 +520,7 @@
 }
 
 
-FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern) {
+FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern, bool &pendingTrackstep) {
 	const byte *const patternPtr = (byte *)(_resource.getPatternPtr(pattern.offset) + pattern.step);
 	++pattern.step;
 
@@ -554,7 +548,7 @@
 		case 0: 	// End Pattern + Next Trackstep
 			pattern.command = 0xFF;
 			--pattern.step;
-			_playerCtx.pendingTrackstep = true;
+			pendingTrackstep = true;
 			return false;
 
 		case 1: 	// Loop Pattern. Parameters: Loopcount, PatternStep(W)
@@ -950,7 +944,6 @@
 
 	while (trackStep())
 		;
-	_playerCtx.pendingTrackstep = false;
 	startPaula();
 }
 
@@ -959,23 +952,20 @@
 	Common::StackLock lock(_mutex);
 
 	const byte *sfxEntry = _resource.getSfxPtr(sfxIndex);
-
 	if (sfxEntry[0] == 0xFB) {
 		// custompattern
 		const uint8 patCmd = sfxEntry[2];
 		const int8 patExp = (int8)sfxEntry[3];
 	} else {
 		// custommacro
-		// byte index = (_playerCtx.song >= 0) ? sfxEntry[2] : sfxEntry[4];
 		const byte channelNo = sfxEntry[2] % kNumVoices;
+		const byte index = (_playerCtx.song >= 0) ? sfxEntry[2] : sfxEntry[4];
 		const byte priority = sfxEntry[5] & 0x7F;
 
 		ChannelContext &channel = _channelCtx[channelNo];
-
 		const int16 sfxLocktime = channel.sfxLockTime;
-
 		if (priority >= channel.customMacroPrio || sfxLocktime < 0) {
-			if (sfxIndex != channel.customMacroIndex || sfxLocktime < 0 || (sfxEntry[5] < 0x80) ) {
+			if (sfxIndex != channel.customMacroIndex || sfxLocktime < 0 || (sfxEntry[5] < 0x80)) {
 				channel.customMacro = READ_UINT32(sfxEntry); // intentionally not "endian-correct"
 				channel.customMacroPrio = priority;
 				channel.customMacroIndex = (uint8)sfxIndex;

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h	2009-06-19 20:17:53 UTC (rev 41685)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h	2009-06-19 20:41:32 UTC (rev 41686)
@@ -205,8 +205,6 @@
 //		bool	end;
 		int8	song;	//!< >= 0 if Song is running (means process Patterns)
 
-		bool	pendingTrackstep;
-
 		uint16	patternCount;
 		uint16	patternSkip;	//!< skip that amount of CIA-Interrupts
 
@@ -261,7 +259,7 @@
 	void effects(ChannelContext &channel);
 	FORCEINLINE bool macroStep(ChannelContext &channel);
 	void advancePatterns();
-	FORCEINLINE bool patternStep(PatternContext &pattern);
+	FORCEINLINE bool patternStep(PatternContext &pattern, bool &pendingTrackstep);
 	bool trackStep();
 	void noteCommand(uint8 note, uint8 param1, uint8 param2, uint8 param3);
 };


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