[Scummvm-cvs-logs] SF.net SVN: scummvm:[52631] scummvm/trunk/engines/mohawk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Tue Sep 7 22:18:30 CEST 2010


Revision: 52631
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52631&view=rev
Author:   mthreepwood
Date:     2010-09-07 20:18:30 +0000 (Tue, 07 Sep 2010)

Log Message:
-----------
MOHAWK: Sound cleanup

Merge the Riven sound file code with the main Riven resource code and remove the mainSoundFile parameter from Sound::playSound(). Reasoning: The sound id's do not collide with the sound id's in the main data files. The sound archives only exist because the original CD version had the ability to choose between low and high quality audio.

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/console.cpp
    scummvm/trunk/engines/mohawk/myst.cpp
    scummvm/trunk/engines/mohawk/myst_scripts.cpp
    scummvm/trunk/engines/mohawk/riven.cpp
    scummvm/trunk/engines/mohawk/riven_external.cpp
    scummvm/trunk/engines/mohawk/riven_scripts.cpp
    scummvm/trunk/engines/mohawk/sound.cpp
    scummvm/trunk/engines/mohawk/sound.h

Modified: scummvm/trunk/engines/mohawk/console.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/console.cpp	2010-09-07 20:14:05 UTC (rev 52630)
+++ scummvm/trunk/engines/mohawk/console.cpp	2010-09-07 20:18:30 UTC (rev 52631)
@@ -367,19 +367,13 @@
 
 bool RivenConsole::Cmd_PlaySound(int argc, const char **argv) {
 	if (argc < 2) {
-		DebugPrintf("Usage: playSound <value> (<use main sound file, default = true>)\n");
-		DebugPrintf("The main sound file is default, but you can use the word \'false\' to make it use the current stack file.\n");
-
+		DebugPrintf("Usage: playSound <value>\n");
 		return true;
 	}
 
 	_vm->_sound->stopSound();
 	_vm->_sound->stopAllSLST();
-
-	bool mainSoundFile = (argc < 3) || (scumm_stricmp(argv[2], "false") != 0);
-
-	_vm->_sound->playSound((uint16)atoi(argv[1]), mainSoundFile);
-
+	_vm->_sound->playSound((uint16)atoi(argv[1]));
 	return false;
 }
 
@@ -393,13 +387,9 @@
 	_vm->_sound->stopSound();
 	_vm->_sound->stopAllSLST();
 
-	uint16 card = _vm->getCurCard();
+	uint16 card = (argc == 3) ? (uint16)atoi(argv[2]) : _vm->getCurCard();
 
-	if (argc == 3)
-		card = (uint16)atoi(argv[2]);
-
 	_vm->_sound->playSLST((uint16)atoi(argv[1]), card);
-
 	return false;
 }
 
@@ -408,7 +398,6 @@
 
 	_vm->_sound->stopSound();
 	_vm->_sound->stopAllSLST();
-
 	return true;
 }
 

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2010-09-07 20:14:05 UTC (rev 52630)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2010-09-07 20:18:30 UTC (rev 52631)
@@ -427,7 +427,7 @@
 
 		// NOTE: All sounds are looped when played via the sound section of the
 		// VIEW resources.
-		_sound->playSound(soundAction, true, soundActionVolume, true);
+		_sound->playSound(soundAction, soundActionVolume, true);
 	} else {
 		error("Unknown sound action %d", soundAction);
 	}

Modified: scummvm/trunk/engines/mohawk/myst_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts.cpp	2010-09-07 20:14:05 UTC (rev 52630)
+++ scummvm/trunk/engines/mohawk/myst_scripts.cpp	2010-09-07 20:18:30 UTC (rev 52631)
@@ -870,7 +870,7 @@
 			_vm->_sound->stopSound();
 			// TODO: Need to keep sound handle and add function to change volume of
 			// looped running sound for kMystSoundActionChangeVolume type
-			_vm->_sound->playSound(soundAction, true, soundVolume);
+			_vm->_sound->playSound(soundAction, soundVolume);
 		} else {
 			debugC(kDebugScript, "Unknown");
 			warning("Unknown sound control value in opcode %d", op);

Modified: scummvm/trunk/engines/mohawk/riven.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven.cpp	2010-09-07 20:14:05 UTC (rev 52630)
+++ scummvm/trunk/engines/mohawk/riven.cpp	2010-09-07 20:18:30 UTC (rev 52631)
@@ -251,7 +251,7 @@
 	// The endings are in reverse order because of the way the 1.02 patch works.
 	// The only "Data3" file is j_Data3.mhk from that patch. Patch files have higher
 	// priorities over the regular files and are therefore loaded and checked first.
-	static const char *endings[] = { "_Data3.mhk", "_Data2.mhk", "_Data1.mhk", "_Data.mhk" };
+	static const char *endings[] = { "_Data3.mhk", "_Data2.mhk", "_Data1.mhk", "_Data.mhk", "_Sounds.mhk" };
 
 	// Don't change stack to the current stack (if the files are loaded)
 	if (_curStack == n && !_mhk.empty())
@@ -285,9 +285,8 @@
 	if (_mhk.empty())
 		error("Could not load stack %s", getStackName(_curStack).c_str());
 
-	// Stop any currently playing sounds and load the new sound file too
+	// Stop any currently playing sounds
 	_sound->stopAllSLST();
-	_sound->loadRivenSounds(_curStack);
 }
 
 // Riven uses some hacks to change stacks for linking books

Modified: scummvm/trunk/engines/mohawk/riven_external.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_external.cpp	2010-09-07 20:14:05 UTC (rev 52630)
+++ scummvm/trunk/engines/mohawk/riven_external.cpp	2010-09-07 20:18:30 UTC (rev 52631)
@@ -277,7 +277,7 @@
 			// If we have at least one found slider, it has now moved
 			// so we should redraw and play a tick sound
 			if (slidersFound) {
-				_vm->_sound->playSound(soundId, false);
+				_vm->_sound->playSound(soundId);
 				drawDomeSliders(bitmapId, startHotspot);
 				_vm->_system->delayMillis(10);
 			}
@@ -350,7 +350,7 @@
 					_sliderState |= 1 << (24 - foundSlider);
 
 					// Now play a click sound and redraw
-					_vm->_sound->playSound(soundId, false);
+					_vm->_sound->playSound(soundId);
 					drawDomeSliders(bitmapId, startHotspot);
 				} else if (foundSlider > 0 && !(_sliderState & (1 << (25 - foundSlider))) && _vm->_hotspots[foundSlider + startHotspot - 1].rect.contains(event.mouse)) {
 					// We've moved the slider left one space
@@ -359,7 +359,7 @@
 					_sliderState |= 1 << (24 - foundSlider);
 
 					// Now play a click sound and redraw
-					_vm->_sound->playSound(soundId, false);
+					_vm->_sound->playSound(soundId);
 					drawDomeSliders(bitmapId, startHotspot);
 				} else
 					_vm->_system->updateScreen(); // A normal update for the cursor
@@ -453,9 +453,9 @@
 
 	// Play the page turning sound
 	if (_vm->getFeatures() & GF_DEMO)
-		_vm->_sound->playSound(4, false);
+		_vm->_sound->playSound(4);
 	else
-		_vm->_sound->playSound(3, false);
+		_vm->_sound->playSound(3);
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(1);
@@ -473,9 +473,9 @@
 
 	// Play the page turning sound
 	if (_vm->getFeatures() & GF_DEMO)
-		_vm->_sound->playSound(5, false);
+		_vm->_sound->playSound(5);
 	else
-		_vm->_sound->playSound(4, false);
+		_vm->_sound->playSound(4);
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(0);
@@ -541,7 +541,7 @@
 	(*page)--;
 
 	// Play the page turning sound
-	_vm->_sound->playSound(5, false);
+	_vm->_sound->playSound(5);
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(3);
@@ -558,7 +558,7 @@
 	(*page)++;
 
 	// Play the page turning sound
-	_vm->_sound->playSound(6, false);
+	_vm->_sound->playSound(6);
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(2);
@@ -577,7 +577,7 @@
 	*_vm->getVar("atrap") = 0;
 
 	// Play the page turning sound
-	_vm->_sound->playSound(8, false);
+	_vm->_sound->playSound(8);
 
 	_vm->refreshCard();
 }
@@ -587,7 +587,7 @@
 	*_vm->getVar("atrap") = 1;
 
 	// Play the page turning sound
-	_vm->_sound->playSound(9, false);
+	_vm->_sound->playSound(9);
 
 	_vm->refreshCard();
 }
@@ -698,7 +698,7 @@
 	(*page)--;
 
 	// Play the page turning sound
-	_vm->_sound->playSound(22, false);
+	_vm->_sound->playSound(22);
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(1);
@@ -715,7 +715,7 @@
 	(*page)++;
 
 	// Play the page turning sound
-	_vm->_sound->playSound(23, false);
+	_vm->_sound->playSound(23);
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(0);
@@ -1149,7 +1149,7 @@
 	if (countDepressedIcons(*iconOrderVar) == 5) {
 		*iconOrderVar = 0;
 		*_vm->getVar("jicons") = 0;
-		_vm->_sound->playSound(46, false);
+		_vm->_sound->playSound(46);
 	}
 }
 
@@ -1569,12 +1569,12 @@
 					_vm->_gfx->changeCursor(kRivenHideCursor);          // Hide the cursor
 					_vm->_gfx->drawPLST(3);                             // Black out the screen
 					_vm->_gfx->updateScreen();                          // Update the screen
-					_vm->_sound->playSound(0, false);                   // Play the link sound
+					_vm->_sound->playSound(0);                          // Play the link sound
 					_vm->_video->activateMLST(7, _vm->getCurCard());    // Activate Gehn Link Video
 					_vm->_video->playMovieBlocking(1);                  // Play Gehn Link Video
-					*_vm->getVar("agehn") = 4;                // Set Gehn to the trapped state
-					*_vm->getVar("atrapbook") = 1;            // We've got the trap book again
-					_vm->_sound->playSound(0, false);                   // Play the link sound again
+					*_vm->getVar("agehn") = 4;                          // Set Gehn to the trapped state
+					*_vm->getVar("atrapbook") = 1;                      // We've got the trap book again
+					_vm->_sound->playSound(0);                          // Play the link sound again
 					_vm->changeToCard(_vm->matchRMAPToCard(0x2885));    // Link out! (TODO: Shouldn't this card change?)
 					return;
 				}
@@ -1661,7 +1661,7 @@
 	(*page)--;
 
 	// Play the page turning sound
-	_vm->_sound->playSound(12, false);
+	_vm->_sound->playSound(12);
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(1);
@@ -1678,7 +1678,7 @@
 	(*page)++;
 
 	// Play the page turning sound
-	_vm->_sound->playSound(13, false);
+	_vm->_sound->playSound(13);
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(0);
@@ -1704,7 +1704,7 @@
 			if (curSound == 5) // Break out after the last sound is done
 				break;
 
-			_vm->_sound->playSound(getComboDigit(*prisonCombo, curSound) + 13, !(_vm->getFeatures() & GF_DVD));
+			_vm->_sound->playSound(getComboDigit(*prisonCombo, curSound) + 13);
 			curSound++;
 			soundTime = _vm->_system->getMillis();
 		}
@@ -1731,7 +1731,7 @@
 
 void RivenExternal::xpisland990_elevcombo(uint16 argc, uint16 *argv) {
 	// Play button sound based on argv[0]
-	_vm->_sound->playSound(argv[0] + 5, false);
+	_vm->_sound->playSound(argv[0] + 5);
 
 	// It is impossible to get here if Gehn is not trapped. However,
 	// the original also disallows brute forcing the ending if you have
@@ -1853,7 +1853,7 @@
 		} else {
 			// ...the telescope can't move down anymore.
 			// Play the sound of not being able to move
-			_vm->_sound->playSound(13, false);
+			_vm->_sound->playSound(13);
 		}
 	} else {
 		// We're not at the bottom, and we can move down again
@@ -1879,7 +1879,7 @@
 	// Check if we can't move up anymore
 	if (*telescopePos == 5) {
 		// Play the sound of not being able to move
-		_vm->_sound->playSound(13, false);
+		_vm->_sound->playSound(13);
 		return;
 	}
 

Modified: scummvm/trunk/engines/mohawk/riven_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_scripts.cpp	2010-09-07 20:14:05 UTC (rev 52630)
+++ scummvm/trunk/engines/mohawk/riven_scripts.cpp	2010-09-07 20:18:30 UTC (rev 52631)
@@ -348,7 +348,7 @@
 
 // Command 4: play local tWAV resource (twav_id, volume, u1)
 void RivenScript::playSound(uint16 op, uint16 argc, uint16 *argv) {
-	_vm->_sound->playSound(argv[0], false);
+	_vm->_sound->playSound(argv[0]);
 }
 
 // Command 7: set variable value (variable, value)

Modified: scummvm/trunk/engines/mohawk/sound.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/sound.cpp	2010-09-07 20:14:05 UTC (rev 52630)
+++ scummvm/trunk/engines/mohawk/sound.cpp	2010-09-07 20:18:30 UTC (rev 52631)
@@ -36,7 +36,6 @@
 namespace Mohawk {
 
 Sound::Sound(MohawkEngine* vm) : _vm(vm) {
-	_rivenSoundFile = NULL;
 	_midiDriver = NULL;
 	_midiParser = NULL;
 
@@ -51,7 +50,6 @@
 Sound::~Sound() {
 	stopSound();
 	stopAllSLST();
-	delete _rivenSoundFile;
 
 	if (_midiDriver) {
 		_midiDriver->close();
@@ -64,15 +62,6 @@
 	}
 }
 
-void Sound::loadRivenSounds(uint16 stack) {
-	static const char prefixes[] = { 'a', 'b', 'g', 'j', 'o', 'p', 'r', 't' };
-
-	if (!_rivenSoundFile)
-		_rivenSoundFile = new MohawkArchive();
-
-	_rivenSoundFile->open(Common::String(prefixes[stack]) + "_Sounds.mhk");
-}
-
 void Sound::initMidi() {
 	if (!(_vm->getFeatures() & GF_HASMIDI))
 		return;
@@ -87,7 +76,7 @@
 	_midiParser->setTimerRate(_midiDriver->getBaseTempo());
 }
 
-Audio::SoundHandle *Sound::playSound(uint16 id, bool mainSoundFile, byte volume, bool loop) {
+Audio::SoundHandle *Sound::playSound(uint16 id, byte volume, bool loop) {
 	debug (0, "Playing sound %d", id);
 
 	SndHandle *handle = getHandle();
@@ -113,21 +102,9 @@
 		} else
 			audStream = makeMohawkWaveStream(_vm->getRawData(ID_MSND, id));
 		break;
-	case GType_RIVEN:
-		if (mainSoundFile)
-			audStream = makeMohawkWaveStream(_rivenSoundFile->getRawData(ID_TWAV, id));
-		else
-			audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id));
-		break;
 	case GType_ZOOMBINI:
 		audStream = makeMohawkWaveStream(_vm->getRawData(ID_SND, id));
 		break;
-	case GType_CSAMTRAK:
-		if (mainSoundFile)
-			audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id));
-		else
-			audStream = getCSAmtrakMusic(id);
-		break;
 	case GType_LIVINGBOOKSV1:
 		audStream = makeOldMohawkWaveStream(_vm->getRawData(ID_WAV, id));
 		break;
@@ -304,7 +281,7 @@
 	sndHandle.id = id;
 	_currentSLSTSounds.push_back(sndHandle);
 
-	Audio::AudioStream *audStream = makeMohawkWaveStream(_rivenSoundFile->getRawData(ID_TWAV, id));
+	Audio::AudioStream *audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id));
 
 	// Loop here if necessary
 	if (loop)
@@ -336,16 +313,6 @@
 		_vm->_mixer->pauseHandle(*_currentSLSTSounds[i].handle, false);
 }
 
-Audio::AudioStream *Sound::getCSAmtrakMusic(uint16 id) {
-	char filename[18];
-	sprintf(filename, "MUSIC/MUSIC%02d.MHK", id);
-	MohawkArchive *file = new MohawkArchive();
-	file->open(filename);
-	Audio::AudioStream *audStream = makeMohawkWaveStream(file->getRawData(ID_TWAV, 2000 + id));
-	delete file;
-	return audStream;
-}
-
 Audio::AudioStream *Sound::makeMohawkWaveStream(Common::SeekableReadStream *stream) {
 	uint32 tag = 0;
 	ADPC_Chunk adpc;

Modified: scummvm/trunk/engines/mohawk/sound.h
===================================================================
--- scummvm/trunk/engines/mohawk/sound.h	2010-09-07 20:14:05 UTC (rev 52630)
+++ scummvm/trunk/engines/mohawk/sound.h	2010-09-07 20:18:30 UTC (rev 52631)
@@ -118,8 +118,7 @@
 	Sound(MohawkEngine*);
 	~Sound();
 
-	void loadRivenSounds(uint16 stack);
-	Audio::SoundHandle *playSound(uint16 id, bool mainSoundFile = true, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false);
+	Audio::SoundHandle *playSound(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false);
 	void playMidi(uint16 id);
 	void stopSound();
 	void pauseSound();
@@ -132,11 +131,9 @@
 
 private:
 	MohawkEngine *_vm;
-	MohawkArchive *_rivenSoundFile;
 	MidiDriver *_midiDriver;
 	MidiParser *_midiParser;
 
-	static Audio::AudioStream *getCSAmtrakMusic(uint16 id);
 	static Audio::AudioStream *makeMohawkWaveStream(Common::SeekableReadStream *stream);
 	static Audio::AudioStream *makeOldMohawkWaveStream(Common::SeekableReadStream *stream);
 	void initMidi();


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