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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Jun 30 15:49:05 CEST 2010


Revision: 50532
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50532&view=rev
Author:   thebluegr
Date:     2010-06-30 13:49:05 +0000 (Wed, 30 Jun 2010)

Log Message:
-----------
SCI: Removed the FreeSCI music code

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kevent.cpp
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/state.h
    scummvm/trunk/engines/sci/module.mk
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h
    scummvm/trunk/engines/sci/sound/music.h
    scummvm/trunk/engines/sci/sound/soundcmd.cpp
    scummvm/trunk/engines/sci/sound/soundcmd.h

Removed Paths:
-------------
    scummvm/trunk/engines/sci/sound/iterator/

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/console.cpp	2010-06-30 13:49:05 UTC (rev 50532)
@@ -36,13 +36,8 @@
 #include "sci/engine/savegame.h"
 #include "sci/engine/gc.h"
 #include "sci/engine/features.h"
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-#include "sci/sound/iterator/songlib.h"	// for SongLibrary
-#include "sci/sound/iterator/iterator.h"	// for SCI_SONG_ITERATOR_TYPE_SCI0
-#else
 #include "sci/sound/midiparser_sci.h"
 #include "sci/sound/music.h"
-#endif
 #include "sci/sound/drivers/mididriver.h"
 #include "sci/graphics/cursor.h"
 #include "sci/graphics/screen.h"
@@ -215,19 +210,11 @@
 }
 
 void Console::preEnter() {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	if (_engine->_gamestate)
-		_engine->_gamestate->_sound.sfx_suspend(true);
-#endif
 	if (g_sci && g_sci->_soundCmd)
 		g_sci->_soundCmd->pauseAll(true);
 }
 
 void Console::postEnter() {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	if (_engine->_gamestate)
-		_engine->_gamestate->_sound.sfx_suspend(false);
-#endif
 	if (g_sci && g_sci->_soundCmd)
 		g_sci->_soundCmd->pauseAll(false);
 
@@ -846,7 +833,6 @@
 }
 
 bool Console::cmdShowInstruments(int argc, const char **argv) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	int songNumber = -1;
 
 	if (argc == 2)
@@ -1004,7 +990,6 @@
 		DebugPrintf("\n\n");
 	}
 
-#endif
 	return true;
 }
 
@@ -1647,23 +1632,7 @@
 
 bool Console::cmdSongLib(int argc, const char **argv) {
 	DebugPrintf("Song library:\n");
-
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	Song *seeker = _engine->_gamestate->_sound._songlib._lib;
-
-	do {
-		DebugPrintf("    %p", (void *)seeker);
-
-		if (seeker) {
-			DebugPrintf("[%04lx,p=%d,s=%d]->", seeker->_handle, seeker->_priority, seeker->_status);
-			seeker = seeker->_next;
-		}
-		DebugPrintf("\n");
-	} while (seeker);
-	DebugPrintf("\n");
-#else
 	g_sci->_soundCmd->printPlayList(this);
-#endif
 
 	return true;
 }
@@ -1726,19 +1695,6 @@
 		return true;
 	}
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	int handle = id.segment << 16 | id.offset;	// frobnicate handle
-
-	if (id.segment) {
-		SegManager *segMan = _engine->_gamestate->_segMan;	// for writeSelectorValue
-		_engine->_gamestate->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
-		_engine->_gamestate->_sound.sfx_remove_song(handle);
-		writeSelectorValue(segMan, id, SELECTOR(signal), SIGNAL_OFFSET);
-		writeSelectorValue(segMan, id, SELECTOR(nodePtr), 0);
-		writeSelectorValue(segMan, id, SELECTOR(handle), 0);
-	}
-#else
-
 	Common::String newState = argv[2];
 	newState.toLowercase();
 
@@ -1748,15 +1704,12 @@
 		g_sci->_soundCmd->stopSound(id);
 	else
 		DebugPrintf("New state can either be 'play' or 'stop'");
-#endif
 
 	return true;
 }
 
 bool Console::cmdStopAllSounds(int argc, const char **argv) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	g_sci->_soundCmd->stopAllSounds();
-#endif
 
 	DebugPrintf("All sounds have been stopped\n");
 	return true;
@@ -1770,36 +1723,6 @@
 		return true;
 	}
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	Resource *song = _engine->getResMan()->findResource(ResourceId(kResourceTypeSound, atoi(argv[1])), 0);
-	SongIterator *songit;
-	Audio::AudioStream *data;
-
-	if (!song) {
-		DebugPrintf("Not a sound resource!\n");
-		return true;
-	}
-
-	songit = songit_new(song->data, song->size, SCI_SONG_ITERATOR_TYPE_SCI0, 0xcaffe /* What do I care about the ID? */);
-
-	if (!songit) {
-		DebugPrintf("Could not convert to song iterator!\n");
-		return true;
-	}
-
-	data = songit->getAudioStream();
-	if (data) {
-		// TODO
-/*
-		DebugPrintf("\nIs sample (encoding %dHz/%s/%04x)", data->conf.rate, (data->conf.stereo) ?
-		          ((data->conf.stereo == SFX_PCM_STEREO_LR) ? "stereo-LR" : "stereo-RL") : "mono", data->conf.format);
-*/
-		delete data;
-	} else
-		DebugPrintf("Valid song, but not a sample.\n");
-
-	delete songit;
-#else
 	int16 number = atoi(argv[1]);
 
 	if (!_engine->getResMan()->testResource(ResourceId(kResourceTypeSound, number))) {
@@ -1823,7 +1746,6 @@
 
 	DebugPrintf("Sample size: %d, sample rate: %d, channels: %d, digital channel number: %d\n",
 			track->digitalSampleSize, track->digitalSampleRate, track->channelCount, track->digitalChannelNr);
-#endif
 
 	return true;
 }

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2010-06-30 13:49:05 UTC (rev 50532)
@@ -32,7 +32,6 @@
 #include "common/str-array.h"
 
 #include "sci/engine/selector.h"
-#include "sci/sci.h"	// for USE_OLD_MUSIC_FUNCTIONS
 #include "sci/engine/vm_types.h"	// for reg_t
 #include "sci/engine/vm.h"
 
@@ -268,17 +267,6 @@
 	const Common::String _invalid;
 };
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-/******************** Misc functions ********************/
-
-/**
- * Get all sound events, apply their changes to the heap.
- */
-void process_sound_events(EngineState *s);
-
-/******************** Constants ********************/
-#endif
-
 /* Maximum length of a savegame name (including terminator character). */
 #define SCI_MAX_SAVENAME_LENGTH 0x24
 

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2010-06-30 13:49:05 UTC (rev 50532)
@@ -149,7 +149,6 @@
 		con->onFrame();
 	}
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	if (g_sci->_features->detectDoSoundType() <= SCI_VERSION_0_LATE) {
 		// If we're running a SCI0 game, update the sound cues, to compensate
 		// for the fact that SCI0 does not poll to update the sound cues itself,
@@ -158,7 +157,6 @@
 		// this call
 		g_sci->_soundCmd->updateSci0Cues();
 	}
-#endif
 
 	return s->r_acc;
 }

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2010-06-30 13:49:05 UTC (rev 50532)
@@ -1080,10 +1080,6 @@
 	reg_t castListReference = (argc > 0) ? argv[0] : NULL_REG;
 	bool cycle = (argc > 1) ? ((argv[1].toUint16()) ? true : false) : false;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	// Take care of incoming events (kAnimate is called semi-regularly)
-	process_sound_events(s);
-#endif
 	g_sci->_gfxAnimate->kernelAnimate(castListReference, cycle, argc, argv);
 
 	return s->r_acc;

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2010-06-30 13:49:05 UTC (rev 50532)
@@ -42,12 +42,7 @@
 #include "sci/engine/script.h"	// for SCI_OBJ_EXPORTS and SCI_OBJ_SYNONYMS
 #include "sci/graphics/ports.h"
 #include "sci/sound/audio.h"
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-#include "sci/sound/iterator/core.h"
-#include "sci/sound/iterator/iterator.h"
-#else
 #include "sci/sound/music.h"
-#endif
 
 #include "gui/message.h"
 
@@ -61,40 +56,11 @@
 const uint32 INTMAPPER_MAGIC_KEY = 0xDEADBEEF;
 
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-// from ksound.cpp:
-SongIterator *build_iterator(ResourceManager *resMan, int song_nr, SongIteratorType type, songit_id_t id);
-#endif
-
-
 #pragma mark -
 
 // TODO: Many of the following sync_*() methods should be turned into member funcs
 // of the classes they are syncing.
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-static void sync_songlib(Common::Serializer &s, SongLibrary &obj);
-
-static void syncSong(Common::Serializer &s, Song &obj) {
-	s.syncAsSint32LE(obj._handle);
-	s.syncAsSint32LE(obj._resourceNum);
-	s.syncAsSint32LE(obj._priority);
-	s.syncAsSint32LE(obj._status);
-	s.syncAsSint32LE(obj._restoreBehavior);
-	s.syncAsSint32LE(obj._restoreTime);
-	s.syncAsSint32LE(obj._loops);
-	s.syncAsSint32LE(obj._hold);
-
-	if (s.isLoading()) {
-		obj._it = 0;
-		obj._delay = 0;
-		obj._next = 0;
-		obj._nextPlaying = 0;
-		obj._nextStopping = 0;
-	}
-}
-#else
-
 #define DEFROBNICATE_HANDLE(handle) (make_reg((handle >> 16) & 0xffff, handle & 0xffff))
 
 void MusicEntry::saveLoadWithSerializer(Common::Serializer &s) {
@@ -148,7 +114,6 @@
 		pStreamAud = 0;
 	}
 }
-#endif
 
 // Experimental hack: Use syncWithSerializer to sync. By default, this assume
 // the object to be synced is a subclass of Serializable and thus tries to invoke
@@ -380,11 +345,7 @@
 
 	syncArray<Class>(s, _segMan->_classTable);
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	sync_songlib(s, _sound._songlib);
-#else
 	g_sci->_soundCmd->syncPlayList(s);
-#endif
 }
 
 void LocalVariables::saveLoadWithSerializer(Common::Serializer &s) {
@@ -620,30 +581,6 @@
 
 #pragma mark -
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-static void sync_songlib(Common::Serializer &s, SongLibrary &obj) {
-	int songcount = 0;
-	if (s.isSaving())
-		songcount = obj.countSongs();
-	s.syncAsUint32LE(songcount);
-
-	if (s.isLoading()) {
-		obj._lib = 0;
-		while (songcount--) {
-			Song *newsong = new Song;
-			syncSong(s, *newsong);
-			obj.addSong(newsong);
-		}
-	} else {
-		Song *seeker = obj._lib;
-		while (seeker) {
-			seeker->_restoreTime = seeker->_it->getTimepos();
-			syncSong(s, *seeker);
-			seeker = seeker->_next;
-		}
-	}
-}
-#else
 void SciMusic::saveLoadWithSerializer(Common::Serializer &s) {
 	// Sync song lib data. When loading, the actual song lib will be initialized
 	// afterwards in gamestate_restore()
@@ -692,16 +629,12 @@
 		}
 	}
 }
-#endif
 
 void SoundCommandParser::syncPlayList(Common::Serializer &s) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	_music->saveLoadWithSerializer(s);
-#endif
 }
 
 void SoundCommandParser::reconstructPlayList(int savegame_version) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	Common::StackLock lock(_music->_mutex);
 
 	const MusicList::iterator end = _music->getPlayListEnd();
@@ -724,8 +657,6 @@
 			cmdPlaySound((*i)->soundObj, 0);
 		}
 	}
-
-#endif
 }
 
 #ifdef ENABLE_SCI32
@@ -819,43 +750,7 @@
 	}	// end for
 }
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-static void reconstruct_sounds(EngineState *s) {
-	Song *seeker;
-	SongIteratorType it_type;
 
-	if (getSciVersion() > SCI_VERSION_01)
-		it_type = SCI_SONG_ITERATOR_TYPE_SCI1;
-	else
-		it_type = SCI_SONG_ITERATOR_TYPE_SCI0;
-
-	seeker = s->_sound._songlib._lib;
-
-	while (seeker) {
-		SongIterator *base, *ff = 0;
-		int oldstatus;
-		SongIterator::Message msg;
-
-		base = ff = build_iterator(g_sci->getResMan(), seeker->_resourceNum, it_type, seeker->_handle);
-		if (seeker->_restoreBehavior == RESTORE_BEHAVIOR_CONTINUE)
-			ff = new_fast_forward_iterator(base, seeker->_restoreTime);
-		ff->init();
-
-		msg = SongIterator::Message(seeker->_handle, SIMSG_SET_LOOPS(seeker->_loops));
-		songit_handle_message(&ff, msg);
-		msg = SongIterator::Message(seeker->_handle, SIMSG_SET_HOLD(seeker->_hold));
-		songit_handle_message(&ff, msg);
-
-		oldstatus = seeker->_status;
-		seeker->_status = SOUND_STATUS_STOPPED;
-		seeker->_it = ff;
-		s->_sound.sfx_song_set_status(seeker->_handle, oldstatus);
-		seeker = seeker->_next;
-	}
-}
-#endif
-
-
 #pragma mark -
 
 
@@ -888,10 +783,6 @@
 }
 
 void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	SongLibrary temp;
-#endif
-
 	SavegameMetadata meta;
 
 	Common::Serializer ser(fh, 0);
@@ -943,21 +834,8 @@
 	s->reset(true);
 	s->saveLoadWithSerializer(ser);	// FIXME: Error handling?
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	s->_sound.sfx_exit();
-#endif
-
 	// Now copy all current state information
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	temp = s->_sound._songlib;
-	s->_sound.sfx_init(g_sci->getResMan(), s->sfx_init_flags, g_sci->_features->detectDoSoundType());
-	s->sfx_init_flags = s->sfx_init_flags;
-	s->_sound._songlib.freeSounds();
-	s->_sound._songlib = temp;
-	s->_soundCmd->updateSfxState(&s->_sound);
-#endif
-
 	s->_segMan->reconstructStack(s);
 	s->_segMan->reconstructScripts(s);
 	s->_segMan->reconstructClones();
@@ -969,15 +847,7 @@
 	s->gameStartTime = g_system->getMillis();
 	s->_screenUpdateTime = g_system->getMillis();
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	s->_sound._it = NULL;
-	s->_sound._flags = s->_sound._flags;
-	s->_sound._song = NULL;
-	s->_sound._suspended = s->_sound._suspended;
-	reconstruct_sounds(s);
-#else
 	g_sci->_soundCmd->reconstructPlayList(meta.savegame_version);
-#endif
 
 	// Message state:
 	s->_msgState = new MessageState(s->_segMan);

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2010-06-30 13:49:05 UTC (rev 50532)
@@ -81,10 +81,6 @@
 }
 
 void EngineState::reset(bool isRestoring) {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	sfx_init_flags = 0;
-#endif
-
 	if (!isRestoring) {
 		_memorySegmentSize = 0;
 

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/engine/state.h	2010-06-30 13:49:05 UTC (rev 50532)
@@ -41,9 +41,6 @@
 
 #include "sci/parser/vocabulary.h"
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-#include "sci/sound/iterator/core.h"
-#endif
 #include "sci/sound/soundcmd.h"
 
 namespace Sci {
@@ -105,11 +102,6 @@
 
 	/* Non-VM information */
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	SfxState _sound; /**< sound subsystem */
-	int sfx_init_flags; /**< flags the sfx subsystem was initialised with */
-#endif
-
 	uint32 gameStartTime; /**< The time at which the interpreter was started */
 	uint32 lastWaitTime; /**< The last time the game invoked Wait() */
 	uint32 _screenUpdateTime;	/**< The last time the game updated the screen */

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/module.mk	2010-06-30 13:49:05 UTC (rev 50532)
@@ -67,9 +67,6 @@
 	sound/drivers/fb01.o \
 	sound/drivers/midi.o \
 	sound/drivers/pcjr.o \
-	sound/iterator/core.o \
-	sound/iterator/iterator.o \
-	sound/iterator/songlib.o \
 	video/seq_decoder.o
 	
 	

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/sci.cpp	2010-06-30 13:49:05 UTC (rev 50532)
@@ -222,10 +222,6 @@
 	_kernel->loadKernelNames(_features);
 	_soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, _features->detectDoSoundType());
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	initGameSound(0, _features->detectDoSoundType());
-#endif
-
 	syncSoundSettings();
 
 	// Initialize all graphics related subsystems
@@ -313,11 +309,6 @@
 
 	srand(g_system->getMillis()); // Initialize random number generator
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	if (_gamestate->sfx_init_flags & SFX_STATE_FLAG_NOSOUND)
-		initGameSound(0, _features->detectDoSoundType());
-#endif
-
 	// Load game language into printLang property of game object
 	setSciLanguage();
 
@@ -399,18 +390,6 @@
 	_gfxPalette->setDefault();
 }
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-
-void SciEngine::initGameSound(int sound_flags, SciVersion soundVersion) {
-	if (getSciVersion() > SCI_VERSION_0_LATE)
-	 sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
-
-	_gamestate->sfx_init_flags = sound_flags;
-	_gamestate->_sound.sfx_init(_resMan, sound_flags, soundVersion);
-}
-
-#endif
-
 void SciEngine::initStackBaseWithSelector(Selector selector) {
 	_gamestate->stack_base[0] = make_reg(0, (uint16)selector);
 	_gamestate->stack_base[1] = NULL_REG;
@@ -438,9 +417,6 @@
 		if (_gamestate->abortScriptProcessing == kAbortRestartGame) {
 			_gamestate->_segMan->resetSegMan();
 			initGame();
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-			_gamestate->_sound.sfx_reset_player();
-#endif
 			initStackBaseWithSelector(SELECTOR(play));
 			_gamestate->gameWasRestarted = true;
 		} else if (_gamestate->abortScriptProcessing == kAbortLoadGame) {
@@ -455,14 +431,8 @@
 void SciEngine::exitGame() {
 	if (_gamestate->abortScriptProcessing != kAbortLoadGame) {
 		_gamestate->_executionStack.clear();
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-		_gamestate->_sound.sfx_exit();
-		// Reinit because some other code depends on having a valid state
-		initGameSound(SFX_STATE_FLAG_NOSOUND, _features->detectDoSoundType());
-#else
 		_audio->stopAllAudio();
 		g_sci->_soundCmd->clearPlayList();
-#endif
 	}
 
 	// TODO Free parser segment here
@@ -544,16 +514,12 @@
 }
 
 void SciEngine::pauseEngineIntern(bool pause) {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	_gamestate->_sound.sfx_suspend(pause);
-#endif
 	_mixer->pauseAll(pause);
 }
 
 void SciEngine::syncSoundSettings() {
 	Engine::syncSoundSettings();
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	bool mute = false;
 	if (ConfMan.hasKey("mute"))
 		mute = ConfMan.getBool("mute");
@@ -564,7 +530,6 @@
 		int vol =  (soundVolumeMusic + 1) * SoundCommandParser::kMaxSciVolume / Audio::Mixer::kMaxMixerVolume;
 		g_sci->_soundCmd->setMasterVolume(vol);
 	}
-#endif
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/sci.h	2010-06-30 13:49:05 UTC (rev 50532)
@@ -42,9 +42,6 @@
  */
 namespace Sci {
 
-// Uncomment this to use old music functions
-//#define USE_OLD_MUSIC_FUNCTIONS
-
 struct EngineState;
 class Vocabulary;
 class ResourceManager;
@@ -321,18 +318,6 @@
 	 */
 	void exitGame();
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	/**
-	 * Initializes the sound part of a SCI game
-	 * This function may only be called if game_init() did not initialize
-	 * 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
-	 */
-	void initGameSound(int sound_flags, SciVersion soundVersion);
-#endif
-
 	void initStackBaseWithSelector(Selector selector);
 
 	const ADGameDescription *_gameDescription;

Modified: scummvm/trunk/engines/sci/sound/music.h
===================================================================
--- scummvm/trunk/engines/sci/sound/music.h	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/sound/music.h	2010-06-30 13:49:05 UTC (rev 50532)
@@ -26,15 +26,11 @@
 #ifndef SCI_MUSIC_H
 #define SCI_MUSIC_H
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 #include "common/serializer.h"
-#endif
 #include "common/mutex.h"
 
 #include "sound/mixer.h"
 #include "sound/audiostream.h"
-//#include "sound/mididrv.h"
-//#include "sound/midiparser.h"
 
 #include "sci/sci.h"
 #include "sci/resource.h"
@@ -55,11 +51,7 @@
 class MidiParser_SCI;
 class SegManager;
 
-class MusicEntry
-#ifndef USE_OLD_MUSIC_FUNCTIONS
-	: public Common::Serializable
-#endif
-{
+class MusicEntry : public Common::Serializable {
 public:
 	// Do not get these directly for the sound objects!
 	// It's a bad idea, as the sound code (i.e. the SciMusic
@@ -96,9 +88,6 @@
 
 	Audio::Mixer::SoundType soundType;
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
-//protected:
-#endif
 	MidiParser_SCI *pMidiParser;
 
 	// TODO: We need to revise how we store the different
@@ -114,19 +103,13 @@
 	void doFade();
 	void onTimer();
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	virtual void saveLoadWithSerializer(Common::Serializer &ser);
-#endif
 };
 
 typedef Common::Array<MusicEntry *> MusicList;
 typedef Common::Array<uint32> MidiCommandQueue;
 
-class SciMusic
-#ifndef USE_OLD_MUSIC_FUNCTIONS
-	: public Common::Serializable
-#endif
-{
+class SciMusic : public Common::Serializable {
 
 public:
 	SciMusic(SciVersion soundVersion);
@@ -193,9 +176,7 @@
 
 	void setReverb(byte reverb);
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	virtual void saveLoadWithSerializer(Common::Serializer &ser);
-#endif
 
 	// Mutex for music code. Used to guard access to the song playlist, to the
 	// MIDI parser and to the MIDI driver/player. Note that guarded code must NOT

Modified: scummvm/trunk/engines/sci/sound/soundcmd.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/soundcmd.cpp	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/sound/soundcmd.cpp	2010-06-30 13:49:05 UTC (rev 50532)
@@ -23,12 +23,6 @@
  *
  */
 
-#include "sci/sci.h"	// for USE_OLD_MUSIC_FUNCTIONS
-
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-#include "sci/sound/iterator/iterator.h"	// for SongIteratorStatus
-#endif
-
 #include "common/config-manager.h"
 #include "sci/sound/audio.h"
 #include "sci/sound/music.h"
@@ -42,108 +36,14 @@
 #define SCI1_SOUND_FLAG_MAY_PAUSE        1 /* Only here for completeness; The interpreter doesn't touch this bit */
 #define SCI1_SOUND_FLAG_SCRIPTED_PRI     2 /* but does touch this */
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-#define FROBNICATE_HANDLE(reg) ((reg).segment << 16 | (reg).offset)
-#define DEFROBNICATE_HANDLE(handle) (make_reg((handle >> 16) & 0xffff, handle & 0xffff))
-#endif
-
 #define SOUNDCOMMAND(x) _soundCommands.push_back(new MusicEntryCommand(#x, &SoundCommandParser::x))
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-static void script_set_priority(ResourceManager *resMan, SegManager *segMan, SfxState *state, reg_t obj, int priority) {
-	int song_nr = readSelectorValue(segMan, obj, SELECTOR(number));
-	Resource *song = resMan->findResource(ResourceId(kResourceTypeSound, song_nr), 0);
-	int flags = readSelectorValue(segMan, obj, SELECTOR(flags));
-
-	if (priority == -1) {
-		if (song->data[0] == 0xf0)
-			priority = song->data[1];
-		else
-			warning("Attempt to unset song priority when there is no built-in value");
-
-		flags &= ~SCI1_SOUND_FLAG_SCRIPTED_PRI;
-	} else flags |= SCI1_SOUND_FLAG_SCRIPTED_PRI;
-
-	state->sfx_song_renice(FROBNICATE_HANDLE(obj), priority);
-	writeSelectorValue(segMan, obj, SELECTOR(flags), flags);
-}
-
-SongIterator *build_iterator(ResourceManager *resMan, int song_nr, SongIteratorType type, songit_id_t id) {
-	Resource *song = resMan->findResource(ResourceId(kResourceTypeSound, song_nr), 0);
-
-	if (!song)
-		return NULL;
-
-	return songit_new(song->data, song->size, type, id);
-}
-
-void process_sound_events(EngineState *s) { /* Get all sound events, apply their changes to the heap */
-	int result;
-	SongHandle handle;
-	int cue;
-	SegManager *segMan = s->_segMan;
-
-	if (getSciVersion() > SCI_VERSION_01)
-		return;
-	// SCI1 and later explicitly poll for everything
-
-	while ((result = s->_sound.sfx_poll(&handle, &cue))) {
-		reg_t obj = DEFROBNICATE_HANDLE(handle);
-		if (!s->_segMan->isObject(obj)) {
-			warning("Non-object %04x:%04x received sound signal (%d/%d)", PRINT_REG(obj), result, cue);
-			return;
-		}
-
-		switch (result) {
-
-		case SI_LOOP:
-			debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x looped (to %d)",
-			          PRINT_REG(obj), cue);
-			/*			writeSelectorValue(segMan, obj, SELECTOR(loops), readSelectorValue(segMan, obj, SELECTOR(loop));; - 1);*/
-			writeSelectorValue(segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
-			break;
-
-		case SI_RELATIVE_CUE:
-			debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received relative cue %d",
-			          PRINT_REG(obj), cue);
-			writeSelectorValue(segMan, obj, SELECTOR(signal), cue + 0x7f);
-			break;
-
-		case SI_ABSOLUTE_CUE:
-			debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received absolute cue %d",
-			          PRINT_REG(obj), cue);
-			writeSelectorValue(segMan, obj, SELECTOR(signal), cue);
-			break;
-
-		case SI_FINISHED:
-			debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x finished",
-			          PRINT_REG(obj));
-			writeSelectorValue(segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
-			writeSelectorValue(segMan, obj, SELECTOR(state), kSoundStopped);
-			break;
-
-		default:
-			warning("Unexpected result from sfx_poll: %d", result);
-			break;
-		}
-	}
-}
-
-#endif
 SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, AudioPlayer *audio, SciVersion soundVersion) :
 	_resMan(resMan), _segMan(segMan), _kernel(kernel), _audio(audio), _soundVersion(soundVersion) {
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	// The following hack is needed to ease the change from old to new sound
-	// code (because the new sound code does not use SfxState)
-	_state = &g_sci->getEngineState()->_sound;	// HACK
-#endif
+	_music = new SciMusic(_soundVersion);
+	_music->init();
 
-	#ifndef USE_OLD_MUSIC_FUNCTIONS
-		_music = new SciMusic(_soundVersion);
-		_music->init();
-	#endif
-
 	switch (_soundVersion) {
 	case SCI_VERSION_0_EARLY:
 	case SCI_VERSION_0_LATE:
@@ -215,9 +115,7 @@
 	for (SoundCommandContainer::iterator i = _soundCommands.begin(); i != _soundCommands.end(); ++i)
 		delete *i;
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	delete _music;
-#endif
 }
 
 reg_t SoundCommandParser::parseCommand(int argc, reg_t *argv, reg_t acc) {
@@ -261,40 +159,6 @@
 
 	int resourceId = readSelectorValue(_segMan, obj, SELECTOR(number));
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-
-	SongHandle handle = FROBNICATE_HANDLE(obj);
-
-	if (_soundVersion != SCI_VERSION_1_LATE) {
-		if (!obj.segment)
-			return;
-	}
-
-	SongIteratorType type = (_soundVersion <= SCI_VERSION_0_LATE) ? SCI_SONG_ITERATOR_TYPE_SCI0 : SCI_SONG_ITERATOR_TYPE_SCI1;
-
-	if (_soundVersion <= SCI_VERSION_0_LATE) {
-		if (readSelectorValue(_segMan, obj, SELECTOR(nodePtr))) {
-			_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
-			_state->sfx_remove_song(handle);
-		}
-	}
-
-	if (!obj.segment || !_resMan->testResource(ResourceId(kResourceTypeSound, resourceId)))
-		return;
-
-	_state->sfx_add_song(build_iterator(_resMan, resourceId, type, handle), 0, handle, resourceId);
-
-
-	// Notify the engine
-	if (_soundVersion <= SCI_VERSION_0_LATE)
-		writeSelectorValue(_segMan, obj, SELECTOR(state), kSoundInitialized);
-	else
-		writeSelector(_segMan, obj, SELECTOR(nodePtr), obj);
-
-	writeSelector(_segMan, obj, SELECTOR(handle), obj);
-
-#else
-
 	// Check if a track with the same sound object is already playing
 	MusicEntry *oldSound = _music->getSlot(obj);
 	if (oldSound)
@@ -342,84 +206,12 @@
 
 		writeSelector(_segMan, obj, SELECTOR(handle), obj);
 	}
-#endif
-
 }
 
 void SoundCommandParser::cmdPlaySound(reg_t obj, int16 value) {
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	SongHandle handle = FROBNICATE_HANDLE(obj);
-
-	if (_soundVersion <= SCI_VERSION_0_LATE) {
-		_state->sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
-		_state->sfx_song_set_loops(handle, readSelectorValue(_segMan, obj, SELECTOR(loop)));
-		writeSelectorValue(_segMan, obj, SELECTOR(state), kSoundPlaying);
-	} else if (_soundVersion == SCI_VERSION_1_EARLY) {
-		_state->sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
-		_state->sfx_song_set_loops(handle, readSelectorValue(_segMan, obj, SELECTOR(loop)));
-		_state->sfx_song_renice(handle, readSelectorValue(_segMan, obj, SELECTOR(pri)));
-		RESTORE_BEHAVIOR rb = (RESTORE_BEHAVIOR) value;		/* Too lazy to look up a default value for this */
-		_state->_songlib.setSongRestoreBehavior(handle, rb);
-		writeSelectorValue(_segMan, obj, SELECTOR(signal), 0);
-	} else if (_soundVersion == SCI_VERSION_1_LATE) {
-		int looping = readSelectorValue(_segMan, obj, SELECTOR(loop));
-		//int vol = readSelectorValue(_segMan, obj, SELECTOR(vol));
-		int pri = readSelectorValue(_segMan, obj, SELECTOR(pri));
-		int sampleLen = 0;
-		Song *song = _state->_songlib.findSong(handle);
-		int songNumber = readSelectorValue(_segMan, obj, SELECTOR(number));
-
-		if (readSelectorValue(_segMan, obj, SELECTOR(nodePtr)) && (song && songNumber != song->_resourceNum)) {
-			_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
-			_state->sfx_remove_song(handle);
-			writeSelector(_segMan, obj, SELECTOR(nodePtr), NULL_REG);
-		}
-
-		if (!readSelectorValue(_segMan, obj, SELECTOR(nodePtr)) && obj.segment) {
-			// In SCI1.1 games, sound effects are started from here. If we can
-			// find a relevant audio resource, play it, otherwise switch to
-			// synthesized effects. If the resource exists, play it using map
-			// 65535 (sound effects map).
-			if (_resMan->testResource(ResourceId(kResourceTypeAudio, songNumber)) &&
-				getSciVersion() >= SCI_VERSION_1_1) {
-				// Found a relevant audio resource, play it
-				_audio->stopAudio();
-				warning("Initializing audio resource instead of requested sound resource %d", songNumber);
-				sampleLen = _audio->startAudio(65535, songNumber);
-				// Also create iterator, that will fire SI_FINISHED event, when
-				// the sound is done playing.
-				_state->sfx_add_song(new_timer_iterator(sampleLen), 0, handle, songNumber);
-			} else {
-				if (!_resMan->testResource(ResourceId(kResourceTypeSound, songNumber))) {
-					warning("Could not open song number %d", songNumber);
-					// Send a "stop handle" event so that the engine won't wait
-					// forever here.
-					_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
-					writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
-					return;
-				}
-				debugC(2, kDebugLevelSound, "Initializing song number %d", songNumber);
-				_state->sfx_add_song(build_iterator(_resMan, songNumber, SCI_SONG_ITERATOR_TYPE_SCI1,
-				                          handle), 0, handle, songNumber);
-			}
-
-			writeSelector(_segMan, obj, SELECTOR(nodePtr), obj);
-			writeSelector(_segMan, obj, SELECTOR(handle), obj);
-		}
-
-		if (obj.segment) {
-			_state->sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
-			_state->sfx_song_set_loops(handle, looping);
-			_state->sfx_song_renice(handle, pri);
-			writeSelectorValue(_segMan, obj, SELECTOR(signal), 0);
-		}
-	}
-
-#else
-
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdPlaySound: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -456,43 +248,16 @@
 			musicSlot->loop, musicSlot->priority, musicSlot->volume);
 
 	_music->soundPlay(musicSlot);
-
-#endif
-
 }
 
 void SoundCommandParser::cmdDummy(reg_t obj, int16 value) {
 	warning("cmdDummy invoked");	// not supposed to occur
 }
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-void SoundCommandParser::changeSoundStatus(reg_t obj, int newStatus) {
-	SongHandle handle = FROBNICATE_HANDLE(obj);
-	if (obj.segment) {
-		_state->sfx_song_set_status(handle, newStatus);
-		if (_soundVersion <= SCI_VERSION_0_LATE)
-			writeSelectorValue(_segMan, obj, SELECTOR(state), newStatus);
-	}
-}
-#endif
-
 void SoundCommandParser::cmdDisposeSound(reg_t obj, int16 value) {
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	SongHandle handle = FROBNICATE_HANDLE(obj);
-	changeSoundStatus(obj, SOUND_STATUS_STOPPED);
-
-	if (obj.segment) {
-		_state->sfx_remove_song(handle);
-
-		if (_soundVersion <= SCI_VERSION_0_LATE)
-			writeSelectorValue(_segMan, obj, SELECTOR(handle), 0x0000);
-	}
-
-#else
-
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdDisposeSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -507,7 +272,6 @@
 		writeSelector(_segMan, obj, SELECTOR(nodePtr), NULL_REG);
 	else
 		writeSelectorValue(_segMan, obj, SELECTOR(state), kSoundStopped);
-#endif
 }
 
 void SoundCommandParser::cmdStopSound(reg_t obj, int16 value) {
@@ -518,12 +282,6 @@
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	changeSoundStatus(obj, SOUND_STATUS_STOPPED);
-
-	if (_soundVersion >= SCI_VERSION_1_EARLY)
-		writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdStopSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -549,20 +307,9 @@
 	musicSlot->dataInc = 0;
 	musicSlot->signal = 0;
 	_music->soundStop(musicSlot);
-#endif
 }
 
 void SoundCommandParser::cmdPauseSound(reg_t obj, int16 value) {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	if (!obj.segment)
-		return;
-
-	if (_soundVersion <= SCI_VERSION_0_LATE)
-		changeSoundStatus(obj, SOUND_STATUS_SUSPENDED);
-	else
-		changeSoundStatus(obj, value ? SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING);
-#else
-
 	if (!obj.segment) {		// pause the whole playlist
 		// Pausing/Resuming the whole playlist was introduced in the SCI1 late
 		// sound scheme.
@@ -585,8 +332,6 @@
 			_music->soundToggle(musicSlot, value);
 		}
 	}
-
-#endif
 }
 
 void SoundCommandParser::cmdResumeSound(reg_t obj, int16 value) {
@@ -595,9 +340,6 @@
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	changeSoundStatus(obj, SOUND_STATUS_PLAYING);
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdResumeSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -606,24 +348,15 @@
 
 	writeSelectorValue(_segMan, musicSlot->soundObj, SELECTOR(state), kSoundPlaying);
 	_music->soundResume(musicSlot);
-#endif
 }
 
 void SoundCommandParser::cmdMuteSound(reg_t obj, int16 value) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	if (_argc > 1)	// the first parameter is the sound command
 		_music->soundSetSoundOn(obj.toUint16());
 	_acc = make_reg(0, _music->soundGetSoundOn());
-#endif
 }
 
 void SoundCommandParser::cmdMasterVolume(reg_t obj, int16 value) {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	_acc = make_reg(0, _state->sfx_getVolume());
-
-	if (obj != SIGNAL_REG)
-		_state->sfx_setVolume(obj.toSint16());
-#else
 	debugC(2, kDebugLevelSound, "cmdMasterVolume: %d", value);
 	_acc = make_reg(0, _music->soundGetMasterVolume());
 
@@ -634,44 +367,12 @@
 		ConfMan.setInt("sfx_volume", vol);
 		g_engine->syncSoundSettings();
 	}
-#endif
 }
 
 void SoundCommandParser::cmdFadeSound(reg_t obj, int16 value) {
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	SongHandle handle = FROBNICATE_HANDLE(obj);
-	if (_soundVersion != SCI_VERSION_1_LATE) {
-		/* FIXME: The next couple of lines actually STOP the handle, rather
-		** than fading it! */
-		_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
-		if (_soundVersion <= SCI_VERSION_0_LATE)
-			writeSelectorValue(_segMan, obj, SELECTOR(state), SOUND_STATUS_STOPPED);
-		writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
-	} else {
-		fade_params_t fade;
-		fade.final_volume = _argv[2].toUint16();
-		fade.ticks_per_step = _argv[3].toUint16();
-		fade.step_size = _argv[4].toUint16();
-		fade.action = _argv[5].toUint16() ?
-		              FADE_ACTION_FADE_AND_STOP :
-		              FADE_ACTION_FADE_AND_CONT;
-
-		_state->sfx_song_set_fade(handle,  &fade);
-
-		/* FIXME: The next couple of lines actually STOP the handle, rather
-		** than fading it! */
-		if (_argv[5].toUint16()) {
-			writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
-			_state->sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
-		} else {
-			// FIXME: Support fade-and-continue. For now, send signal right away.
-			writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
-		}
-	}
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdFadeSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -711,28 +412,16 @@
 	}
 
 	debugC(2, kDebugLevelSound, "cmdFadeSound: to %d, step %d, ticker %d", musicSlot->fadeTo, musicSlot->fadeStep, musicSlot->fadeTickerStep);
-#endif
 }
 
 void SoundCommandParser::cmdGetPolyphony(reg_t obj, int16 value) {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	_acc = make_reg(0, _state->sfx_get_player_polyphony());
-#else
 	_acc = make_reg(0, _music->soundGetVoices());	// Get the number of voices
-#endif
 }
 
 void SoundCommandParser::cmdUpdateSound(reg_t obj, int16 value) {
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	SongHandle handle = FROBNICATE_HANDLE(obj);
-	if (_soundVersion <= SCI_VERSION_0_LATE && obj.segment) {
-		_state->sfx_song_set_loops(handle, readSelectorValue(_segMan, obj, SELECTOR(loop)));
-		script_set_priority(_resMan, _segMan, _state, obj, readSelectorValue(_segMan, obj, SELECTOR(pri)));
-	}
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdUpdateSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -746,85 +435,12 @@
 	uint32 objPrio = readSelectorValue(_segMan, obj, SELECTOR(pri));
 	if (objPrio != musicSlot->priority)
 		_music->soundSetPriority(musicSlot, objPrio);
-
-#endif
 }
 
 void SoundCommandParser::cmdUpdateCues(reg_t obj, int16 value) {
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	int signal = 0;
-	int min = 0;
-	int sec = 0;
-	int frame = 0;
-	int result = SI_LOOP; // small hack
-	SongHandle handle = FROBNICATE_HANDLE(obj);
-
-	while (result == SI_LOOP)
-		result = _state->sfx_poll_specific(handle, &signal);
-
-	switch (result) {
-	case SI_ABSOLUTE_CUE:
-		debugC(2, kDebugLevelSound, "---    [CUE] %04x:%04x Absolute Cue: %d",
-		          PRINT_REG(obj), signal);
-		debugC(2, kDebugLevelSound, "abs-signal %04X", signal);
-		writeSelectorValue(_segMan, obj, SELECTOR(signal), signal);
-		break;
-
-	case SI_RELATIVE_CUE:
-		debugC(2, kDebugLevelSound, "---    [CUE] %04x:%04x Relative Cue: %d",
-		          PRINT_REG(obj), signal);
-
-		/* FIXME to match commented-out semantics
-		 * below, with proper storage of dataInc and
-		 * signal in the iterator code. */
-		writeSelectorValue(_segMan, obj, SELECTOR(dataInc), signal);
-		debugC(2, kDebugLevelSound, "rel-signal %04X", signal);
-		if (_soundVersion == SCI_VERSION_1_EARLY)
-			writeSelectorValue(_segMan, obj, SELECTOR(signal), signal);
-		else
-			writeSelectorValue(_segMan, obj, SELECTOR(signal), signal + 127);
-		break;
-
-	case SI_FINISHED:
-		debugC(2, kDebugLevelSound, "---    [FINISHED] %04x:%04x", PRINT_REG(obj));
-		writeSelectorValue(_segMan, obj, SELECTOR(signal), SIGNAL_OFFSET);
-		break;
-
-	case SI_LOOP:
-		break; // Doesn't happen
-	}
-
-	//switch (signal) {
-	//case 0x00:
-	//	if (dataInc != readSelectorValue(segMan, obj, SELECTOR(dataInc))) {
-	//		writeSelectorValue(segMan, obj, SELECTOR(dataInc), dataInc);
-	//		writeSelectorValue(segMan, obj, SELECTOR(signal), dataInc+0x7f);
-	//	} else {
-	//		writeSelectorValue(segMan, obj, SELECTOR(signal), signal);
-	//	}
-	//	break;
-	//case 0xFF: // May be unnecessary
-	//	s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
-	//	break;
-	//default :
-	//	if (dataInc != readSelectorValue(segMan, obj, SELECTOR(dataInc))) {
-	//		writeSelectorValue(segMan, obj, SELECTOR(dataInc), dataInc);
-	//		writeSelectorValue(segMan, obj, SELECTOR(signal), dataInc + 0x7f);
-	//	} else {
-	//		writeSelectorValue(segMan, obj, SELECTOR(signal), signal);
-	//	}
-	//	break;
-	//}
-
-	if (_soundVersion == SCI_VERSION_1_EARLY) {
-		writeSelectorValue(_segMan, obj, SELECTOR(min), min);
-		writeSelectorValue(_segMan, obj, SELECTOR(sec), sec);
-		writeSelectorValue(_segMan, obj, SELECTOR(frame), frame);
-	}
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdUpdateCues: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -900,15 +516,9 @@
 		writeSelectorValue(_segMan, obj, SELECTOR(sec), musicSlot->ticker % 3600 / 60);
 		writeSelectorValue(_segMan, obj, SELECTOR(frame), musicSlot->ticker);
 	}
-
-#endif
 }
 
 void SoundCommandParser::cmdSendMidi(reg_t obj, int16 value) {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	//SongHandle handle = FROBNICATE_HANDLE(obj);
-	//_state->sfx_send_midi(handle, value, _midiCmd, _controller, _param);
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		// TODO: maybe it's possible to call this with obj == 0:0 and send directly?!
@@ -918,20 +528,13 @@
 		return;
 	}
 	_music->sendMidiCommand(musicSlot, _midiCommand);
-#endif
 }
 
 void SoundCommandParser::cmdReverb(reg_t obj, int16 value) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	_music->setReverb(obj.toUint16() & 0xF);
-#endif
 }
 
 void SoundCommandParser::cmdSetSoundHold(reg_t obj, int16 value) {
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	SongHandle handle = FROBNICATE_HANDLE(obj);
-	_state->sfx_song_set_hold(handle, value);
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdSetSoundHold: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -940,7 +543,6 @@
 
 	// Set the special hold marker ID where the song should be looped at.
 	musicSlot->hold = value;
-#endif
 }
 
 void SoundCommandParser::cmdGetAudioCapability(reg_t obj, int16 value) {
@@ -949,7 +551,6 @@
 }
 
 void SoundCommandParser::cmdStopAllSounds(reg_t obj, int16 value) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	Common::StackLock(_music->_mutex);
 
 	const MusicList::iterator end = _music->getPlayListEnd();
@@ -964,14 +565,12 @@
 		(*i)->dataInc = 0;
 		_music->soundStop(*i);
 	}
-#endif
 }
 
 void SoundCommandParser::cmdSetSoundVolume(reg_t obj, int16 value) {
 	if (!obj.segment)
 		return;
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		// Do not throw a warning if the sound can't be found, as in some games
@@ -991,16 +590,12 @@
 		_music->soundSetVolume(musicSlot, value);
 		writeSelectorValue(_segMan, obj, SELECTOR(vol), value);
 	}
-#endif
 }
 
 void SoundCommandParser::cmdSetSoundPriority(reg_t obj, int16 value) {
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	script_set_priority(_resMan, _segMan, _state, obj, value);
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		warning("cmdSetSoundPriority: Slot not found (%04x:%04x)", PRINT_REG(obj));
@@ -1024,19 +619,12 @@
 		writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | 2);
 		//DoSOund(0xF,hobj,w)
 	}
-#endif
 }
 
 void SoundCommandParser::cmdSetSoundLoop(reg_t obj, int16 value) {
 	if (!obj.segment)
 		return;
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	if (!readSelector(_segMan, obj, SELECTOR(nodePtr)).isNull()) {
-		SongHandle handle = FROBNICATE_HANDLE(obj);
-		_state->sfx_song_set_loops(handle, value);
-	}
-#else
 	MusicEntry *musicSlot = _music->getSlot(obj);
 	if (!musicSlot) {
 		// Apparently, it's perfectly normal for a game to call cmdSetSoundLoop
@@ -1058,7 +646,6 @@
 	}
 
 	writeSelectorValue(_segMan, obj, SELECTOR(loop), musicSlot->loop);
-#endif
 }
 
 void SoundCommandParser::cmdSuspendSound(reg_t obj, int16 value) {
@@ -1066,8 +653,6 @@
 	warning("STUB: cmdSuspendSound");
 }
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
-
 void SoundCommandParser::updateSci0Cues() {
 	bool noOnePlaying = true;
 	MusicEntry *pWaitingForPlay = NULL;
@@ -1101,34 +686,23 @@
 	}
 }
 
-#endif
-
 void SoundCommandParser::clearPlayList() {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	_music->clearPlayList();
-#endif
 }
 
 void SoundCommandParser::printPlayList(Console *con) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	_music->printPlayList(con);
-#endif
 }
 
 void SoundCommandParser::printSongInfo(reg_t obj, Console *con) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	_music->printSongInfo(obj, con);
-#endif
 }
 
 void SoundCommandParser::stopAllSounds() {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	_music->stopAll();
-#endif
 }
 
 void SoundCommandParser::startNewSound(int number) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	Common::StackLock lock(_music->_mutex);
 
 	// Overwrite the first sound in the playlist
@@ -1138,19 +712,14 @@
 	writeSelectorValue(_segMan, soundObj, SELECTOR(number), number);
 	cmdInitSound(soundObj, 0);
 	cmdPlaySound(soundObj, 0);
-#endif
 }
 
 void SoundCommandParser::setMasterVolume(int vol) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	_music->soundSetMasterVolume(vol);
-#endif
 }
 
 void SoundCommandParser::pauseAll(bool pause) {
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	_music->pauseAll(pause);
-#endif
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/sound/soundcmd.h
===================================================================
--- scummvm/trunk/engines/sci/sound/soundcmd.h	2010-06-30 13:35:39 UTC (rev 50531)
+++ scummvm/trunk/engines/sci/sound/soundcmd.h	2010-06-30 13:49:05 UTC (rev 50532)
@@ -26,8 +26,6 @@
 #ifndef SCI_SOUNDCMD_H
 #define SCI_SOUNDCMD_H
 
-#include "sci/sci.h"	// for USE_OLD_MUSIC_FUNCTIONS
-
 #include "common/list.h"
 #include "sci/engine/state.h"
 
@@ -53,10 +51,6 @@
 		kMaxSciVolume = 15
 	};
 
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	void updateSfxState(SfxState *newState) { _state = newState; }
-#endif
-
 	reg_t parseCommand(int argc, reg_t *argv, reg_t acc);
 
 	// Functions used for game state loading
@@ -76,7 +70,6 @@
 	void printPlayList(Console *con);
 	void printSongInfo(reg_t obj, Console *con);
 
-#ifndef USE_OLD_MUSIC_FUNCTIONS
 	/**
 	 * Synchronizes the current state of the music list to the rest of the engine, so that
 	 * the changes that the sound thread makes to the music are registered with the engine
@@ -85,7 +78,6 @@
 	 * by the engine scripts themselves, so the engine itself polls for changes to the music
 	 */
 	void updateSci0Cues();
-#endif
 
 private:
 	typedef Common::Array<MusicEntryCommand *> SoundCommandContainer;
@@ -93,12 +85,7 @@
 	ResourceManager *_resMan;
 	SegManager *_segMan;
 	Kernel *_kernel;
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	SfxState *_state;
-	int _midiCmd, _controller, _param;
-#else
 	SciMusic *_music;
-#endif
 	AudioPlayer *_audio;
 	SciVersion _soundVersion;
 	int _argc;
@@ -131,10 +118,6 @@
 	void cmdSuspendSound(reg_t obj, int16 value);
 
 	void processStopSound(reg_t obj, int16 value, bool sampleFinishedPlaying);
-
-#ifdef USE_OLD_MUSIC_FUNCTIONS
-	void changeSoundStatus(reg_t obj, int newStatus);
-#endif
 };
 
 } // End of namespace Sci


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