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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Jan 25 18:43:49 CET 2007


Revision: 25192
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25192&view=rev
Author:   lordhoto
Date:     2007-01-25 09:43:48 -0800 (Thu, 25 Jan 2007)

Log Message:
-----------
Adds CD audio support.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/seqplayer.cpp
    scummvm/trunk/engines/kyra/sequences_v1.cpp
    scummvm/trunk/engines/kyra/sound.cpp
    scummvm/trunk/engines/kyra/sound.h

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2007-01-25 15:17:46 UTC (rev 25191)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2007-01-25 17:43:48 UTC (rev 25192)
@@ -146,7 +146,11 @@
 	// TODO: We should play the native Kyra 2 Adlib music, but until that
 	//       is support, we'll use the automagic MIDI -> Adlib converter.
 
-	if (midiDriver == MD_ADLIB && _flags.gameID == GI_KYRA1) {
+	if (_flags.hasAudioCD) {
+		// no sfx enabled for CD audio music atm
+		// later on here should be a usage of MixedSoundDriver
+		_sound = new SoundCD(this, _mixer);
+	} else if (midiDriver == MD_ADLIB && _flags.gameID == GI_KYRA1) {
 		_sound = new SoundAdlibPC(_mixer, this);
 		assert(_sound);
 	} else {

Modified: scummvm/trunk/engines/kyra/seqplayer.cpp
===================================================================
--- scummvm/trunk/engines/kyra/seqplayer.cpp	2007-01-25 15:17:46 UTC (rev 25191)
+++ scummvm/trunk/engines/kyra/seqplayer.cpp	2007-01-25 17:43:48 UTC (rev 25192)
@@ -399,37 +399,20 @@
 
 void SeqPlayer::s1_playTrack() {
 	uint8 msg = *_seqData++;
-/*	
-	// we do not have audio cd support for now
-	if (_vm->features() & GF_AUDIOCD) {
-		switch (msg) {
-		case 0:
-			// nothing to do here...
-			break;
-		case 1:
-			_sound->beginFadeOut();
-			break;
-		case 56:
-			_vm->snd_playTheme(KyraEngine::MUSIC_INTRO, 3);
-			break;
-		case 57:
-			_vm->snd_playTheme(KyraEngine::MUSIC_INTRO, 4);
-			break;
-		case 58:
-			_vm->snd_playTheme(KyraEngine::MUSIC_INTRO, 5);
-			break;
-		default:
-			warning("Unknown seq. message: %.02d", msg);
-			break;
-		}
-	} else {*/
+
+	if (_vm->gameFlags().hasAudioCD) {
+		if (msg <= 1)
+			_vm->snd_playWanderScoreViaMap(msg, 0);
+		else
+			_vm->snd_playWanderScoreViaMap(msg+55, 0);
+	} else {
 		if (msg == 1) {
 			_sound->beginFadeOut();
 		} else {
 			_sound->haltTrack();
 			_sound->playTrack(msg);
 		}
-//	}
+	}
 }
 
 void SeqPlayer::s1_allocTempBuffer() {

Modified: scummvm/trunk/engines/kyra/sequences_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_v1.cpp	2007-01-25 15:17:46 UTC (rev 25191)
+++ scummvm/trunk/engines/kyra/sequences_v1.cpp	2007-01-25 17:43:48 UTC (rev 25192)
@@ -109,7 +109,10 @@
 
 	_seq->setCopyViewOffs(true);
 	_screen->setFont(Screen::FID_8_FNT);
-	snd_playTheme(MUSIC_INTRO, 2);
+	if (_flags.hasAudioCD)
+		snd_playWanderScoreViaMap(57, 0);
+	else
+		snd_playTheme(MUSIC_INTRO, 2);
 	_text->setTalkCoords(144);
 	for (int i = 0; i < ARRAYSIZE(introProcTable) && !seq_skipSequence(); ++i) {
 		(this->*introProcTable[i])();

Modified: scummvm/trunk/engines/kyra/sound.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound.cpp	2007-01-25 15:17:46 UTC (rev 25191)
+++ scummvm/trunk/engines/kyra/sound.cpp	2007-01-25 17:43:48 UTC (rev 25192)
@@ -28,6 +28,7 @@
 #include "sound/mixer.h"
 #include "sound/voc.h"
 #include "sound/audiostream.h"
+#include "sound/audiocd.h"
 
 #include "sound/mp3.h"
 #include "sound/vorbis.h"
@@ -433,7 +434,118 @@
 
 #pragma mark -
 
+SoundCD::~SoundCD() {
+	AudioCD.stop();
+}
 
+bool SoundCD::init() {
+	_engine->checkCD();
+	return true;
+}
+
+void SoundCD::process() {
+	AudioCD.updateCD();
+}
+
+namespace {
+
+struct CDTrackTable {
+	uint32 unk1;
+	bool loop;
+	int track;
+};
+
+} // end of anonymous namespace
+
+void SoundCD::playTrack(uint8 track) {
+	if (track < 2)
+		return;
+	track -= 2;
+
+	static CDTrackTable tTable[] = {
+		{ 0x04000, 1,  0 },
+		{ 0x05480, 1,  6 },
+		{ 0x05E70, 0,  1 },
+		{ 0x06D90, 1,  3 },
+		{ 0x072C0, 0, -1 },
+		{ 0x075F0, 1, -1 },
+		{ 0x07880, 1, -1 },
+		{ 0x089C0, 0, -1 },
+		{ 0x09080, 0, -1 },
+		{ 0x091D0, 1,  4 },
+		{ 0x0A880, 1,  5 },
+		{ 0x0AF50, 0, -1 },
+		{ 0x0B1A0, 1, -1 },
+		{ 0x0B870, 0, -1 },
+		{ 0x0BCF0, 1, -1 },
+		{ 0x0C5D0, 1,  7 },
+		{ 0x0D3E0, 1,  8 },
+		{ 0x0e7b0, 1,  2 },
+		{ 0x0edc0, 0, -1 },
+		{ 0x0eef0, 1,  9 },
+		{ 0x10540, 1, 10 },
+		{ 0x10d80, 0, -1 },
+		{ 0x10E30, 0, -1 },
+		{ 0x10FC0, 0, -1 },
+		{ 0x11310, 1, -1 },
+		{ 0x11A20, 1, -1 },
+		{ 0x12380, 0, -1 },
+		{ 0x12540, 1, -1 },
+		{ 0x12730, 1, -1 },
+		{ 0x12A90, 1, 11 },
+		{ 0x134D0, 0, -1 },
+		{ 0x00000, 0, -1 },
+		{ 0x13770, 0, -1 },
+		{ 0x00000, 0, -1 },
+		{ 0x00000, 0, -1 },
+		{ 0x00000, 0, -1 },
+		{ 0x00000, 0, -1 },
+		{ 0x14710, 1, 12 },
+		{ 0x15DF0, 1, 13 },
+		{ 0x16030, 1, 14 },
+		{ 0x17030, 0, -1 },
+		{ 0x17650, 0, -1 },
+		{ 0x134D0, 0, -1 },
+		{ 0x178E0, 1, -1 },
+		{ 0x18200, 0, -1 },
+		{ 0x18320, 0, -1 },
+		{ 0x184A0, 0, -1 },
+		{ 0x18BB0, 0, -1 },
+		{ 0x19040, 0, 19 },
+		{ 0x19B50, 0, 20 },
+		{ 0x17650, 0, -1 },
+		{ 0x1A730, 1, 21 },
+		{ 0x00000, 0, -1 },
+		{ 0x12380, 0, -1 },
+		{ 0x1B810, 0, -1 },
+		{ 0x1BA50, 0, 15 },
+		{ 0x1C190, 0, 16 },
+		{ 0x1CA50, 0, 17 },
+		{ 0x1D100, 0, 18 },
+	};
+
+	int trackNum = tTable[track].track;
+	bool loop = tTable[track].loop;
+	// could be that if the trackNum is -1, the music should be stopped
+	// instead of letting the old music play on
+	if (trackNum == -1 || trackNum == _lastTrack)
+		return;
+
+	haltTrack();
+	AudioCD.play(trackNum+1, loop ? -1 : 1, 0, 0);
+	AudioCD.updateCD();
+
+	_lastTrack = trackNum;
+}
+
+void SoundCD::haltTrack() {
+	_lastTrack = -1;
+	AudioCD.stop();
+	AudioCD.updateCD();
+}
+
+#pragma mark -
+
 bool KyraEngine::speechEnabled() {
 	return _flags.isTalkie && (_configVoice == 1 || _configVoice == 2);
 }
@@ -457,45 +569,59 @@
 
 void KyraEngine::snd_playWanderScoreViaMap(int command, int restart) {
 	debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playWanderScoreViaMap(%d, %d)", command, restart);
-	static const int8 soundTable[] = {
-		-1,   0,  -1,   1,   0,   3,   0,   2,
-		 0,   4,   1,   2,   1,   3,   1,   4,
-		 1,  92,   1,   6,   1,   7,   2,   2,
-		 2,   3,   2,   4,   2,   5,   2,   6,
-		 2,   7,   3,   3,   3,   4,   1,   8,
-		 1,   9,   4,   2,   4,   3,   4,   4,
-		 4,   5,   4,   6,   4,   7,   4,   8,
-		 1,  11,   1,  12,   1,  14,   1,  13,
-		 4,   9,   5,  12,   6,   2,   6,   6,
-		 6,   7,   6,   8,   6,   9,   6,   3,
-		 6,   4,   6,   5,   7,   2,   7,   3,
-		 7,   4,   7,   5,   7,   6,   7,   7,
-		 7,   8,   7,   9,   8,   2,   8,   3,
-		 8,   4,   8,   5,   6,  11,   5,  11
-	};
-	//if (!_disableSound) {
-	//	XXX
-	//}
-	assert(command*2+1 < ARRAYSIZE(soundTable));
-	if (_curMusicTheme != soundTable[command*2]+1) {
-		if (soundTable[command*2] != -1) {
-			snd_playTheme(soundTable[command*2]+1);
-		}
-	}
-	
 	if (restart)
 		_lastMusicCommand = -1;
-	
-	if (command != 1) {
-		if (_lastMusicCommand != command) {
-			_lastMusicCommand = command;
+
+	if (_flags.hasAudioCD) {
+		if (command == 1) {
+			_sound->beginFadeOut();
+		} else if (command >= 35 && command <= 38) {
+			snd_playSoundEffect(command-20);
+		} else if (command >= 2) {
+			if (_lastMusicCommand != command) {
+				// the original does -2 here we handle this inside _sound->playTrack()
+				_sound->playTrack(command);
+			}
+		} else
 			_sound->haltTrack();
-			_sound->playTrack(soundTable[command*2+1]);
+	} else {
+		static const int8 soundTable[] = {
+			-1,   0,  -1,   1,   0,   3,   0,   2,
+			 0,   4,   1,   2,   1,   3,   1,   4,
+			 1,  92,   1,   6,   1,   7,   2,   2,
+			 2,   3,   2,   4,   2,   5,   2,   6,
+			 2,   7,   3,   3,   3,   4,   1,   8,
+			 1,   9,   4,   2,   4,   3,   4,   4,
+			 4,   5,   4,   6,   4,   7,   4,   8,
+			 1,  11,   1,  12,   1,  14,   1,  13,
+			 4,   9,   5,  12,   6,   2,   6,   6,
+			 6,   7,   6,   8,   6,   9,   6,   3,
+			 6,   4,   6,   5,   7,   2,   7,   3,
+			 7,   4,   7,   5,   7,   6,   7,   7,
+			 7,   8,   7,   9,   8,   2,   8,   3,
+			 8,   4,   8,   5,   6,  11,   5,  11
+		};
+		//if (!_disableSound) {
+		//	XXX
+		//}
+		assert(command*2+1 < ARRAYSIZE(soundTable));
+		if (_curMusicTheme != soundTable[command*2]+1) {
+			if (soundTable[command*2] != -1) {
+				snd_playTheme(soundTable[command*2]+1);
+			}
 		}
-	} else {
-		_lastMusicCommand = 1;
-		_sound->beginFadeOut();
+	
+		if (command != 1) {
+			if (_lastMusicCommand != command) {
+				_sound->haltTrack();
+				_sound->playTrack(soundTable[command*2+1]);
+			}
+		} else {
+			_sound->beginFadeOut();
+		}
 	}
+
+	_lastMusicCommand = command;
 }
 
 void KyraEngine::snd_playVoiceFile(int id) {

Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h	2007-01-25 15:17:46 UTC (rev 25191)
+++ scummvm/trunk/engines/kyra/sound.h	2007-01-25 17:43:48 UTC (rev 25192)
@@ -230,6 +230,29 @@
 	Common::Mutex _mutex;
 };
 
+class SoundCD : public Sound {
+public:
+	SoundCD(KyraEngine *engine, Audio::Mixer *mixer) : Sound(engine, mixer), _lastTrack(-1) {}
+	~SoundCD();
+
+	bool init();
+	void process();
+
+	void setVolume(int) { /* TODO */ }
+	int getVolume() { return 255; /* TODO */ }
+
+	void loadMusicFile(const char *) {}
+
+	void playTrack(uint8 track);
+	void haltTrack();
+
+	void playSoundEffect(uint8) {}
+
+	void beginFadeOut() { /* TODO */ }
+private:
+	int _lastTrack;
+};
+
 class MixedSoundDriver : public Sound {
 public:
 	MixedSoundDriver(KyraEngine *engine, Audio::Mixer *mixer, Sound *music, Sound *sfx) : Sound(engine, mixer), _music(music), _sfx(sfx) {}


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