[Scummvm-cvs-logs] CVS: scummvm/scumm script_v5.cpp,1.127,1.128 sound.cpp,1.149,1.150 sound.h,1.37,1.38

Max Horn fingolfin at users.sourceforge.net
Mon Jun 30 16:19:03 CEST 2003


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

Modified Files:
	script_v5.cpp sound.cpp sound.h 
Log Message:
partially implemented the Audio CD query opcode in Zak256 (see bug #762589); cleanup

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -d -r1.127 -r1.128
--- script_v5.cpp	26 Jun 2003 14:38:48 -0000	1.127
+++ script_v5.cpp	30 Jun 2003 23:18:19 -0000	1.128
@@ -2015,15 +2015,38 @@
 }
 
 void Scumm_v5::o5_startMusic() {
-	int snd;
 	if (_gameId == GID_ZAK256) {
+		// In Zak256, this seems to be some kind of Audio CD status query function.
+		// See also bug #762589 (thanks to Hibernatus for providing the information).
 		getResultPos();
-		snd = getVarOrDirectByte(0x80);
-		warning("unknown: o5_startMusic(%d)", snd);
+		int b = getVarOrDirectByte(0x80);
+		int result = 0;
+		switch (b) {
+		case 0:
+			result = _sound->pollCD() != 0;
+			break;
+		case 0xFC:
+			// TODO: Unpause (resume) audio track. We'll have to extend Sound and OSystem for this.
+			break;
+		case 0xFD:
+			// TODO: Pause audio track. We'll have to extend Sound and OSystem for this.
+			break;
+		case 0xFE:
+			result = _sound->getCurrentCDSound();
+			break;
+		case 0xFF:
+			// Unknown, but apparently never used.
+			break;
+		default:
+			// TODO: return track length in seconds. We'll have to extend Sound and OSystem for this.
+			// To check scummvm returns the right track length you 
+			// can look at the global script #9 (0x888A in 49.LFL). 
+			break;
+		}
+		warning("unknown: o5_startMusic(%d)", b);
 		setResult(0);
 	} else {
-		snd = getVarOrDirectByte(0x80);
-		_sound->addSoundToQueue(snd);
+		_sound->addSoundToQueue(getVarOrDirectByte(0x80));
 	}
 }
 
@@ -2522,7 +2545,7 @@
 						_sound->stopCD();
 					} else {
 						// Loom specified the offset from the start of the CD;
-						// thus we have to subtract the lenght of the first track
+						// thus we have to subtract the length of the first track
 						// (22500 frames) plus the 2 second = 150 frame leadin.
 						// I.e. in total 22650 frames.
 						offset = (int)(offset * 7.5 - 22650);

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -d -r1.149 -r1.150
--- sound.cpp	30 Jun 2003 22:25:08 -0000	1.149
+++ sound.cpp	30 Jun 2003 23:18:20 -0000	1.150
@@ -93,7 +93,7 @@
 	_musicDisk = 0;
 	_talkChannel = -1;
 	_current_cache = 0;
-	_current_cd_sound = 0;
+	_currentCDSound = 0;
 
 	_sfxFile = 0;
 	
@@ -200,7 +200,7 @@
 			_scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0;
 			playCDTrack(track, loops == 0xff ? -1 : loops, start, 0);
 
-			_current_cd_sound = soundID;
+			_currentCDSound = soundID;
 			return;
 		}
 		// Support for SFX in Monkey Island 1, Mac version
@@ -379,12 +379,12 @@
 				int start = (ptr[2] * 60 + ptr[3]) * 75 + ptr[4];
 				int end = (ptr[5] * 60 + ptr[6]) * 75 + ptr[7];
 
-				if (soundID == _current_cd_sound)
+				if (soundID == _currentCDSound)
 					if (pollCD() == 1)
 						return;
 
 				playCDTrack(track, loops == 0xff ? -1 : loops, start, end);
-				_current_cd_sound = soundID;
+				_currentCDSound = soundID;
 				return;
 			}
 	
@@ -601,7 +601,7 @@
 int Sound::isSoundRunning(int sound) const {
 	int i;
 
-	if (sound == _current_cd_sound)
+	if (sound == _currentCDSound)
 		return pollCD();
 	
 	if (_scumm->_features & GF_HUMONGOUS) {
@@ -645,7 +645,7 @@
 bool Sound::isSoundActive(int sound) const {
 	int i;
 
-	if (sound == _current_cd_sound)
+	if (sound == _currentCDSound)
 		return pollCD() != 0;
 
 	i = _soundQue2Pos;
@@ -692,8 +692,8 @@
 void Sound::stopSound(int a) {
 	int i;
 
-	if (a != 0 && a == _current_cd_sound) {
-		_current_cd_sound = 0;
+	if (a != 0 && a == _currentCDSound) {
+		_currentCDSound = 0;
 		stopCD();
 	}
 
@@ -711,8 +711,8 @@
 }
 
 void Sound::stopAllSounds() {
-	if (_current_cd_sound != 0) {
-		_current_cd_sound = 0;
+	if (_currentCDSound != 0) {
+		_currentCDSound = 0;
 		stopCD();
 	}
 

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- sound.h	30 Jun 2003 22:25:08 -0000	1.37
+++ sound.h	30 Jun 2003 23:18:20 -0000	1.38
@@ -82,7 +82,7 @@
 
 	/* used for mp3 CD music */
 
-	int _current_cd_sound;
+	int _currentCDSound;
 
 	int _cached_tracks[CACHE_TRACKS];
 	int _dig_cd_index;
@@ -102,8 +102,11 @@
 
 	int _talkChannel;	/* Mixer channel actor is talking on */
 	bool _soundsPaused;
-	int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx;
 	byte _sfxMode;
+	
+	// FIXME: Should add API to get/set volumes (and automatically
+	// update iMuse/iMuseDigi/Player_v2/SoundMIxer, too
+	int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx;
 
 	Bundle *_bundle;	// FIXME: should be protected but is used by Scumm::askForDisk
 
@@ -143,6 +146,7 @@
 	void stopCD();
 	int pollCD() const;
 	void updateCD();
+	int getCurrentCDSound() const { return _currentCDSound; }
 
 protected:
 	void clearSoundQue();





More information about the Scummvm-git-logs mailing list