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

nolange at users.sourceforge.net nolange at users.sourceforge.net
Mon Jul 6 20:51:22 CEST 2009


Revision: 42189
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42189&view=rev
Author:   nolange
Date:     2009-07-06 18:51:22 +0000 (Mon, 06 Jul 2009)

Log Message:
-----------
fix identation and replaced the "goto-workaround" with something simpler

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

Modified: scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp	2009-07-06 18:49:51 UTC (rev 42188)
+++ scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp	2009-07-06 18:51:22 UTC (rev 42189)
@@ -35,22 +35,22 @@
 
 MaxTrax::MaxTrax(int rate, bool stereo)
 	: Paula(stereo, rate, rate/50), _playerCtx(), _voiceCtx(), _patch(), _channelCtx(), _scores(), _numScores(), _microtonal() {
-		_playerCtx.maxScoreNum = 128;
-		_playerCtx.vBlankFreq = 50;
-		_playerCtx.frameUnit = (uint16)((1000 * (1<<8)) /  _playerCtx.vBlankFreq);
-		_playerCtx.scoreIndex = -1;
-		// glob_CurrentScore = _scoreptr;
-		_playerCtx.volume = 0x64;
+	_playerCtx.maxScoreNum = 128;
+	_playerCtx.vBlankFreq = 50;
+	_playerCtx.frameUnit = (uint16)((1000 * (1<<8)) /  _playerCtx.vBlankFreq);
+	_playerCtx.scoreIndex = -1;
+	// glob_CurrentScore = _scoreptr;
+	_playerCtx.volume = 0x64;
 
-		_playerCtx.tempoTime = 0;
+	_playerCtx.tempoTime = 0;
 
-		uint32 uinqueId = 0;
-		byte flags = 0;
+	uint32 uinqueId = 0;
+	byte flags = 0;
 
-		uint32 colorClock = kPalSystemClock / 2;
+	uint32 colorClock = kPalSystemClock / 2;
 
-		// init extraChannel
-		// extraChannel. chan_Number = 16, chan_Flags = chan_VoicesActive = 0
+	// init extraChannel
+	// extraChannel. chan_Number = 16, chan_Flags = chan_VoicesActive = 0
 }
 
 MaxTrax::~MaxTrax() {
@@ -200,8 +200,6 @@
 }
 
 int8 MaxTrax::noteOn(ChannelContext &channel, const byte note, uint16 volume, uint16 pri) {
-	bool processNote = true;
-
 	if (channel.microtonal >= 0)
 		_microtonal[note % 127] = channel.microtonal;
 	if (!volume)
@@ -226,7 +224,9 @@
 			voice.flags |= VoiceContext::kFlagPortamento;
 			voice.endNote = channel.lastNote = note;
 			voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
-			processNote = false;
+			_playerCtx.addedNote = true;
+			_playerCtx.lastVoice = voiceNum;
+			return voiceNum;
 		}
 	} else {
 		// TODO:
@@ -234,74 +234,72 @@
 		// return if no channel found
 		voiceNum = (channel.flags & ChannelContext::kFlagRightChannel) != 0 ? 0 : 1;
 	}
-	if (processNote) {
-		assert(voiceNum >= 0 && voiceNum < ARRAYSIZE(_voiceCtx));
+	assert(voiceNum >= 0 && voiceNum < ARRAYSIZE(_voiceCtx));
 
-		VoiceContext &voice = _voiceCtx[voiceNum];
-		voice.flags = 0;
-		if (voice.channel) {
-			killVoice(voiceNum);
-			voice.flags |= VoiceContext::kFlagStolen;
-		}
-		voice.channel = &channel;
-		voice.patch = &patch;
-		voice.baseNote = note;
+	VoiceContext &voice = _voiceCtx[voiceNum];
+	voice.flags = 0;
+	if (voice.channel) {
+		killVoice(voiceNum);
+		voice.flags |= VoiceContext::kFlagStolen;
+	}
+	voice.channel = &channel;
+	voice.patch = &patch;
+	voice.baseNote = note;
 
-		// calc note period
-		voice.priority = (byte)pri;
-		voice.status = VoiceContext::kStatusStart;
+	// calc note period
+	voice.priority = (byte)pri;
+	voice.status = VoiceContext::kStatusStart;
 
-		voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
+	voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
 
-		// ifeq HAS_FULLCHANVOL macro
-		if (channel.volume < 128)
-			voice.noteVolume = (voice.noteVolume * channel.volume) >> 7;
+	// ifeq HAS_FULLCHANVOL macro
+	if (channel.volume < 128)
+		voice.noteVolume = (voice.noteVolume * channel.volume) >> 7;
 
-		voice.baseVolume = 0;
-		voice.lastTicks = 0;
+	voice.baseVolume = 0;
+	voice.lastTicks = 0;
 
-		uint16 period = voice.lastPeriod;
-		if (!period)
-			period = 1000;
+	uint16 period = voice.lastPeriod;
+	if (!period)
+		period = 1000;
 
-		int useOctave = 0;
-		// get samplestart for the given octave
-		const int8 *samplePtr = patch.samplePtr + (patch.sampleTotalLen << useOctave) - patch.sampleTotalLen;
-		if (patch.sampleAttackLen) {
-			Paula::setChannelSampleStart(voiceNum, samplePtr);
-			Paula::setChannelSampleLen(voiceNum, patch.sampleAttackLen << useOctave);
+	int useOctave = 0;
+	// get samplestart for the given octave
+	const int8 *samplePtr = patch.samplePtr + (patch.sampleTotalLen << useOctave) - patch.sampleTotalLen;
+	if (patch.sampleAttackLen) {
+		Paula::setChannelSampleStart(voiceNum, samplePtr);
+		Paula::setChannelSampleLen(voiceNum, patch.sampleAttackLen << useOctave);
+		Paula::setChannelPeriod(voiceNum, period);
+		Paula::setChannelVolume(voiceNum, 0);
+
+		Paula::enableChannel(voiceNum);
+		// wait  for dma-clear
+	}
+
+	if (patch.sampleTotalLen > patch.sampleAttackLen) {
+		Paula::setChannelSampleStart(voiceNum, samplePtr + patch.sampleAttackLen);
+		Paula::setChannelSampleLen(voiceNum, (patch.sampleTotalLen - patch.sampleAttackLen) << useOctave);
+		if (!patch.sampleAttackLen) {
+			// need to enable channel
 			Paula::setChannelPeriod(voiceNum, period);
 			Paula::setChannelVolume(voiceNum, 0);
 
 			Paula::enableChannel(voiceNum);
-			// wait  for dma-clear
 		}
+		// another pointless wait for DMA-Clear???
+	}
 
-		if (patch.sampleTotalLen > patch.sampleAttackLen) {
-			Paula::setChannelSampleStart(voiceNum, samplePtr + patch.sampleAttackLen);
-			Paula::setChannelSampleLen(voiceNum, (patch.sampleTotalLen - patch.sampleAttackLen) << useOctave);
-			if (!patch.sampleAttackLen) {
-				// need to enable channel
-				Paula::setChannelPeriod(voiceNum, period);
-				Paula::setChannelVolume(voiceNum, 0);
-
-				Paula::enableChannel(voiceNum);
-			}
-			// another pointless wait for DMA-Clear???
+	channel.voicesActive++;
+	if (&channel < &_channelCtx[kNumChannels]) {
+		const byte flagsSet = ChannelContext::kFlagMono | ChannelContext::kFlagPortamento;
+		if ((channel.flags & flagsSet) == flagsSet && channel.lastNote < 0x80 && channel.lastNote != voice.baseNote) {
+			voice.portaTicks = 0;
+			voice.endNote = voice.baseNote;
+			voice.baseNote = channel.lastNote;
+			voice.flags |= VoiceContext::kFlagPortamento;
 		}
-
-		channel.voicesActive++;
-		if (&channel < &_channelCtx[kNumChannels]) {
-			const byte flagsSet = ChannelContext::kFlagMono | ChannelContext::kFlagPortamento;
-			if ((channel.flags & flagsSet) == flagsSet && channel.lastNote < 0x80 && channel.lastNote != voice.baseNote) {
-				voice.portaTicks = 0;
-				voice.endNote = voice.baseNote;
-				voice.baseNote = channel.lastNote;
-				voice.flags |= VoiceContext::kFlagPortamento;
-			}
-			if ((channel.flags & ChannelContext::kFlagPortamento) != 0)
-				channel.lastNote = note;
-		}
+		if ((channel.flags & ChannelContext::kFlagPortamento) != 0)
+			channel.lastNote = note;
 	}
 	_playerCtx.addedNote = true;
 	_playerCtx.lastVoice = voiceNum;


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