[Scummvm-cvs-logs] CVS: scummvm/scumm player_v2.cpp,2.10,2.11 player_v2.h,2.3,2.4

Jochen Hoenicke hoenicke at users.sourceforge.net
Fri Jun 6 14:57:06 CEST 2003


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

Modified Files:
	player_v2.cpp player_v2.h 
Log Message:
Added a fix for music_timer in V3 games.


Index: player_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v2.cpp,v
retrieving revision 2.10
retrieving revision 2.11
diff -u -d -r2.10 -r2.11
--- player_v2.cpp	5 Jun 2003 08:45:24 -0000	2.10
+++ player_v2.cpp	6 Jun 2003 21:56:37 -0000	2.11
@@ -336,6 +336,8 @@
 	_sample_rate = _system->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
 	_mutex = _system->create_mutex();
 
+	_header_len = (scumm->_features & GF_SMALL_HEADER) ? 6 : 4;
+
 	// Initialize sound queue 
 	current_nr = next_nr = 0;
 	current_data = next_data = 0;
@@ -347,6 +349,10 @@
 	_next_tick = 0;
 	_tick_len = (_sample_rate << FIXP_SHIFT) / FREQ_HZ;
 
+	// Initialize V3 music timer
+	_music_timer_ctr = _music_timer = 0;
+	_ticks_per_music_timer = 65535;
+
 	// Initialize square generator
 	_level = 0;
 
@@ -418,7 +424,8 @@
 }
 
 void Player_V2::chainSound(int nr, byte *data) {
-	int offset = _pcjr ? 14 : 6;
+	int offset = _header_len + (_pcjr ? 10 : 2);
+
 	current_nr = nr;
 	current_data = data;
 
@@ -432,6 +439,7 @@
 				channels[i].d.time_left = 1;
 		}
 	}
+	_music_timer = 0;
 }
 
 void Player_V2::chainNextSound() {
@@ -472,11 +480,11 @@
 void Player_V2::startSound(int nr, byte *data) {
 	mutex_up();
 
-	int cprio = current_data ? *(current_data+4) : 0;
-	int prio  = *(data+4);
-	int nprio = next_data ? *(next_data+4) : 0;
+	int cprio = current_data ? *(current_data + _header_len) : 0;
+	int prio  = *(data + _header_len);
+	int nprio = next_data ? *(next_data + _header_len) : 0;
 
-	int restartable = *(data+5);
+	int restartable = *(data + _header_len + 1);
 
 	if (!current_nr || cprio <= prio) {
 		int tnr = current_nr;
@@ -487,7 +495,7 @@
 		nr   = tnr;
 		prio = tprio;
 		data = tdata;
-		restartable = data ? *(data+5) : 0;
+		restartable = data ? *(data + _header_len + 1) : 0;
 	}
 	
 	if (!current_nr) {
@@ -509,7 +517,7 @@
 }
 
 void Player_V2::restartSound() {
-	if (*(current_data + 5)) {
+	if (*(current_data + _header_len + 1)) {
 		/* current sound is restartable */
 		chainSound(current_nr, current_data);
 	} else {
@@ -548,7 +556,10 @@
 }
 
 int Player_V2::getMusicTimer() {
-	return channels[0].d.music_timer;
+	if ((_scumm->_features & GF_AFTER_V3))
+		return _music_timer;
+	else
+		return channels[0].d.music_timer;
 }
 
 void Player_V2::execute_cmd(ChannelInfo *channel) {
@@ -640,7 +651,11 @@
 				channel->array[opcode/2] = value;
 				debug(9, "channels[%d]: set param %2d = %5d", 
 				channel - &channels[0], opcode, value);
-				script_ptr+=2;
+				script_ptr += 2;
+				if (opcode == 14) {
+				    /* tempo var */
+				    _ticks_per_music_timer = 125;
+				}
 				if (opcode == 0)
 					goto end;
 				break;
@@ -806,6 +821,10 @@
 				next_freqs(&channels[i]);
 			}
 			_next_tick += _tick_len;
+			if (_music_timer_ctr++ >= _ticks_per_music_timer) {
+				_music_timer_ctr = 0;
+				_music_timer++;
+			}
 		}
 	} while (len -= step);
 	mutex_down();

Index: player_v2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v2.h,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -d -r2.3 -r2.4
--- player_v2.h	1 Jun 2003 16:42:29 -0000	2.3
+++ player_v2.h	6 Jun 2003 21:56:37 -0000	2.4
@@ -79,6 +79,7 @@
 
 
 	bool _pcjr;
+	int _header_len;
 
 	int _sample_rate;
 	int _next_tick;
@@ -89,6 +90,9 @@
 	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;
 





More information about the Scummvm-git-logs mailing list