[Scummvm-cvs-logs] SF.net SVN: scummvm:[34252] scummvm/trunk/engines/saga

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Sep 1 22:19:29 CEST 2008


Revision: 34252
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34252&view=rev
Author:   fingolfin
Date:     2008-09-01 20:19:28 +0000 (Mon, 01 Sep 2008)

Log Message:
-----------
Merging more of the GSoC 2008 RTL branch: SAGA

Modified Paths:
--------------
    scummvm/trunk/engines/saga/detection.cpp
    scummvm/trunk/engines/saga/input.cpp
    scummvm/trunk/engines/saga/interface.cpp
    scummvm/trunk/engines/saga/introproc_ihnm.cpp
    scummvm/trunk/engines/saga/music.cpp
    scummvm/trunk/engines/saga/music.h
    scummvm/trunk/engines/saga/saga.cpp
    scummvm/trunk/engines/saga/saga.h
    scummvm/trunk/engines/saga/scene.cpp
    scummvm/trunk/engines/saga/sfuncs.cpp
    scummvm/trunk/engines/saga/sound.cpp
    scummvm/trunk/engines/saga/sound.h

Modified: scummvm/trunk/engines/saga/detection.cpp
===================================================================
--- scummvm/trunk/engines/saga/detection.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/detection.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -147,9 +147,19 @@
 		return "Inherit the Earth (C) Wyrmkeep Entertainment";
 	}
 
+	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
+	virtual SaveStateList listSaves(const char *target) const;
 };
 
+bool SagaMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsRTL) ||
+		(f == kSupportsListSaves) ||
+		(f == kSupportsDirectLoad) ||
+		(f == kSupportsDeleteSave);
+}
+
 bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
 	const Saga::SAGAGameDescription *gd = (const Saga::SAGAGameDescription *)desc;
 	if (gd) {
@@ -158,6 +168,36 @@
 	return gd != 0;
 }
 
+SaveStateList SagaMetaEngine::listSaves(const char *target) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::StringList filenames;
+	char saveDesc[SAVE_TITLE_SIZE];
+	Common::String pattern = target;
+	pattern += ".s??";
+
+	filenames = saveFileMan->listSavefiles(pattern.c_str());
+	sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..)
+
+	SaveStateList saveList;
+	for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+		// Obtain the last 2 digits of the filename, since they correspond to the save slot
+		int slotNum = atoi(file->c_str() + file->size() - 2);
+		
+		if (slotNum >= 0 && slotNum <= 99) {
+			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+			if (in) {
+				for (int i = 0; i < 3; i++)
+					in->readUint32BE();
+				in->read(saveDesc, SAVE_TITLE_SIZE);
+				saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file));
+				delete in;
+			}
+		}
+	}
+
+	return saveList;
+}
+
 #if PLUGIN_ENABLED_DYNAMIC(SAGA)
 	REGISTER_PLUGIN_DYNAMIC(SAGA, PLUGIN_TYPE_ENGINE, SagaMetaEngine);
 #else

Modified: scummvm/trunk/engines/saga/input.cpp
===================================================================
--- scummvm/trunk/engines/saga/input.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/input.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -141,9 +141,6 @@
 			break;
 		case Common::EVENT_MOUSEMOVE:
 			break;
-		case Common::EVENT_QUIT:
-			shutDown();
-			break;
 		default:
 			break;
 		}

Modified: scummvm/trunk/engines/saga/interface.cpp
===================================================================
--- scummvm/trunk/engines/saga/interface.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/interface.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -688,7 +688,7 @@
 			setMode(kPanelMain);
 			_vm->_script->setNoPendingVerb();
 		} else if (ascii == 'q' || ascii == 'Q') {
-			_vm->shutDown();
+			_vm->quitGame();
 		}
 		break;
 	case kPanelBoss:
@@ -1084,7 +1084,7 @@
 			if (_vm->getGameId() == GID_IHNM_DEMO)
 				_vm->_scene->creditsScene();	// display sales info for IHNM demo
 			else
-				_vm->shutDown();
+				_vm->quitGame();
 			break;
 	}
 }
@@ -1153,6 +1153,7 @@
 						debug(1, "Loading save game %d", _vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber);
 						setMode(kPanelMain);
 						_vm->load(_vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber));
+						_vm->syncSoundSettings();
 					}
 				}
 			}
@@ -1616,6 +1617,7 @@
 					debug(1, "Loading save game %d", _vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber);
 					setMode(kPanelMain);
 					_vm->load(_vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber));
+					_vm->syncSoundSettings();
 				}
 			}
 		} else {
@@ -1650,8 +1652,8 @@
 		break;
 	case kTextSound:
 		_vm->_soundVolume = (_vm->_soundVolume + 1) % 11;
-		_vm->_sound->setVolume(_vm->_soundVolume == 10 ? 255 : _vm->_soundVolume * 25);
 		ConfMan.setInt("sfx_volume", _vm->_soundVolume * 25);
+		_vm->_sound->setVolume();
 		break;
 	case kTextVoices:
 		if (_vm->_voiceFilesExist) {
@@ -1669,6 +1671,10 @@
 			_vm->_subtitlesEnabled = true;								// Set it to "Text"
 			_vm->_voicesEnabled = false;
 		}
+		
+		_vm->_speechVolume = (_vm->_speechVolume + 1) % 11;
+		ConfMan.setInt("speech_volume", _vm->_speechVolume * 25);
+		_vm->_sound->setVolume();
 
 		ConfMan.setBool("subtitles", _vm->_subtitlesEnabled);
 		ConfMan.setBool("voices", _vm->_voicesEnabled);

Modified: scummvm/trunk/engines/saga/introproc_ihnm.cpp
===================================================================
--- scummvm/trunk/engines/saga/introproc_ihnm.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/introproc_ihnm.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -59,8 +59,12 @@
 
 		// Play Cyberdreams logo for 168 frames
 		if (!playTitle(0, logoLength, true)) {
+			if (_vm->quit())
+				return !SUCCESS;
 			// Play Dreamers Guild logo for 10 seconds
 			if (!playLoopingTitle(1, 10)) {
+				if (_vm->quit())
+					return !SUCCESS;
 				// Play the title music
 				_vm->_music->play(1, MUSIC_NORMAL);
 				// Play title screen
@@ -70,6 +74,8 @@
 	} else {
 		_vm->_music->play(1, MUSIC_NORMAL);
 		playTitle(0, 10);
+		if (_vm->quit())
+			return !SUCCESS;
 		playTitle(2, 12);
 	}
 
@@ -142,9 +148,9 @@
 
 	while (_vm->_eventMan->pollEvent(event)) {
 		switch (event.type) {
+		case Common::EVENT_RTL:
 		case Common::EVENT_QUIT:
 			res = true;
-			_vm->shutDown();
 			break;
 		case Common::EVENT_KEYDOWN:
 			// Don't react to modifier keys alone. The original did
@@ -187,7 +193,7 @@
 
 	_vm->_gfx->getCurrentPal(pal_cut);
 
-	while (!done) {
+	while (!done && !_vm->quit()) {
 		curTime = _vm->_system->getMillis();
 
 		switch (phase) {

Modified: scummvm/trunk/engines/saga/music.cpp
===================================================================
--- scummvm/trunk/engines/saga/music.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/music.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -348,7 +348,7 @@
 	}
 }
 
-Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enabled) : _vm(vm), _mixer(mixer), _enabled(enabled), _adlib(false) {
+Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver) : _vm(vm), _mixer(mixer), _adlib(false) {
 	_player = new MusicPlayer(driver);
 	_currentVolume = 0;
 
@@ -434,11 +434,7 @@
 	uint32 loopStart;
 
 	debug(2, "Music::play %d, %d", resourceId, flags);
-
-	if (!_enabled) {
-		return;
-	}
-
+	
 	if (isPlaying() && _trackNumber == resourceId) {
 		return;
 	}
@@ -446,11 +442,7 @@
 	_trackNumber = resourceId;
 	_player->stopMusic();
 	_mixer->stopHandle(_musicHandle);
-
-	if (!_vm->_musicVolume) {
-		return;
-	}
-
+	
 	int realTrackNumber;
 
 	if (_vm->getGameType() == GType_ITE) {

Modified: scummvm/trunk/engines/saga/music.h
===================================================================
--- scummvm/trunk/engines/saga/music.h	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/music.h	2008-09-01 20:19:28 UTC (rev 34252)
@@ -105,7 +105,7 @@
 class Music {
 public:
 
-	Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enabled);
+	Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver);
 	~Music(void);
 	void setNativeMT32(bool b)	{ _player->setNativeMT32(b); }
 	bool hasNativeMT32()		{ return _player->hasNativeMT32(); }
@@ -133,7 +133,6 @@
 	Audio::SoundHandle _musicHandle;
 	uint32 _trackNumber;
 
-	int _enabled;
 	bool _adlib;
 
 	int _targetVolume;

Modified: scummvm/trunk/engines/saga/saga.cpp
===================================================================
--- scummvm/trunk/engines/saga/saga.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/saga.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -64,7 +64,6 @@
 	_leftMouseButtonPressed = _rightMouseButtonPressed = false;
 
 	_console = NULL;
-	_quit = false;
 
 	_resource = NULL;
 	_sndRes = NULL;
@@ -142,8 +141,7 @@
 }
 
 int SagaEngine::init() {
-	_soundVolume = ConfMan.getInt("sfx_volume") / 25;
-	_musicVolume = ConfMan.getInt("music_volume") / 25;
+	_musicVolume = ConfMan.getInt("music_volume");
 	_subtitlesEnabled = ConfMan.getBool("subtitles");
 	_readingSpeed = getTalkspeed();
 	_copyProtection = ConfMan.getBool("copy_protection");
@@ -194,29 +192,21 @@
 	if (native_mt32)
 		_driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
 
-	_music = new Music(this, _mixer, _driver, _musicVolume);
+	_music = new Music(this, _mixer, _driver);
 	_music->setNativeMT32(native_mt32);
 	_music->setAdlib(adlib);
-
-	if (!_musicVolume) {
-		debug(1, "Music disabled.");
-	}
-
 	_render = new Render(this, _system);
 	if (!_render->initialized()) {
 		return FAILURE;
 	}
 
 	// Initialize system specific sound
-	_sound = new Sound(this, _mixer, _soundVolume);
-	if (!_soundVolume) {
-		debug(1, "Sound disabled.");
-	}
-
+	_sound = new Sound(this, _mixer);
+	
 	_interface->converseInit();
 	_script->setVerb(_script->getVerbType(kVerbWalkTo));
 
-	_music->setVolume(-1, 1);
+	_music->setVolume(_musicVolume, 1);
 
 	_gfx->initPalette();
 
@@ -233,6 +223,8 @@
 		}
 	}
 
+	syncSoundSettings();
+
 	// FIXME: This is the ugly way of reducing redraw overhead. It works
 	//        well for 320x200 but it's unclear how well it will work for
 	//        640x480.
@@ -270,6 +262,7 @@
 
 		char *fileName = calcSaveFileName(ConfMan.getInt("save_slot"));
 		load(fileName);
+		syncSoundSettings();
 	} else {
 		_framesEsc = 0;
 		_scene->startScene();
@@ -277,7 +270,7 @@
 
 	uint32 currentTicks;
 
-	while (!_quit) {
+	while (!quit()) {
 		if (_console->isAttached())
 			_console->onFrame();
 
@@ -317,7 +310,7 @@
 		_system->delayMillis(10);
 	}
 
-	return 0;
+	return _eventMan->shouldRTL();
 }
 
 void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) {
@@ -527,4 +520,16 @@
 	return (ConfMan.getInt("talkspeed") * 3 + 255 / 2) / 255;
 }
 
+void SagaEngine::syncSoundSettings() {
+	_subtitlesEnabled = ConfMan.getBool("subtitles");
+	_readingSpeed = getTalkspeed();
+
+	if (_readingSpeed > 3)
+		_readingSpeed = 0;
+
+	_musicVolume = ConfMan.getInt("music_volume");
+	_music->setVolume(_musicVolume, 1);
+	_sound->setVolume();
+}
+
 } // End of namespace Saga

Modified: scummvm/trunk/engines/saga/saga.h
===================================================================
--- scummvm/trunk/engines/saga/saga.h	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/saga.h	2008-09-01 20:19:28 UTC (rev 34252)
@@ -492,7 +492,6 @@
 public:
 	SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc);
 	virtual ~SagaEngine();
-	void shutDown() { _quit = true; }
 
 	void save(const char *fileName, const char *saveName);
 	void load(const char *fileName);
@@ -513,6 +512,8 @@
 		return isSaveListFull() ? _saveFilesCount : _saveFilesCount + 1;
 	}
 
+	virtual void syncSoundSettings();
+	
 	int16 _framesEsc;
 
 	uint32 _globalFlags;
@@ -521,6 +522,7 @@
 
 	int _soundVolume;
 	int _musicVolume;
+	int _speechVolume;
 	bool _subtitlesEnabled;
 	bool _voicesEnabled;
 	bool _voiceFilesExist;
@@ -611,8 +613,6 @@
 	bool _rightMouseButtonPressed;
 	int _mouseClickCount;
 
-	bool _quit;
-
 //current game description
 	int _gameNumber;
 	const SAGAGameDescription *_gameDescription;

Modified: scummvm/trunk/engines/saga/scene.cpp
===================================================================
--- scummvm/trunk/engines/saga/scene.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/scene.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -315,7 +315,7 @@
 		break;
 	}
 
-	_vm->shutDown();
+	_vm->quitGame();
 	return;
 }
 

Modified: scummvm/trunk/engines/saga/sfuncs.cpp
===================================================================
--- scummvm/trunk/engines/saga/sfuncs.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/sfuncs.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -339,7 +339,7 @@
 	// exit the game. Known non-interactive demos are GID_ITE_MACDEMO1 and
 	// GID_ITE_WINDEMO1
 	if (_vm->getFeatures() & GF_NON_INTERACTIVE)
-		_vm->shutDown();
+		_vm->quitGame();
 }
 
 // Script function #6 (0x06) blocking
@@ -555,7 +555,7 @@
 	}
 
 	if (_vm->getGameType() == GType_ITE && sceneNumber < 0) {
-		_vm->shutDown();
+		_vm->quitGame();
 		return;
 	}
 

Modified: scummvm/trunk/engines/saga/sound.cpp
===================================================================
--- scummvm/trunk/engines/saga/sound.cpp	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/sound.cpp	2008-09-01 20:19:28 UTC (rev 34252)
@@ -22,8 +22,10 @@
  * $Id$
  *
  */
+
+#include "common/config-manager.h"
+
 #include "saga/saga.h"
-
 #include "saga/sound.h"
 
 #include "sound/audiostream.h"
@@ -32,13 +34,13 @@
 
 namespace Saga {
 
-Sound::Sound(SagaEngine *vm, Audio::Mixer *mixer, int volume) :
+Sound::Sound(SagaEngine *vm, Audio::Mixer *mixer) :
 	_vm(vm), _mixer(mixer), _voxStream(0) {
 
 	for (int i = 0; i < SOUND_HANDLES; i++)
 		_handles[i].type = kFreeHandle;
 
-	setVolume(volume == 10 ? 255 : volume * 25);
+	setVolume();
 }
 
 Sound::~Sound() {
@@ -61,7 +63,8 @@
 	return NULL;
 }
 
-void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop) {
+void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, 
+				sndHandleType handleType, bool loop) {
 	byte flags;
 
 	flags = Audio::Mixer::FLAG_AUTOFREE;
@@ -81,7 +84,12 @@
 		flags |= Audio::Mixer::FLAG_UNSIGNED;
 
 	if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) {
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume);
+		if (handleType == kVoiceHandle)
+			_mixer->playRaw(Audio::Mixer::kSpeechSoundType, handle, buffer.buffer, 
+					buffer.size, buffer.frequency, flags, -1, volume);
+		else
+			_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, 
+					buffer.size, buffer.frequency, flags, -1, volume);
 	} else {
 		Audio::AudioStream *stream = NULL;
 		MemoryReadStream *tmp = NULL;
@@ -116,12 +124,23 @@
 #endif
 			default:
 				// No compression, play it as raw sound
-				_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume);
+				if (handleType == kVoiceHandle)
+					_mixer->playRaw(Audio::Mixer::kSpeechSoundType, handle, buffer.buffer, 
+							buffer.size, buffer.frequency, flags, -1, volume);
+				else
+					_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, 
+							buffer.size, buffer.frequency, flags, -1, volume);
 				break;
 		}
 
-		if (stream != NULL)
-			_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, stream, -1, volume, 0, true, false);
+		if (stream != NULL) {
+			if (handleType == kVoiceHandle)
+				_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, handle, stream, -1, 
+							volume, 0, true, false);
+			else
+				_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, stream, -1, 
+							volume, 0, true, false);
+		}
 	}
 }
 
@@ -129,7 +148,7 @@
 	SndHandle *handle = getHandle();
 
 	handle->type = kEffectHandle;
-	playSoundBuffer(&handle->handle, buffer, 2 * volume, loop);
+	playSoundBuffer(&handle->handle, buffer, 2 * volume, handle->type, loop);
 }
 
 void Sound::pauseSound() {
@@ -156,7 +175,7 @@
 	SndHandle *handle = getHandle();
 
 	handle->type = kVoiceHandle;
-	playSoundBuffer(&handle->handle, buffer, 255, false);
+	playSoundBuffer(&handle->handle, buffer, 255, handle->type, false);
 }
 
 void Sound::pauseVoice() {
@@ -184,9 +203,11 @@
 	stopSound();
 }
 
-void Sound::setVolume(int volume) {
-	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume);
-	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume);
+void Sound::setVolume() {
+	_vm->_soundVolume = ConfMan.getInt("sound_volume");
+	_vm->_speechVolume = ConfMan.getInt("speech_volume");
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_soundVolume);
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _vm->_speechVolume);
 }
 
 } // End of namespace Saga

Modified: scummvm/trunk/engines/saga/sound.h
===================================================================
--- scummvm/trunk/engines/saga/sound.h	2008-09-01 20:18:17 UTC (rev 34251)
+++ scummvm/trunk/engines/saga/sound.h	2008-09-01 20:19:28 UTC (rev 34252)
@@ -71,7 +71,7 @@
 class Sound {
 public:
 
-	Sound(SagaEngine *vm, Audio::Mixer *mixer, int volume);
+	Sound(SagaEngine *vm, Audio::Mixer *mixer);
 	~Sound();
 
 	void playSound(SoundBuffer &buffer, int volume, bool loop);
@@ -86,11 +86,12 @@
 
 	void stopAll();
 
-	void setVolume(int volume);
+	void setVolume();
 
  private:
 
-	void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop);
+	void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, 
+				sndHandleType handleType, bool loop);
 
 	SndHandle *getHandle();
 


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