[Scummvm-cvs-logs] SF.net SVN: scummvm:[48604] scummvm/trunk/sound/softsynth/opl

salty-horse at users.sourceforge.net salty-horse at users.sourceforge.net
Fri Apr 9 21:25:05 CEST 2010


Revision: 48604
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48604&view=rev
Author:   salty-horse
Date:     2010-04-09 19:25:05 +0000 (Fri, 09 Apr 2010)

Log Message:
-----------
Add missing cases to switch statements, remove whitespace

Modified Paths:
--------------
    scummvm/trunk/sound/softsynth/opl/dbopl.cpp
    scummvm/trunk/sound/softsynth/opl/dbopl.h

Modified: scummvm/trunk/sound/softsynth/opl/dbopl.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/opl/dbopl.cpp	2010-04-09 15:47:49 UTC (rev 48603)
+++ scummvm/trunk/sound/softsynth/opl/dbopl.cpp	2010-04-09 19:25:05 UTC (rev 48604)
@@ -103,8 +103,8 @@
 //How much to substract from the base value for the final attenuation
 static const Bit8u KslCreateTable[16] = {
 	//0 will always be be lower than 7 * 8
-	64, 32, 24, 19, 
-	16, 12, 11, 10, 
+	64, 32, 24, 19,
+	16, 12, 11, 10,
 	 8,  6,  5,  4,
 	 3,  2,  1,  0,
 };
@@ -128,7 +128,7 @@
 	4,  5,  6,  7,
 	8, 10, 12, 14,
 	16, 20, 24, 28,
-	32, 
+	32,
 };
 
 #if ( DBOPL_WAVE == WAVE_HANDLER ) || ( DBOPL_WAVE == WAVE_TABLELOG )
@@ -184,9 +184,9 @@
 //The lower bits are the shift of the operator vibrato value
 //The highest bit is right shifted to generate -1 or 0 for negation
 //So taking the highest input value of 7 this gives 3, 7, 3, 0, -3, -7, -3, 0
-static const Bit8s VibratoTable[ 8 ] = {	
-	1 - 0x00, 0 - 0x00, 1 - 0x00, 30 - 0x00, 
-	1 - 0x80, 0 - 0x80, 1 - 0x80, 30 - 0x80 
+static const Bit8s VibratoTable[ 8 ] = {
+	1 - 0x00, 0 - 0x00, 1 - 0x00, 30 - 0x00,
+	1 - 0x80, 0 - 0x80, 1 - 0x80, 30 - 0x80
 };
 
 //Shift strength for the ksl value determined by ksl strength
@@ -315,13 +315,13 @@
 		rateZero &= ~(1 << RELEASE);
 		if ( !(reg20 & MASK_SUSTAIN ) ) {
 			rateZero &= ~( 1 << SUSTAIN );
-		}	
+		}
 	} else {
 		rateZero |= (1 << RELEASE);
 		releaseAdd = 0;
 		if ( !(reg20 & MASK_SUSTAIN ) ) {
 			rateZero |= ( 1 << SUSTAIN );
-		}	
+		}
 	}
 }
 
@@ -417,7 +417,7 @@
 			return vol;
 		}
 		//In sustain phase, but not sustaining, do regular release
-	case RELEASE: 
+	case RELEASE:
 		vol += RateForward( releaseAdd );;
 		if ( GCC_UNLIKELY(vol >= ENV_MAX) ) {
 			volume = ENV_MAX;
@@ -444,13 +444,13 @@
 
 
 INLINE Bitu Operator::ForwardWave() {
-	waveIndex += waveCurrent;	
+	waveIndex += waveCurrent;
 	return waveIndex >> WAVE_SH;
 }
 
 void Operator::Write20( const Chip* chip, Bit8u val ) {
 	Bit8u change = (reg20 ^ val );
-	if ( !change ) 
+	if ( !change )
 		return;
 	reg20 = val;
 	//Shift the tremolo bit over the entire register, saved a branch, YES!
@@ -474,7 +474,7 @@
 }
 
 void Operator::Write40( const Chip* /*chip*/, Bit8u val ) {
-	if (!(reg40 ^ val )) 
+	if (!(reg40 ^ val ))
 		return;
 	reg40 = val;
 	UpdateAttenuation( );
@@ -493,7 +493,7 @@
 
 void Operator::Write80( const Chip* chip, Bit8u val ) {
 	Bit8u change = (reg80 ^ val );
-	if ( !change ) 
+	if ( !change )
 		return;
 	reg80 = val;
 	Bit8u sustain = val >> 4;
@@ -506,7 +506,7 @@
 }
 
 void Operator::WriteE0( const Chip* chip, Bit8u val ) {
-	if ( !(regE0 ^ val) ) 
+	if ( !(regE0 ^ val) )
 		return;
 	//in opl3 mode you can always selet 7 waveforms regardless of waveformselect
 	Bit8u waveForm = val & ( ( 0x3 & chip->waveFormMask ) | (0x7 & chip->opl3Active ) );
@@ -541,7 +541,7 @@
 		//Sign extend over the shift value
 		Bit32s neg = chip->vibratoSign;
 		//Negate the add with -1 or 0
-		add = ( add ^ neg ) - neg; 
+		add = ( add ^ neg ) - neg;
 		waveCurrent += add;
 	}
 }
@@ -769,7 +769,7 @@
 		maskLeft = ( val & 0x10 ) ? -1 : 0;
 		maskRight = ( val & 0x20 ) ? -1 : 0;
 	//opl2 active
-	} else { 
+	} else {
 		//Disable updating percussion channels
 		if ( (fourMask & 0x40) && ( chip->regBD & 0x20 ) ) {
 
@@ -795,7 +795,7 @@
 	//BassDrum
 	Bit32s mod = (Bit32u)((old[0] + old[1])) >> feedback;
 	old[0] = old[1];
-	old[1] = Op(0)->GetSample( mod ); 
+	old[1] = Op(0)->GetSample( mod );
 
 	//When bassdrum is in AM mode first operator is ignoed
 	if ( chan->regC0 & 1 ) {
@@ -803,7 +803,7 @@
 	} else {
 		mod = old[0];
 	}
-	Bit32s sample = Op(1)->GetSample( mod ); 
+	Bit32s sample = Op(1)->GetSample( mod );
 
 
 	//Precalculate stuff used by other outputs
@@ -893,6 +893,16 @@
 		// thus we leave this blank.
 		// TODO: Consider checking this.
 		break;
+	case sm4Start:
+		// This case was not handled in the DOSBox code either
+		// thus we leave this blank.
+		// TODO: Consider checking this.
+		break;
+	case sm6Start:
+		// This case was not handled in the DOSBox code either
+		// thus we leave this blank.
+		// TODO: Consider checking this.
+		break;
 	}
 	//Init the operators with the the current vibrato and tremolo values
 	Op( 0 )->Prepare( chip );
@@ -926,12 +936,12 @@
 		} else if ( mode == sm2FM || mode == sm3FM ) {
 			sample = Op(1)->GetSample( out0 );
 		} else if ( mode == sm3FMFM ) {
-			Bits next = Op(1)->GetSample( out0 ); 
+			Bits next = Op(1)->GetSample( out0 );
 			next = Op(2)->GetSample( next );
 			sample = Op(3)->GetSample( next );
 		} else if ( mode == sm3AMFM ) {
 			sample = out0;
-			Bits next = Op(1)->GetSample( 0 ); 
+			Bits next = Op(1)->GetSample( 0 );
 			next = Op(2)->GetSample( next );
 			sample += Op(3)->GetSample( next );
 		} else if ( mode == sm3FMAM ) {
@@ -940,7 +950,7 @@
 			sample += Op(3)->GetSample( next );
 		} else if ( mode == sm3AMAM ) {
 			sample = out0;
-			Bits next = Op(1)->GetSample( 0 ); 
+			Bits next = Op(1)->GetSample( 0 );
 			sample += Op(2)->GetSample( next );
 			sample += Op(3)->GetSample( 0 );
 		}
@@ -968,6 +978,16 @@
 			// thus we leave this blank.
 			// TODO: Consider checking this.
 			break;
+		case sm4Start:
+			// This case was not handled in the DOSBox code either
+			// thus we leave this blank.
+			// TODO: Consider checking this.
+			break;
+		case sm6Start:
+			// This case was not handled in the DOSBox code either
+			// thus we leave this blank.
+			// TODO: Consider checking this.
+			break;
 		}
 	}
 	switch( mode ) {
@@ -984,6 +1004,16 @@
 	case sm2Percussion:
 	case sm3Percussion:
 		return( this + 3 );
+	case sm4Start:
+		// This case was not handled in the DOSBox code either
+		// thus we leave this blank.
+		// TODO: Consider checking this.
+		break;
+	case sm6Start:
+		// This case was not handled in the DOSBox code either
+		// thus we leave this blank.
+		// TODO: Consider checking this.
+		break;
 	}
 	return 0;
 }
@@ -1015,7 +1045,7 @@
 INLINE Bit32u Chip::ForwardLFO( Bit32u samples ) {
 	//Current vibrato value, runs 4x slower than tremolo
 	vibratoSign = ( VibratoTable[ vibratoIndex >> 2] ) >> 7;
-	vibratoShift = ( VibratoTable[ vibratoIndex >> 2] & 7) + vibratoStrength; 
+	vibratoShift = ( VibratoTable[ vibratoIndex >> 2] & 7) + vibratoStrength;
 	tremoloValue = TremoloTable[ tremoloIndex ] >> tremoloStrength;
 
 	//Check hom many samples there can be done before the value changes
@@ -1051,9 +1081,9 @@
 		//Drum was just enabled, make sure channel 6 has the right synth
 		if ( change & 0x20 ) {
 			if ( opl3Active ) {
-				chan[6].synthHandler = &Channel::BlockTemplate< sm3Percussion >; 
+				chan[6].synthHandler = &Channel::BlockTemplate< sm3Percussion >;
 			} else {
-				chan[6].synthHandler = &Channel::BlockTemplate< sm2Percussion >; 
+				chan[6].synthHandler = &Channel::BlockTemplate< sm2Percussion >;
 			}
 		}
 		//Bass Drum
@@ -1121,7 +1151,7 @@
 	switch ( (reg & 0xf0) >> 4 ) {
 	case 0x00 >> 4:
 		if ( reg == 0x01 ) {
-			waveFormMask = ( val & 0x20 ) ? 0x7 : 0x0; 
+			waveFormMask = ( val & 0x20 ) ? 0x7 : 0x0;
 		} else if ( reg == 0x104 ) {
 			//Only detect changes in lowest 6 bits
 			if ( !((reg104 ^ val) & 0x3f) )
@@ -1187,7 +1217,7 @@
 	case 2:
 		if ( opl3Active || (val == 0x05) )
 			return 0x100 | val;
-		else 
+		else
 			return val;
 	}
 	return 0;
@@ -1261,7 +1291,7 @@
 		EnvelopeSelect( i, index, shift );
 		//Original amount of samples the attack would take
 		Bit32s original = (Bit32u)( (AttackSamplesTable[ index ] << shift) / scale);
-		 
+
 		Bit32s guessAdd = (Bit32u)( scale * (EnvelopeIncreaseTable[ index ] << ( RATE_SH - shift - 3 )));
 		Bit32s bestAdd = guessAdd;
 		Bit32u bestDiff = 1 << 30;
@@ -1273,7 +1303,7 @@
 				count += guessAdd;
 				Bit32s change = count >> RATE_SH;
 				count &= RATE_MASK;
-				if ( GCC_UNLIKELY(change) ) { // less than 1 % 
+				if ( GCC_UNLIKELY(change) ) { // less than 1 %
 					volume += ( ~volume * change ) >> 3;
 				}
 				samples++;
@@ -1395,7 +1425,7 @@
 	for ( int i = 0; i < 256; i++ ) {
 		WaveTable[ 0x700 + i ] = i * 8;
 		WaveTable[ 0x6ff - i ] = ((Bit16s)0x8000) | i * 8;
-	} 
+	}
 #endif
 
 	//	|    |//\\|____|WAV7|//__|/\  |____|/\/\|
@@ -1417,7 +1447,7 @@
 		WaveTable[ 0xb00 + i ] = WaveTable[ 0x000 + i * 2 ];
 		WaveTable[ 0xe00 + i ] = WaveTable[ 0x200 + i * 2 ];
 		WaveTable[ 0xf00 + i ] = WaveTable[ 0x200 + i * 2 ];
-	} 
+	}
 #endif
 
 	//Create the ksl table

Modified: scummvm/trunk/sound/softsynth/opl/dbopl.h
===================================================================
--- scummvm/trunk/sound/softsynth/opl/dbopl.h	2010-04-09 15:47:49 UTC (rev 48603)
+++ scummvm/trunk/sound/softsynth/opl/dbopl.h	2010-04-09 19:25:05 UTC (rev 48604)
@@ -112,7 +112,7 @@
 	VolumeHandler volHandler;
 
 #if (DBOPL_WAVE == WAVE_HANDLER)
-	WaveHandler waveHandler;	//Routine that generate a wave 
+	WaveHandler waveHandler;	//Routine that generate a wave
 #else
 	Bit16s* waveBase;
 	Bit32u waveMask;
@@ -129,7 +129,7 @@
 	Bit32s totalLevel;			//totalLevel is added to every generated volume
 	Bit32u currentLevel;		//totalLevel + tremolo
 	Bit32s volume;				//The currently active volume
-	
+
 	Bit32u attackAdd;			//Timers for the different states of the envelope
 	Bit32u decayAdd;
 	Bit32u releaseAdd;
@@ -222,8 +222,8 @@
 	//This is used as the base counter for vibrato and tremolo
 	Bit32u lfoCounter;
 	Bit32u lfoAdd;
-	
 
+
 	Bit32u noiseCounter;
 	Bit32u noiseAdd;
 	Bit32u noiseValue;


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