[Scummvm-cvs-logs] CVS: scummvm/scumm player_v1.cpp,1.8,1.9 player_v1.h,1.5,1.6 player_v2.cpp,2.33,2.34 player_v2.h,2.14,2.15

Max Horn fingolfin at users.sourceforge.net
Fri Sep 19 13:05:57 CEST 2003


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

Modified Files:
	player_v1.cpp player_v1.h player_v2.cpp player_v2.h 
Log Message:
cleanup; some more fixed need afnow that the premix proc is expected to generate stereo data; (we probably should add a common base class for Player_V1/V2 instead of deriving V1 from V2)

Index: player_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v1.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- player_v1.cpp	19 Sep 2003 14:13:24 -0000	1.8
+++ player_v1.cpp	19 Sep 2003 14:43:57 -0000	1.9
@@ -56,7 +56,6 @@
 	_current_nr = nr;
 	_current_data = data;
 	_repeat_chunk = _next_chunk = data + (_pcjr ? 2 : 4);
-	_music_timer = 0;
 
 	debug(4, "Chaining new sound %d", nr);
 	if (_pcjr)
@@ -512,43 +511,23 @@
 	_tick_len = _mplex_step * mplex;
 }
 
-void Player_V1::do_mix(int16 *data, uint len) {
-	mutex_up();
-	uint step;
-
-	do {
-		step = len;
-		if (step > (_next_tick >> FIXP_SHIFT))
-			step = (_next_tick >> FIXP_SHIFT);
+void Player_V1::nextTick() {
+	if (_next_chunk) {
 		if (_pcjr)
-			generatePCjrSamples(data, step);
+			nextPCjrCmd();
 		else
-			generateSpkSamples(data, step);
-		data += 2 * step;
-		_next_tick -= step << FIXP_SHIFT;
-
-		if (!(_next_tick >> FIXP_SHIFT)) {
-			_next_tick += _tick_len;
-			if (_next_chunk) {
-				if (_pcjr)
-					nextPCjrCmd();
-				else
-					nextSpeakerCmd();
-			}
-		}
-	} while (len -= step);
-	mutex_down();
+			nextSpeakerCmd();
+	}
 }
 
 void Player_V1::generateSpkSamples(int16 *data, uint len) {
 	uint i;
 
-	memset (data, 0, sizeof(int16) * len);
+	memset(data, 0, 2 * sizeof(int16) * len);
 	if (_channels[0].freq == 0) {
 		if (_forced_level) {
-			for (i = 0; i < len; i++) {
-				data[i] = _volumetable[0];
-			}
+			for (i = 0; i < len; i++)
+				data[2*i] = data[2*i+1] = _volumetable[0];
 			debug(9, "speaker: %8x: forced one", _tick_len);
 		} else if (!_level) {
 			return;
@@ -566,11 +545,11 @@
 	uint freq, vol;
 	bool hasdata = false;
 
-	memset(data, 0, sizeof(int16) * len);
+	memset(data, 0, 2 * sizeof(int16) * len);
 
 	if (_forced_level) {
 		for (i = 0; i < len; i++)
-			data[i] = _volumetable[0];
+			data[2*i] = data[2*i+1] = _volumetable[0];
 		hasdata = true;
 		debug(9, "channel[4]: %8x: forced one", _tick_len);
 	}

Index: player_v1.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v1.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- player_v1.h	7 Sep 2003 17:14:56 -0000	1.5
+++ player_v1.h	19 Sep 2003 14:43:57 -0000	1.6
@@ -53,24 +53,25 @@
 	int  getMusicTimer() const;
 
 protected:
+	virtual void nextTick();
+	virtual void clear_channel(int i);
+	virtual void chainSound(int nr, byte *data);
+
+	virtual void generateSpkSamples(int16 *data, uint len);
+	virtual void generatePCjrSamples(int16 *data, uint len);
+
 	void restartSound();
 	void next_speaker_cmd(ChannelInfo *channel);
-	void clear_channel(int i);
-	void chainSound(int nr, byte *data);
-
-	void do_mix(int16 *buf, uint len);
 
 	void set_mplex(uint mplex);
 	void parseSpeakerChunk();
 	void nextSpeakerCmd();
 	void parsePCjrChunk();
 	void nextPCjrCmd();
-	void generateSpkSamples(int16 *data, uint len);
-	void generatePCjrSamples(int16 *data, uint len);
 
+private:
 	channel_data_v1 _channels[4];
 
-private:
 	byte *_next_chunk;
 	byte *_repeat_chunk;
 	uint  _chunk_type;

Index: player_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v2.cpp,v
retrieving revision 2.33
retrieving revision 2.34
diff -u -d -r2.33 -r2.34
--- player_v2.cpp	18 Sep 2003 19:56:38 -0000	2.33
+++ player_v2.cpp	19 Sep 2003 14:43:57 -0000	2.34
@@ -838,20 +838,24 @@
 		_next_tick -= step << FIXP_SHIFT;
 
 		if (!(_next_tick >> FIXP_SHIFT)) {
-			for (int i = 0; i < 4; i++) {
-				if (!_channels[i].d.time_left)
-					continue;
-				next_freqs(&_channels[i]);
-			}
 			_next_tick += _tick_len;
-			if (_music_timer_ctr++ >= _ticks_per_music_timer) {
-				_music_timer_ctr = 0;
-				_music_timer++;
-			}
+			nextTick();
 		}
 	} while (len -= step);
 
 	mutex_down();
+}
+
+void Player_V2::nextTick() {
+	for (int i = 0; i < 4; i++) {
+		if (!_channels[i].d.time_left)
+			continue;
+		next_freqs(&_channels[i]);
+	}
+	if (_music_timer_ctr++ >= _ticks_per_music_timer) {
+		_music_timer_ctr = 0;
+		_music_timer++;
+	}
 }
 
 void Player_V2::lowPassFilter(int16 *sample, uint len) {

Index: player_v2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v2.h,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -d -r2.14 -r2.15
--- player_v2.h	7 Sep 2003 19:28:45 -0000	2.14
+++ player_v2.h	19 Sep 2003 14:43:57 -0000	2.15
@@ -102,42 +102,48 @@
 	unsigned int _RNG;
 	unsigned int _volumetable[16];
 
-	int _music_timer;
-	int _music_timer_ctr;
-	int _ticks_per_music_timer;
 	int _timer_count[4];
 	int _timer_output;
 
-	const uint16 *_freqs_table;
-
-	ChannelInfo _channels[5];
-
 	int   _current_nr;
 	byte *_current_data;
 	int   _next_nr;
 	byte *_next_data;
 	byte *_retaddr;
 
+private:
+	int _music_timer;
+	int _music_timer_ctr;
+	int _ticks_per_music_timer;
+
+	const uint16 *_freqs_table;
+
 	OSystem::MutexRef _mutex;
+	ChannelInfo _channels[5];
+
+protected:
 	void mutex_up() { _system->lock_mutex (_mutex); }
 	void mutex_down() { _system->unlock_mutex (_mutex); }
 
-	virtual void set_pcjr(bool pcjr);
-	void execute_cmd(ChannelInfo *channel);
-	virtual void next_freqs(ChannelInfo *channel);
+	virtual void nextTick();
 	virtual void clear_channel(int i);
 	virtual void chainSound(int nr, byte *data);
 	virtual void chainNextSound();
 
-	static void premix_proc(void *param, int16 *buf, uint len);
-	virtual void do_mix (int16 *buf, uint len);
+	virtual void generateSpkSamples(int16 *data, uint len);
+	virtual void generatePCjrSamples(int16 *data, uint len);
 
 	void lowPassFilter(int16 *data, uint len);
 	void squareGenerator(int channel, int freq, int vol,
 	                     int noiseFeedback, int16 *sample, uint len);
-	void generateSpkSamples(int16 *data, uint len);
-	void generatePCjrSamples(int16 *data, uint len);
     
+private:
+	static void premix_proc(void *param, int16 *buf, uint len);
+	void do_mix(int16 *buf, uint len);
+
+	void set_pcjr(bool pcjr);
+	void execute_cmd(ChannelInfo *channel);
+	void next_freqs(ChannelInfo *channel);
 };
 
 #endif





More information about the Scummvm-git-logs mailing list