[Scummvm-cvs-logs] SF.net SVN: scummvm:[40972] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri May 29 00:44:33 CEST 2009


Revision: 40972
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40972&view=rev
Author:   lordhoto
Date:     2009-05-28 22:44:33 +0000 (Thu, 28 May 2009)

Log Message:
-----------
Clean up PC Speaker output implementation. (Stripping out unused code)

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/sound_intern.h
    scummvm/trunk/engines/kyra/sound_pcspk.cpp

Modified: scummvm/trunk/engines/kyra/sound_intern.h
===================================================================
--- scummvm/trunk/engines/kyra/sound_intern.h	2009-05-28 22:42:18 UTC (rev 40971)
+++ scummvm/trunk/engines/kyra/sound_intern.h	2009-05-28 22:44:33 UTC (rev 40972)
@@ -301,14 +301,12 @@
 	int _rate;
 
 	struct Channel {
-		uint8 volume;
 		uint8 pitchBendLow, pitchBendHigh;
-		uint8 expression;
 		uint8 hold;
 		uint8 modulation;
 		uint8 voiceProtect;
 		uint8 noteCount;
-	} _channel[16];
+	} _channel[2];
 
 	void resetController(int channel);
 
@@ -316,8 +314,7 @@
 		bool enabled;
 		uint8 hardwareChannel;
 		uint8 midiChannel;
-		uint8 note1, note2;
-		uint8 velocity;
+		uint8 note;
 		bool processHold;
 		uint8 flags;
 		uint8 hardwareFlags;
@@ -326,7 +323,7 @@
 		uint16 precedence;
 	} _note[2];
 
-	void noteOn(int channel, int note, int velocity);
+	void noteOn(int channel, int note);
 	void noteOff(int channel, int note);
 
 	void turnNoteOn(int note);
@@ -342,7 +339,6 @@
 	uint8 _timerValue;
 	void onTimer();
 
-	static const uint8 _velocityTable[];
 	static const uint8 _noteTable1[];
 	static const uint8 _noteTable2[];
 };

Modified: scummvm/trunk/engines/kyra/sound_pcspk.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_pcspk.cpp	2009-05-28 22:42:18 UTC (rev 40971)
+++ scummvm/trunk/engines/kyra/sound_pcspk.cpp	2009-05-28 22:44:33 UTC (rev 40972)
@@ -64,8 +64,11 @@
 	uint8 param1 = (data >>  8) & 0xFF;
 	uint8 param2 = (data >> 16) & 0xFF;
 
-	uint8 flags = 0;
+	uint8 flags = 0x00;
 
+	if (channel > 1)
+		return;
+
 	switch (data & 0xF0) {
 	case 0x80:	// note off
 		noteOff(channel, param1);
@@ -76,7 +79,7 @@
 			return;
 
 		if (param2)
-			noteOn(channel, param1, param2);
+			noteOn(channel, param1);
 		else
 			noteOff(channel, param1);
 		return;
@@ -85,14 +88,8 @@
 		switch (param1) {
 		case 0x01:	// modulation
 			_channel[channel].modulation = param2;
-			flags = 0x00;
 			break;
 
-		case 0x07:	// volume
-			_channel[channel].volume = param2;
-			flags = 0x40;
-			break;
-
 		case 0x40:	// hold
 			_channel[channel].hold = param2;
 			if (param2 < 0x40)
@@ -107,17 +104,11 @@
 			_channel[channel].hold = 0;
 			resetController(channel);
 			_channel[channel].modulation = 0;
-			_channel[channel].expression = 0x7F;
 			_channel[channel].pitchBendLow = 0;
 			_channel[channel].pitchBendHigh = 0x40;
-			flags = 0x41;
+			flags = 0x01;
 			break;
 
-		case 0xB0:	// expression
-			_channel[channel].expression = param2;
-			flags = 0x40;
-			break;
-
 		default:
 			return;
 		}
@@ -144,11 +135,11 @@
 void MidiDriver_PCSpeaker::resetController(int channel) {
 	for (int i = 0; i < 2; ++i) {
 		if (_note[i].enabled && _note[i].midiChannel == channel && _note[i].processHold)
-			noteOff(channel, _note[i].note2);
+			noteOff(channel, _note[i].note);
 	}
 }
 
-void MidiDriver_PCSpeaker::noteOn(int channel, int note, int velocity) {
+void MidiDriver_PCSpeaker::noteOn(int channel, int note) {
 	int n = 0;
 
 	while (n < 2 && _note[n].enabled)
@@ -158,13 +149,12 @@
 		return;
 
 	_note[n].midiChannel = channel;
-	_note[n].note1 = _note[n].note2 = note;
-	_note[n].velocity = _velocityTable[((uint8)velocity) >> 3];
+	_note[n].note = note;
 	_note[n].enabled = true;
 	_note[n].processHold = false;
 	_note[n].hardwareFlags = 0x20;
 	_note[n].priority = 0x7FFF;
-	_note[n].flags = 0x41;
+	_note[n].flags = 0x01;
 
 	turnNoteOn(n);
 }
@@ -174,7 +164,7 @@
 		_note[note].hardwareChannel = 0;
 		++_channel[_note[note].midiChannel].noteCount;
 		_hardwareChannel[0] = _note[note].midiChannel;
-		_note[note].flags = 0x41;
+		_note[note].flags = 0x01;
 
 		setupTone(note);
 	} else {
@@ -235,7 +225,7 @@
 		_note[newNote].hardwareChannel = _note[note].hardwareChannel;
 		++_channel[_note[newNote].midiChannel].noteCount;
 		_hardwareChannel[_note[note].hardwareChannel] = _note[newNote].midiChannel;
-		_note[newNote].flags = 0x41;
+		_note[newNote].flags = 0x01;
 
 		setupTone(newNote);
 	} while (--totalNotes);
@@ -243,7 +233,7 @@
 
 void MidiDriver_PCSpeaker::noteOff(int channel, int note) {
 	for (int i = 0; i < 2; ++i) {
-		if (_note[i].enabled && _note[i].note1 == note && _note[i].midiChannel == channel) {
+		if (_note[i].enabled && _note[i].note == note && _note[i].midiChannel == channel) {
 			if (_channel[i].hold < 0x40) {
 				turnNoteOff(i);
 				_note[i].enabled = false;
@@ -272,8 +262,6 @@
 	if (_note[note].hardwareChannel == 0xFF)
 		return;
 
-	if (_note[note].flags & 0x40)
-		_note[note].flags &= 0xBF;
 	if (!(_note[note].flags & 0x01))
 		return;
 
@@ -283,7 +271,7 @@
 		const int midiChannel = _note[note].midiChannel;
 		uint16 pitchBend = (_channel[midiChannel].pitchBendHigh << 7) | _channel[midiChannel].pitchBendLow;
 
-		int noteValue = _note[note].note2;
+		int noteValue = _note[note].note;
 
 		noteValue -= 24;
 		do {
@@ -351,11 +339,6 @@
 	}*/
 }
 
-const uint8 MidiDriver_PCSpeaker::_velocityTable[] = {
-	0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64, 0x67,
-	0x6A, 0x6D, 0x70, 0x73, 0x76, 0x79, 0x7C, 0x7F
-};
-
 const uint8 MidiDriver_PCSpeaker::_noteTable1[] = {
 	0x88, 0xB5, 0x4E, 0x40, 0x41, 0xCD, 0xC4, 0x3D,
 	0x43, 0x7C, 0x2A, 0xD6, 0x88, 0xB5, 0xFF, 0xD1,


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