[Scummvm-cvs-logs] SF.net SVN: scummvm: [26820] scummvm/trunk/engines/cine

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sun May 13 04:11:38 CEST 2007


Revision: 26820
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26820&view=rev
Author:   cyx
Date:     2007-05-12 19:11:38 -0700 (Sat, 12 May 2007)

Log Message:
-----------
minor fixes to the adlib sound code, this should help bug #1599270

Modified Paths:
--------------
    scummvm/trunk/engines/cine/sfx_player.cpp
    scummvm/trunk/engines/cine/sound_driver.cpp

Modified: scummvm/trunk/engines/cine/sfx_player.cpp
===================================================================
--- scummvm/trunk/engines/cine/sfx_player.cpp	2007-05-13 02:08:53 UTC (rev 26819)
+++ scummvm/trunk/engines/cine/sfx_player.cpp	2007-05-13 02:11:38 UTC (rev 26820)
@@ -111,13 +111,15 @@
 }
 
 void SfxPlayer::stop() {
-	_fadeOutCounter = 0;
-	_playing = false;
-	for (int i = 0; i < NUM_CHANNELS; ++i) {
-		_driver->stopChannel(i);
+	if (_playing || _fadeOutCounter != 0) {
+		_fadeOutCounter = 0;
+		_playing = false;
+		for (int i = 0; i < NUM_CHANNELS; ++i) {
+			_driver->stopChannel(i);
+		}
+		_driver->stopSound();
+		unload();
 	}
-	_driver->stopSound();
-	unload();
 }
 
 void SfxPlayer::fadeOut() {

Modified: scummvm/trunk/engines/cine/sound_driver.cpp
===================================================================
--- scummvm/trunk/engines/cine/sound_driver.cpp	2007-05-13 02:08:53 UTC (rev 26819)
+++ scummvm/trunk/engines/cine/sound_driver.cpp	2007-05-13 02:11:38 UTC (rev 26820)
@@ -87,18 +87,16 @@
 void AdlibSoundDriver::stopChannel(int channel) {
 	assert(channel < 4);
 	AdlibSoundInstrument *ins = &_instrumentsTable[channel];
-	if (ins) {
-		if (ins->mode != 0 && ins->channel == 6) {
-			channel = 6;
-		}
-		if (ins->mode == 0 || ins->channel == 6) {
-			OPLWriteReg(_opl, 0xB0 | channel, 0);
-		}
-		if (ins->mode != 0) {
-			_vibrato &= (1 << (10 - ins->channel)) ^ 0xFF;
-			OPLWriteReg(_opl, 0xBD, _vibrato);
-		}
+	if (ins->mode != 0 && ins->channel == 6) {
+		channel = 6;
 	}
+	if (ins->mode == 0 || channel == 6) {
+		OPLWriteReg(_opl, 0xB0 | channel, 0);
+	}
+	if (ins->mode != 0) {
+		_vibrato &= ~(1 << (10 - ins->channel));
+		OPLWriteReg(_opl, 0xBD, _vibrato);
+	}
 }
 
 void AdlibSoundDriver::stopSound() {
@@ -295,16 +293,17 @@
 		channel = 6;
 	}
 	if (ins->mode == 0 || channel == 6) {
-		int freq = _freqTable[0];
+		uint16 note = 12;
+		int freq = _freqTable[note % 12];
 		OPLWriteReg(_opl, 0xA0 | channel, freq);
-		freq = 4 | ((freq & 0x300) >> 8);
+		freq = ((note / 12) << 2) | ((freq & 0x300) >> 8);
 		if (ins->mode == 0) {
 			freq |= 0x20;
 		}
 		OPLWriteReg(_opl, 0xB0 | channel, freq);
 	}
 	if (ins->mode != 0) {
-		_vibrato = 1 << (10 - ins->channel);
+		_vibrato |= 1 << (10 - ins->channel);
 		OPLWriteReg(_opl, 0xBD, _vibrato);
 	}
 }
@@ -351,7 +350,7 @@
 		}
 		OPLWriteReg(_opl, 0xB0 | channel, freq);
 		if (ins->mode != 0) {
-			_vibrato = 1 << (10 - channel);
+			_vibrato |= 1 << (10 - channel);
 			OPLWriteReg(_opl, 0xBD, _vibrato);
 		}
 	}
@@ -366,7 +365,7 @@
 		OPLWriteReg(_opl, 0xB0 | channel, 0);
 	}
 	if (ins->mode != 0) {
-		_vibrato = (1 << (10 - ins->channel)) ^ 0xFF;
+		_vibrato &= ~(1 << (10 - ins->channel));
 		OPLWriteReg(_opl, 0xBD, _vibrato);
 	}
 	if (ins->mode != 0) {
@@ -389,7 +388,7 @@
 	}
 	OPLWriteReg(_opl, 0xB0 | channel, freq);
 	if (ins->mode != 0) {
-		_vibrato = 1 << (10 - channel);
+		_vibrato |= 1 << (10 - channel);
 		OPLWriteReg(_opl, 0xBD, _vibrato);
 	}
 }


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