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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Fri Dec 25 19:59:15 CET 2009


Revision: 46563
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46563&view=rev
Author:   m_kiewitz
Date:     2009-12-25 18:59:15 +0000 (Fri, 25 Dec 2009)

Log Message:
-----------
SCI/newmusic: added filter support for kq4early and adlib

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/vm.h
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sfx/iterator/core.cpp
    scummvm/trunk/engines/sci/sfx/iterator/core.h
    scummvm/trunk/engines/sci/sfx/music.cpp
    scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp
    scummvm/trunk/engines/sci/sfx/softseq/amiga.cpp
    scummvm/trunk/engines/sci/sfx/softseq/mididriver.h
    scummvm/trunk/engines/sci/sfx/softseq/pcjr.cpp
    scummvm/trunk/engines/sci/sfx/softseq/pcjr.h

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -291,13 +291,13 @@
 }
 #endif
 
-int game_init_sound(EngineState *s, int sound_flags) {
+int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion) {
 #ifdef USE_OLD_MUSIC_FUNCTIONS
 	if (getSciVersion() > SCI_VERSION_0_LATE)
 		sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
 
 	s->sfx_init_flags = sound_flags;
-	s->_sound.sfx_init(s->resMan, sound_flags);
+	s->_sound.sfx_init(s->resMan, sound_flags, soundVersion);
 #endif
 
 	return 0;
@@ -421,7 +421,7 @@
 
 #ifdef USE_OLD_MUSIC_FUNCTIONS
 	if (s->sfx_init_flags & SFX_STATE_FLAG_NOSOUND)
-		game_init_sound(s, 0);
+		game_init_sound(s, 0, s->detectDoSoundType());
 #endif
 
 	// Load game language into printLang property of game object
@@ -437,7 +437,7 @@
 	if (!s->successor) {
 		s->_sound.sfx_exit();
 		// Reinit because some other code depends on having a valid state
-		game_init_sound(s, SFX_STATE_FLAG_NOSOUND);
+		game_init_sound(s, SFX_STATE_FLAG_NOSOUND, s->detectDoSoundType());
 	}
 #endif
 

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -903,7 +903,7 @@
 
 #ifdef USE_OLD_MUSIC_FUNCTIONS
 	temp = retval->_sound._songlib;
-	retval->_sound.sfx_init(retval->resMan, s->sfx_init_flags);
+	retval->_sound.sfx_init(retval->resMan, s->sfx_init_flags, s->detectDoSoundType());
 	retval->sfx_init_flags = s->sfx_init_flags;
 	retval->_sound._songlib.freeSounds();
 	retval->_sound._songlib = temp;

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-12-25 18:59:15 UTC (rev 46563)
@@ -492,9 +492,10 @@
  * the sound data.
  * @param[in] s				The state to initialize the sound in
  * @param[in] sound_flags	Flags to pass to the sound subsystem
+ * @param[in] soundVersion	sound-version that got detected during game init
  * @return					0 on success, 1 if an error occured
  */
-int game_init_sound(EngineState *s, int sound_flags);
+int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion);
 
 /**
  * Runs an SCI game

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/resource.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -1942,7 +1942,15 @@
 
 	switch (_soundVersion) {
 	case SCI_VERSION_0_EARLY:
-		channelMask = 0xFFFF;
+		data++; // Skip over digital sample flag
+		for (int channelNr = 0; channelNr < 16; channelNr++) {
+			channelMask = channelMask >> 1;
+			if (*data & hardwareMask) {
+				// this Channel is supposed to get played for hardware
+				channelMask |= 0x8000;
+			}
+			data++;
+		}
 		break;
 
 	case SCI_VERSION_0_LATE:

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -180,8 +180,10 @@
 	// since we cannot let the game control where saves are stored)
 	strcpy(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value, "");
 
-	_gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _audio, _gamestate->detectDoSoundType());
+	SciVersion soundVersion = _gamestate->detectDoSoundType();
 
+	_gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _audio, soundVersion);
+
 	GfxState gfx_state;
 	_gamestate->gfx_state = &gfx_state;
 
@@ -198,7 +200,7 @@
 	}
 #endif
 
-	if (game_init_sound(_gamestate, 0)) {
+	if (game_init_sound(_gamestate, 0, soundVersion)) {
 		warning("Game initialization failed: Error in sound subsystem. Aborting...");
 		return Common::kUnknownError;
 	}

Modified: scummvm/trunk/engines/sci/sfx/iterator/core.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator/core.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sfx/iterator/core.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -59,6 +59,7 @@
 	int _polyphony;
 
 protected:
+	SciVersion _soundVersion;
 	MidiPlayer *_mididrv;
 
 	SongIterator *_iterator;
@@ -77,7 +78,7 @@
 	static void player_timer_callback(void *refCon);
 
 public:
-	SfxPlayer();
+	SfxPlayer(SciVersion soundVersion);
 	~SfxPlayer();
 
 	/**
@@ -138,7 +139,8 @@
 	int getVolume();
 };
 
-SfxPlayer::SfxPlayer() {
+SfxPlayer::SfxPlayer(SciVersion soundVersion)
+	: _soundVersion(soundVersion) {
 	_polyphony = 0;
 
 	_mididrv = 0;
@@ -261,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()));
+	SIMSG_SEND(it, SIMSG_SET_PLAYMASK(_mididrv->getPlayMask(_soundVersion)));
 	SIMSG_SEND(it, SIMSG_SET_RHYTHM(_mididrv->hasRhythmChannel()));
 
 	if (_iterator == NULL) {
@@ -648,7 +650,7 @@
 
 #define DELAY (1000000 / SFX_TICKS_PER_SEC)
 
-void SfxState::sfx_init(ResourceManager *resMan, int flags) {
+void SfxState::sfx_init(ResourceManager *resMan, int flags, SciVersion soundVersion) {
 	_songlib._lib = 0;
 	_song = NULL;
 	_flags = flags;
@@ -673,7 +675,7 @@
 		return;
 	}
 
-	_player = new SfxPlayer();
+	_player = new SfxPlayer(soundVersion);
 
 	if (!_player) {
 		warning("[SFX] No song player found");

Modified: scummvm/trunk/engines/sci/sfx/iterator/core.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator/core.h	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sfx/iterator/core.h	2009-12-25 18:59:15 UTC (rev 46563)
@@ -72,7 +72,7 @@
 	** Parameters: (ResourceManager *) resMan: Resource manager for initialization
 	**             (int) flags: SFX_STATE_FLAG_*
 	*/
-	void sfx_init(ResourceManager *resMan, int flags);
+	void sfx_init(ResourceManager *resMan, int flags, SciVersion soundVersion);
 
 	/** Deinitializes the sound subsystem. */
 	void sfx_exit();

Modified: scummvm/trunk/engines/sci/sfx/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/music.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sfx/music.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -335,7 +335,7 @@
 				pSnd->pMidiParser->setTimerRate(_dwTempo);
 			}
 			// Find out what channels to filter for SCI0
-			channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayMask());
+			channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayMask(_soundVersion));
 			pSnd->pMidiParser->loadMusic(track, pSnd, channelFilterMask, _soundVersion);
 		}
 	}

Modified: scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -162,7 +162,7 @@
 public:
 	MidiPlayer_Adlib() { _driver = new MidiDriver_Adlib(g_system->getMixer()); }
 	int open(ResourceManager *resMan);
-	int getPlayMask() const { return 0x04; }
+	int getPlayMask(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); }
@@ -811,6 +811,14 @@
 	return static_cast<MidiDriver_Adlib *>(_driver)->open(getSciVersion() <= SCI_VERSION_0_LATE);
 }
 
+int MidiPlayer_Adlib::getPlayMask(SciVersion soundVersion) {
+	switch (soundVersion) {
+	case SCI_VERSION_0_EARLY:
+		return 0x10; // FIXME: Not correct
+	}
+	return 0x04;
+}
+
 MidiPlayer *MidiPlayer_Adlib_create() {
 	return new MidiPlayer_Adlib();
 }

Modified: scummvm/trunk/engines/sci/sfx/softseq/amiga.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/amiga.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sfx/softseq/amiga.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -651,7 +651,7 @@
 class MidiPlayer_Amiga : public MidiPlayer {
 public:
 	MidiPlayer_Amiga() { _driver = new MidiDriver_Amiga(g_system->getMixer()); }
-	int getPlayMask() const { return 0x40; }
+	int getPlayMask(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); }
@@ -663,4 +663,12 @@
 	return new MidiPlayer_Amiga();
 }
 
+int MidiPlayer_Amiga::getPlayMask(SciVersion soundVersion) {
+	switch (soundVersion) {
+	case SCI_VERSION_0_EARLY:
+		return 0x40; // FIXME: Not correct
+	}
+	return 0x40;
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/sfx/softseq/mididriver.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/mididriver.h	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sfx/softseq/mididriver.h	2009-12-25 18:59:15 UTC (rev 46563)
@@ -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() const = 0;
+	virtual int getPlayMask(SciVersion soundVersion) = 0;
 	virtual int getPolyphony() const = 0;
 
 	virtual void setVolume(byte volume) {

Modified: scummvm/trunk/engines/sci/sfx/softseq/pcjr.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/pcjr.cpp	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sfx/softseq/pcjr.cpp	2009-12-25 18:59:15 UTC (rev 46563)
@@ -192,4 +192,20 @@
 	_mixer->stopHandle(_mixerSoundHandle);
 }
 
+int MidiPlayer_PCJr::getPlayMask(SciVersion soundVersion) {
+	switch (soundVersion) {
+	case SCI_VERSION_0_EARLY:
+		return 0x10; // FIXME: Not correct
+	}
+	return 0x10;
+}
+
+int MidiPlayer_PCSpeaker::getPlayMask(SciVersion soundVersion) {
+	switch (soundVersion) {
+	case SCI_VERSION_0_EARLY:
+		return 0x20; // FIXME: Not correct
+	}
+	return 0x20;
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/sfx/softseq/pcjr.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/pcjr.h	2009-12-25 18:37:07 UTC (rev 46562)
+++ scummvm/trunk/engines/sci/sfx/softseq/pcjr.h	2009-12-25 18:59:15 UTC (rev 46563)
@@ -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() const { return 0x10; }
+	int getPlayMask(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() const { return 0x20; }
+	int getPlayMask(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