[Scummvm-cvs-logs] SF.net SVN: scummvm:[47190] scummvm/trunk/engines/sci

waltervn at users.sourceforge.net waltervn at users.sourceforge.net
Sat Jan 9 03:14:38 CET 2010


Revision: 47190
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47190&view=rev
Author:   waltervn
Date:     2010-01-09 02:14:12 +0000 (Sat, 09 Jan 2010)

Log Message:
-----------
SCI: Move music device IDs to drivers.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/sound/iterator/core.cpp
    scummvm/trunk/engines/sci/sound/iterator/iterator.cpp
    scummvm/trunk/engines/sci/sound/music.cpp
    scummvm/trunk/engines/sci/sound/softseq/adlib.cpp
    scummvm/trunk/engines/sci/sound/softseq/amiga.cpp
    scummvm/trunk/engines/sci/sound/softseq/mididriver.h
    scummvm/trunk/engines/sci/sound/softseq/pcjr.cpp
    scummvm/trunk/engines/sci/sound/softseq/pcjr.h

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/resource.cpp	2010-01-09 02:14:12 UTC (rev 47190)
@@ -1898,7 +1898,7 @@
 		_trackCount = 1;
 		_tracks = new Track[_trackCount];
 		_tracks->digitalChannelNr = -1;
-		_tracks->type = TRACKTYPE_NONE;
+		_tracks->type = 0; // Not used for SCI0
 		_tracks->channelCount = 1;
 		// Digital sample data included? -> Add an additional channel
 		if (resource->data[0] == 2)
@@ -1957,7 +1957,7 @@
 			// 0xFF:BYTE as terminator to end that track and begin with another track type
 			// Track type 0xFF is the marker signifying the end of the tracks
 
-			_tracks[trackNr].type = (TrackType) *data++;
+			_tracks[trackNr].type = *data++;
 			// Counting # of channels used
 			data2 = data;
 			_tracks[trackNr].channelCount = 0;
@@ -2028,7 +2028,7 @@
 }
 #endif
 
-SoundResource::Track* SoundResource::getTrackByType(TrackType type) {
+SoundResource::Track *SoundResource::getTrackByType(byte type) {
 	if (_soundVersion <= SCI_VERSION_0_LATE)
 		return &_tracks[0];
 
@@ -2039,6 +2039,14 @@
 	return NULL;
 }
 
+SoundResource::Track *SoundResource::getDigitalTrack() {
+	for (int trackNr = 0; trackNr < _trackCount; trackNr++) {
+		if (_tracks[trackNr].digitalChannelNr != -1)
+			return &_tracks[trackNr];
+	}
+	return NULL;
+}
+
 // Gets the filter mask for SCI0 sound resources
 int SoundResource::getChannelFilterMask(int hardwareMask) {
 	byte *data = _innerResource->data;

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/resource.h	2010-01-09 02:14:12 UTC (rev 47190)
@@ -439,15 +439,6 @@
 
 class SoundResource {
 public:
-	enum TrackType {
-		TRACKTYPE_ADLIB = 0,
-		TRACKTYPE_GAMEBLASTER = 9,
-		TRACKTYPE_MT32 = 12,
-		TRACKTYPE_SPEAKER = 18,
-		TRACKTYPE_TANDY = 19,
-		TRACKTYPE_NONE = 255
-	};
-
 	struct Channel {
 		byte number;
 		byte poly;
@@ -459,7 +450,7 @@
 	};
 
 	struct Track {
-		TrackType type;
+		byte type;
 		byte channelCount;
 		Channel *channels;
 		int16 digitalChannelNr;
@@ -472,7 +463,8 @@
 #if 0
 	Track *getTrackByNumber(uint16 number);
 #endif
-	Track *getTrackByType(TrackType type);
+	Track *getTrackByType(byte type);
+	Track *getDigitalTrack();
 	int getChannelFilterMask(int hardwareMask);
 
 private:

Modified: scummvm/trunk/engines/sci/sound/iterator/core.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/iterator/core.cpp	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/sound/iterator/core.cpp	2010-01-09 02:14:12 UTC (rev 47190)
@@ -263,7 +263,7 @@
 
 Common::Error SfxPlayer::add_iterator(SongIterator *it, uint32 start_time) {
 	Common::StackLock lock(_mutex);
-	SIMSG_SEND(it, SIMSG_SET_PLAYMASK(_mididrv->getPlayMask(_soundVersion)));
+	SIMSG_SEND(it, SIMSG_SET_PLAYMASK(_mididrv->getPlayId(_soundVersion)));
 	SIMSG_SEND(it, SIMSG_SET_RHYTHM(_mididrv->hasRhythmChannel()));
 
 	if (_iterator == NULL) {

Modified: scummvm/trunk/engines/sci/sound/iterator/iterator.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/iterator/iterator.cpp	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/sound/iterator/iterator.cpp	2010-01-09 02:14:12 UTC (rev 47190)
@@ -666,20 +666,6 @@
 /*-- SCI1 song iterators --*/
 /***************************/
 
-#define SCI01_INVALID_DEVICE 0xff
-
-/* Second index determines whether PCM output is supported */
-static const int sci0_to_sci1_device_map[][2] = {
-	{0x06, 0x0c}, /* MT-32 */
-	{0xff, 0xff}, /* YM FB-01 */
-	{0x00, 0x00}, /* CMS/Game Blaster-- we assume OPL/2 here... */
-	{0xff, 0xff}, /* Casio MT540/CT460 */
-	{0x13, 0x13}, /* Tandy 3-voice */
-	{0x12, 0x12}, /* PC speaker */
-	{0xff, 0xff},
-	{0xff, 0xff},
-}; /* Maps bit number to device ID */
-
 int Sci1SongIterator::initSample(const int offset) {
 	Sci1Sample sample;
 	int rate;
@@ -1008,16 +994,8 @@
 			if (msg.ID == ID) {
 				channel_mask = 0;
 
-				_deviceId
-				= sci0_to_sci1_device_map
-				  [sci_ffs(msg._arg.i & 0xff) - 1]
-				  [g_system->getMixer()->isReady()]
-				  ;
+				_deviceId = msg._arg.i;
 
-				if (_deviceId == 0xff) {
-					warning("[iterator] Device %d(%d) not supported",
-					          msg._arg.i & 0xff, g_system->getMixer()->isReady());
-				}
 				if (_initialised) {
 					int i;
 					int toffset = -1;

Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/sound/music.cpp	2010-01-09 02:14:12 UTC (rev 47190)
@@ -303,30 +303,17 @@
 	SoundResource::Track *track = NULL;
 	int channelFilterMask = 0;
 
-	switch (_midiType) {
-	case MD_PCSPK:
-		track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_SPEAKER);
-		break;
-	case MD_PCJR:
-		track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_TANDY);
-		break;
-	case MD_ADLIB:
-		track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB);
-		break;
-	case MD_MT32:
-		track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_MT32);
-		break;
-	default:
-		// Should never occur
-		error("soundInitSnd: Unknown MIDI type");
-		break;
-	}
+	track = pSnd->soundRes->getTrackByType(_pMidiDrv->getPlayId(_soundVersion));
 
 	if (track) {
 		// If MIDI device is selected but there is no digital track in sound resource
 		// try to use adlib's digital sample if possible
-		if (_bMultiMidi && pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB)->digitalChannelNr != -1)
-			track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB);
+		if (_bMultiMidi && (track->digitalChannelNr == -1)) {
+			SoundResource::Track *digital = pSnd->soundRes->getDigitalTrack();
+			if (digital)
+				track = digital;
+		}
+
 		// Play digital sample
 		if (track->digitalChannelNr != -1) {
 			byte *channelData = track->channels[track->digitalChannelNr].data;
@@ -351,7 +338,7 @@
 			pSnd->pauseCounter = 0;
 
 			// Find out what channels to filter for SCI0
-			channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayMask(_soundVersion));
+			channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayId(_soundVersion));
 			pSnd->pMidiParser->loadMusic(track, pSnd, channelFilterMask, _soundVersion);
 
 			// Fast forward to the last position and perform associated events when loading

Modified: scummvm/trunk/engines/sci/sound/softseq/adlib.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/softseq/adlib.cpp	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/sound/softseq/adlib.cpp	2010-01-09 02:14:12 UTC (rev 47190)
@@ -162,7 +162,7 @@
 public:
 	MidiPlayer_Adlib() { _driver = new MidiDriver_Adlib(g_system->getMixer()); }
 	int open(ResourceManager *resMan);
-	int getPlayMask(SciVersion soundVersion);
+	byte getPlayId(SciVersion soundVersion);
 	int getPolyphony() const { return MidiDriver_Adlib::kVoices; }
 	bool hasRhythmChannel() const { return false; }
 	void setVolume(byte volume) { static_cast<MidiDriver_Adlib *>(_driver)->setVolume(volume); }
@@ -812,8 +812,15 @@
 	return static_cast<MidiDriver_Adlib *>(_driver)->open(getSciVersion() <= SCI_VERSION_0_LATE);
 }
 
-int MidiPlayer_Adlib::getPlayMask(SciVersion soundVersion) {
-	return (soundVersion == SCI_VERSION_0_EARLY) ? 0x01 : 0x04;
+byte MidiPlayer_Adlib::getPlayId(SciVersion soundVersion) {
+	switch (soundVersion) {
+	case SCI_VERSION_0_EARLY:
+		return 0x01;
+	case SCI_VERSION_0_LATE:
+		return 0x04;
+	default:
+		return 0x00;
+	}
 }
 
 MidiPlayer *MidiPlayer_Adlib_create() {

Modified: scummvm/trunk/engines/sci/sound/softseq/amiga.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/softseq/amiga.cpp	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/sound/softseq/amiga.cpp	2010-01-09 02:14:12 UTC (rev 47190)
@@ -654,7 +654,7 @@
 class MidiPlayer_Amiga : public MidiPlayer {
 public:
 	MidiPlayer_Amiga() { _driver = new MidiDriver_Amiga(g_system->getMixer()); }
-	int getPlayMask(SciVersion soundVersion);
+	byte getPlayId(SciVersion soundVersion);
 	int getPolyphony() const { return MidiDriver_Amiga::kVoices; }
 	bool hasRhythmChannel() const { return false; }
 	void setVolume(byte volume) { static_cast<MidiDriver_Amiga *>(_driver)->setVolume(volume); }
@@ -666,9 +666,9 @@
 	return new MidiPlayer_Amiga();
 }
 
-int MidiPlayer_Amiga::getPlayMask(SciVersion soundVersion) {
-	if (soundVersion == SCI_VERSION_0_EARLY)
-		error("No amiga support for sci0early");
+byte MidiPlayer_Amiga::getPlayId(SciVersion soundVersion) {
+	if (soundVersion != SCI_VERSION_0_LATE)
+		error("Amiga sound support not available for this SCI version");
 
 	return 0x40;
 }

Modified: scummvm/trunk/engines/sci/sound/softseq/mididriver.h
===================================================================
--- scummvm/trunk/engines/sci/sound/softseq/mididriver.h	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/sound/softseq/mididriver.h	2010-01-09 02:14:12 UTC (rev 47190)
@@ -81,7 +81,7 @@
 	MidiChannel *getPercussionChannel() { return _driver->getPercussionChannel(); }
 	void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) { _driver->setTimerCallback(timer_param, timer_proc); }
 
-	virtual int getPlayMask(SciVersion soundVersion) = 0;
+	virtual byte getPlayId(SciVersion soundVersion) = 0;
 	virtual int getPolyphony() const = 0;
 
 	virtual void setVolume(byte volume) {

Modified: scummvm/trunk/engines/sci/sound/softseq/pcjr.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/softseq/pcjr.cpp	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/sound/softseq/pcjr.cpp	2010-01-09 02:14:12 UTC (rev 47190)
@@ -192,18 +192,26 @@
 	_mixer->stopHandle(_mixerSoundHandle);
 }
 
-int MidiPlayer_PCJr::getPlayMask(SciVersion soundVersion) {
-	if (soundVersion == SCI_VERSION_0_EARLY)
-		return 0x10; // FIXME: Not correct
-
-	return 0x10;
+byte MidiPlayer_PCJr::getPlayId(SciVersion soundVersion) {
+	switch (soundVersion) {
+	case SCI_VERSION_0_EARLY:
+		return 0x02;
+	case SCI_VERSION_0_LATE:
+		return 0x10;
+	default:
+		return 0x13;
+	}
 }
 
-int MidiPlayer_PCSpeaker::getPlayMask(SciVersion soundVersion) {
-	if (soundVersion == SCI_VERSION_0_EARLY)
-		return 0x02;
-
-	return 0x20;
+byte MidiPlayer_PCSpeaker::getPlayId(SciVersion soundVersion) {
+	switch (soundVersion) {
+	case SCI_VERSION_0_EARLY:
+		return 0x04;
+	case SCI_VERSION_0_LATE:
+		return 0x20;
+	default:
+		return 0x12;
+	}
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/sound/softseq/pcjr.h
===================================================================
--- scummvm/trunk/engines/sci/sound/softseq/pcjr.h	2010-01-09 00:19:13 UTC (rev 47189)
+++ scummvm/trunk/engines/sci/sound/softseq/pcjr.h	2010-01-09 02:14:12 UTC (rev 47190)
@@ -68,7 +68,7 @@
 public:
 	MidiPlayer_PCJr() { _driver = new MidiDriver_PCJr(g_system->getMixer()); }
 	int open(ResourceManager *resMan) { return static_cast<MidiDriver_PCJr *>(_driver)->open(getPolyphony()); }
-	int getPlayMask(SciVersion soundVersion);
+	byte getPlayId(SciVersion soundVersion);
 	int getPolyphony() const { return 3; }
 	bool hasRhythmChannel() const { return false; }
 	void setVolume(byte volume) { static_cast<MidiDriver_PCJr *>(_driver)->_global_volume = volume; }
@@ -76,7 +76,7 @@
 
 class MidiPlayer_PCSpeaker : public MidiPlayer_PCJr {
 public:
-	int getPlayMask(SciVersion soundVersion);
+	byte getPlayId(SciVersion soundVersion);
 	int getPolyphony() const { return 1; }
 };
 


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