[Scummvm-cvs-logs] CVS: scummvm/scumm player_v1.h,1.6,1.7 player_v2.cpp,2.34,2.35 player_v1.cpp,1.9,1.10

Jochen Hoenicke hoenicke at users.sourceforge.net
Tue Sep 30 10:10:04 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv9923

Modified Files:
	player_v1.h player_v2.cpp player_v1.cpp 
Log Message:
player_v2.h

Index: player_v1.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v1.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- player_v1.h	19 Sep 2003 14:43:57 -0000	1.6
+++ player_v1.h	30 Sep 2003 17:08:59 -0000	1.7
@@ -79,7 +79,7 @@
 	uint  _mplex;
 	uint  _repeat_ctr;
 	uint  _freq_current;
-	uint  _forced_level;
+	int   _forced_level;
 	uint16 _random_lsr;
 	uint  *_value_ptr;
 	uint  _time_left;

Index: player_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v2.cpp,v
retrieving revision 2.34
retrieving revision 2.35
diff -u -d -r2.34 -r2.35
--- player_v2.cpp	19 Sep 2003 14:43:57 -0000	2.34
+++ player_v2.cpp	30 Sep 2003 17:08:59 -0000	2.35
@@ -433,8 +433,8 @@
 	/* build volume table (2dB per step) */
 	for (int i = 0; i < 15; i++) {
 		/* limit volume to avoid clipping */
-		if (out > 0x7fff)
-			_volumetable[i] = 0x7fff;
+		if (out > 0xffff)
+			_volumetable[i] = 0xffff;
 		else
 			_volumetable[i] = (int) out;
 
@@ -860,8 +860,8 @@
 
 void Player_V2::lowPassFilter(int16 *sample, uint len) {
 	for (uint i = 0; i < len; i++) {
-		_level = (_level * _decay
-			 + (unsigned int)sample[0] * (0x10000-_decay)) >> 16;
+		_level = (int) (_level * _decay
+				+ sample[0] * (0x10000-_decay)) >> 16;
 		sample[0] = sample[1] = _level;
 		sample += 2;
 	}
@@ -870,6 +870,7 @@
 void Player_V2::squareGenerator(int channel, int freq, int vol,
                                 int noiseFeedback, int16 *sample, uint len) {
 	int period = _update_step * freq;
+	long nsample;
 	if (period == 0)
 		period = _update_step;
 
@@ -901,11 +902,15 @@
 		if (_timer_output & (1 << channel))
 			duration -= _timer_count[channel];
 		
-		sample[0] += (duration * _volumetable[vol]) >> FIXP_SHIFT;
-		if (sample[0] < 0) {
-			/* overflow: clip value */
-			sample[0] = 0x7fff;
-		}
+		nsample = *sample + 
+			(((signed long) (duration - (1 << (FIXP_SHIFT-1)))
+			  * (signed long) _volumetable[vol]) >> FIXP_SHIFT);
+		/* overflow: clip value */
+		if (nsample > 0x7fff)
+			nsample = 0x7fff;
+		if (nsample < -0x8000)
+			nsample = -0x8000;
+		*sample = nsample;
 		// The following write isn't necessary, because the lowPassFilter does it for us
 		//sample[1] = sample[0];
 		sample += 2;

Index: player_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v1.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- player_v1.cpp	19 Sep 2003 14:43:57 -0000	1.9
+++ player_v1.cpp	30 Sep 2003 17:08:59 -0000	1.10
@@ -179,6 +179,7 @@
 		_delta = (int16) READ_LE_UINT16(_next_chunk + 4);
 		_channels[0].freq = 0;
 		_next_chunk += 6;
+		_forced_level = -1;
 		debug(6, "chunk 2: %d -> %d step %d", 
 			  _start, _end, _delta);
 		break;
@@ -188,6 +189,7 @@
 		_delta = (int16) READ_LE_UINT16(_next_chunk + 4);
 		_channels[0].freq = 0;
 		_next_chunk += 6;
+		_forced_level = -1;
 		debug(6, "chunk 3: %d -> %d step %d", 
 			  _start, _end, _delta);
 		break;
@@ -237,7 +239,7 @@
 			return;
 		}
 		set_mplex(_start);
-		_forced_level ^= 1;
+		_forced_level = -_forced_level;
 		break;
 	case 3:
 		_start = (_start + _delta) & 0xffff;
@@ -249,7 +251,7 @@
 		lsr = (lsr >> 3) | (lsr << 13);
 		_random_lsr = lsr;
 		set_mplex((_start & lsr) | 0x180);
-		_forced_level ^= 1;
+		_forced_level = -_forced_level;
 		break;
 	}
 }
@@ -310,7 +312,8 @@
 			_channels[i].cmd_ptr   = _current_data + tmp + 10;
 		}
 		break;
-	case 1: /* FIXME: implement! */
+
+	case 1:
 		set_mplex(READ_LE_UINT16(_next_chunk));
 		tmp = READ_LE_UINT16(_next_chunk + 2);
 		_channels[0].cmd_ptr = tmp != 0xffff ? _current_data + tmp : NULL;
@@ -360,6 +363,7 @@
 		_delta = (int16) READ_LE_UINT16(_next_chunk + 4);
 		_channels[0].freq = 0;
 		_next_chunk += 6;
+		_forced_level = -1;
 		debug(6, "chunk 2: %d -> %d step %d", 
 			  _start, _end, _delta);
 		break;
@@ -481,7 +485,7 @@
 		}
 		set_mplex(_start);
 		debug(7, "chunk 2: mplex %d  curve %d", _start, _forced_level);
-		_forced_level ^= 1;
+		_forced_level = -_forced_level;
 		break;
 	case 3:
 		dummy = _channels[3].volume + _delta;
@@ -526,8 +530,9 @@
 	memset(data, 0, 2 * sizeof(int16) * len);
 	if (_channels[0].freq == 0) {
 		if (_forced_level) {
+			int sample = _forced_level * _volumetable[0];
 			for (i = 0; i < len; i++)
-				data[2*i] = data[2*i+1] = _volumetable[0];
+				data[2*i] = data[2*i+1] = sample;
 			debug(9, "speaker: %8x: forced one", _tick_len);
 		} else if (!_level) {
 			return;
@@ -548,8 +553,9 @@
 	memset(data, 0, 2 * sizeof(int16) * len);
 
 	if (_forced_level) {
+		int sample = _forced_level * _volumetable[0];
 		for (i = 0; i < len; i++)
-			data[2*i] = data[2*i+1] = _volumetable[0];
+			data[2*i] = data[2*i+1] = sample;
 		hasdata = true;
 		debug(9, "channel[4]: %8x: forced one", _tick_len);
 	}





More information about the Scummvm-git-logs mailing list