aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus
diff options
context:
space:
mode:
authorMatthew Hoops2011-06-15 13:00:17 -0400
committerMatthew Hoops2011-06-15 13:00:17 -0400
commit9aa9e6afcb160d0aee233aeaeb80390a23a616a4 (patch)
treececd1751668147b58693b5e0f893418755d6ecf1 /engines/pegasus
parentae1a9323917b7d1d45929d675a14ffd314bf95da (diff)
downloadscummvm-rg350-9aa9e6afcb160d0aee233aeaeb80390a23a616a4.tar.gz
scummvm-rg350-9aa9e6afcb160d0aee233aeaeb80390a23a616a4.tar.bz2
scummvm-rg350-9aa9e6afcb160d0aee233aeaeb80390a23a616a4.zip
PEGASUS: Switch sound playback to using the MMSound class
Diffstat (limited to 'engines/pegasus')
-rw-r--r--engines/pegasus/menu.cpp22
-rw-r--r--engines/pegasus/module.mk1
-rw-r--r--engines/pegasus/pegasus.cpp10
-rw-r--r--engines/pegasus/pegasus.h2
-rw-r--r--engines/pegasus/sound.cpp86
-rw-r--r--engines/pegasus/sound.h69
6 files changed, 17 insertions, 173 deletions
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 33e8df3f6b..577d96aa82 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -26,6 +26,8 @@
#include "pegasus/console.h"
#include "pegasus/pegasus.h"
+#include "pegasus/MMShell/Sounds/MMSound.h"
+
namespace Pegasus {
enum {
@@ -44,7 +46,9 @@ enum {
};
void PegasusEngine::runMainMenu() {
- _sound->playSound("Sounds/Main Menu.aiff", true);
+ MMSound sound;
+ sound.InitFromAIFFFile("Sounds/Main Menu.aiff");
+ sound.LoopSound();
// Note down how long since the last click
uint32 lastClickTime = _system->getMillis();
@@ -82,14 +86,14 @@ void PegasusEngine::runMainMenu() {
case Common::KEYCODE_RETURN:
if (buttonSelected != kDifficultyButton) {
drawMenuButtonSelected(buttonSelected);
+ sound.StopSound();
setGameMode(buttonSelected);
- if (_gameMode != kMainMenuMode) {
- _sound->stopSound();
+ if (_gameMode != kMainMenuMode)
return;
- }
-
+
drawMenu(buttonSelected);
+ sound.LoopSound();
}
break;
case Common::KEYCODE_d:
@@ -118,7 +122,7 @@ void PegasusEngine::runMainMenu() {
return;
// Too slow! Go back and show the intro again.
- _sound->stopSound();
+ sound.StopSound();
_video->playMovie(_introDirectory + "/LilMovie.movie");
_gameMode = kIntroMode;
}
@@ -173,9 +177,7 @@ void PegasusEngine::setGameMode(int buttonSelected) {
_gameMode = kMainGameMode;
break;
case kDemoCreditsButton:
- _sound->stopSound();
runDemoCredits();
- _sound->playSound("Sounds/Main Menu.aiff", true);
break;
case kDemoQuitButton:
_gameMode = kQuitMode;
@@ -184,9 +186,7 @@ void PegasusEngine::setGameMode(int buttonSelected) {
} else {
switch (buttonSelected) {
case kInterfaceOverviewButton:
- _sound->stopSound();
runInterfaceOverview();
- _sound->playSound("Sounds/Main Menu.aiff", true);
break;
case kStartButton:
_gameMode = kMainGameMode;
@@ -195,9 +195,7 @@ void PegasusEngine::setGameMode(int buttonSelected) {
showLoadDialog();
break;
case kCreditsButton:
- _sound->stopSound();
runCredits();
- _sound->playSound("Sounds/Main Menu.aiff", true);
break;
case kQuitButton:
_gameMode = kQuitMode;
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 1f5e6f5a28..cb1f237d8f 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -8,7 +8,6 @@ MODULE_OBJS = \
menu.o \
overview.o \
pegasus.o \
- sound.o \
video.o \
Game_Shell/CItem.o \
MMShell/Sounds/MMSound.o \
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index cf79900bf8..4e68007c03 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -37,6 +37,10 @@
//#define RUN_SUB_MOVIE // :D :D :D :D :D :D
//#define RUN_INTERFACE_TEST
+#ifdef RUN_INTERFACE_TEST
+#include "pegasus/MMShell/Sounds/MMSound.h"
+#endif
+
namespace Pegasus {
PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
@@ -44,7 +48,6 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
PegasusEngine::~PegasusEngine() {
delete _video;
- delete _sound;
delete _gfx;
delete _resFork;
delete _inventoryLid;
@@ -56,7 +59,6 @@ Common::Error PegasusEngine::run() {
_console = new PegasusConsole(this);
_gfx = new GraphicsManager(this);
_video = new VideoManager(this);
- _sound = new SoundManager(this);
_resFork = new Common::MacResManager();
_inventoryLid = new Common::MacResManager();
_biochipLid = new Common::MacResManager();
@@ -112,7 +114,9 @@ Common::Error PegasusEngine::run() {
#elif defined(RUN_INTERFACE_TEST)
drawInterface();
_gfx->setCursor(kMainCursor);
- _sound->playSound("Sounds/Caldoria/Apartment Music.aiff", true);
+ MMSound sound;
+ sound.InitFromAIFFFile("Sounds/Caldoria/Apartment Music.aiff");
+ sound.LoopSound();
while (!shouldQuit()) {
Common::Event event;
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index ee5dc76a92..9f546337b5 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -31,7 +31,6 @@
#include "engines/engine.h"
-#include "pegasus/sound.h"
#include "pegasus/graphics.h"
#include "pegasus/video.h"
@@ -204,7 +203,6 @@ public:
GUI::Debugger *getDebugger();
VideoManager *_video;
- SoundManager *_sound;
GraphicsManager *_gfx;
Common::MacResManager *_resFork, *_inventoryLid, *_biochipLid;
diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
deleted file mode 100644
index b87bff423a..0000000000
--- a/engines/pegasus/sound.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/sound.h"
-
-#include "common/file.h"
-#include "common/textconsole.h"
-#include "audio/decoders/aiff.h"
-
-namespace Pegasus {
-
-SoundManager::SoundManager(PegasusEngine *vm) : _vm(vm) {
-}
-
-void SoundManager::playSound(Common::String filename, bool loop) {
- SndHandle *handle = getHandle();
- handle->type = kUsedHandle;
-
- Common::File *file = new Common::File();
- if (!file->open(filename.c_str()))
- error("Could not open file \'%s\'", filename.c_str());
-
- Audio::AudioStream* audStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
-
- if (loop)
- audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream*)audStream, 0);
-
- if (audStream)
- _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle->handle, audStream);
-}
-
-SndHandle *SoundManager::getHandle() {
- for (int i = 0; i < SOUND_HANDLES; i++) {
- if (_handles[i].type == kFreeHandle)
- return &_handles[i];
-
- if (!_vm->_mixer->isSoundHandleActive(_handles[i].handle)) {
- _handles[i].type = kFreeHandle;
- return &_handles[i];
- }
- }
-
- error("SoundManager::getHandle(): Too many sound handles");
- return NULL;
-}
-
-bool SoundManager::isPlaying() {
- for (int i = 0; i < SOUND_HANDLES; i++)
- if (_handles[i].type == kUsedHandle)
- if (_vm->_mixer->isSoundHandleActive(_handles[i].handle))
- return true;
- return false;
-}
-
-void SoundManager::stopSound() {
- _vm->_mixer->stopAll();
-}
-
-void SoundManager::pauseSound() {
- _vm->_mixer->pauseAll(true);
-}
-
-void SoundManager::resumeSound() {
- _vm->_mixer->pauseAll(false);
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
deleted file mode 100644
index ebe6f79ac0..0000000000
--- a/engines/pegasus/sound.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_SOUND_H
-#define PEGASUS_SOUND_H
-
-#include "common/scummsys.h"
-#include "common/str.h"
-
-#include "audio/audiostream.h"
-#include "audio/mixer.h"
-
-#include "pegasus/pegasus.h"
-
-namespace Pegasus {
-
-#define SOUND_HANDLES 10
-
-enum sndHandleType {
- kFreeHandle,
- kUsedHandle
-};
-
-struct SndHandle {
- Audio::SoundHandle handle;
- sndHandleType type;
-};
-
-class PegasusEngine;
-
-class SoundManager {
-public:
- SoundManager(PegasusEngine *vm);
-
- void playSound(Common::String filename, bool loop = false);
- void stopSound();
- void pauseSound();
- void resumeSound();
- bool isPlaying();
-
-private:
- PegasusEngine *_vm;
-
- SndHandle _handles[SOUND_HANDLES];
- SndHandle *getHandle();
-};
-
-} // End of namespace Pegasus
-
-#endif