aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche
diff options
context:
space:
mode:
authorStrangerke2013-09-18 23:59:26 +0200
committerStrangerke2013-09-18 23:59:26 +0200
commit23b225ca0d1da28a45507824edcff1c9ca0f917b (patch)
treee5bcd9a33e5abd92d179582fcf66d4e15288f0c5 /engines/avalanche
parentedc147774100ffcdfb6aeaa896151e75790564ce (diff)
downloadscummvm-rg350-23b225ca0d1da28a45507824edcff1c9ca0f917b.tar.gz
scummvm-rg350-23b225ca0d1da28a45507824edcff1c9ca0f917b.tar.bz2
scummvm-rg350-23b225ca0d1da28a45507824edcff1c9ca0f917b.zip
AVALANCHE: Add sound class, blip(), playNote() and click()
Diffstat (limited to 'engines/avalanche')
-rw-r--r--engines/avalanche/avalanche.cpp2
-rw-r--r--engines/avalanche/avalanche.h2
-rw-r--r--engines/avalanche/avalot.cpp7
-rw-r--r--engines/avalanche/celer.cpp3
-rw-r--r--engines/avalanche/gyro.cpp12
-rw-r--r--engines/avalanche/gyro.h4
-rw-r--r--engines/avalanche/lucerna.cpp10
-rw-r--r--engines/avalanche/menu.cpp2
-rw-r--r--engines/avalanche/module.mk3
-rw-r--r--engines/avalanche/parser.cpp4
-rw-r--r--engines/avalanche/sound.cpp101
-rw-r--r--engines/avalanche/sound.h54
-rw-r--r--engines/avalanche/timer.cpp2
13 files changed, 173 insertions, 33 deletions
diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp
index 1c92d2b0ed..b363b8a307 100644
--- a/engines/avalanche/avalanche.cpp
+++ b/engines/avalanche/avalanche.cpp
@@ -73,6 +73,7 @@ AvalancheEngine::~AvalancheEngine() {
delete _menu;
delete _closing;
delete _gyro;
+ delete _sound;
}
Common::ErrorCode AvalancheEngine::initialize() {
@@ -91,6 +92,7 @@ Common::ErrorCode AvalancheEngine::initialize() {
_acci = new Acci(this);
_menu = new Menu(this);
_closing = new Closing(this);
+ _sound = new SoundHandler(this);
_graphics->init();
_scrolls->init();
diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h
index 4a01c729d2..c930fe7347 100644
--- a/engines/avalanche/avalanche.h
+++ b/engines/avalanche/avalanche.h
@@ -45,6 +45,7 @@
#include "avalanche/acci.h"
#include "avalanche/menu.h"
#include "avalanche/closing.h"
+#include "avalanche/sound.h"
#include "common/serializer.h"
@@ -80,6 +81,7 @@ public:
Acci *_acci;
Menu *_menu;
Closing *_closing;
+ SoundHandler *_sound;
OSystem *_system;
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index 0bee2b77cc..565d54c9f7 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -56,11 +56,8 @@ Avalot::Avalot(AvalancheEngine *vm) {
}
void Avalot::handleKeyDown(Common::Event &event) {
- //if (keyboardclick)
- // click();
- //
- // To be implemented later with the sounds, I assume.
-
+// if (keyboardclick)
+ _vm->_sound->click();
if ((Common::KEYCODE_F1 <= event.kbd.keycode) && (event.kbd.keycode <= Common::KEYCODE_F15))
_vm->_parser->handleFunctionKey(event);
diff --git a/engines/avalanche/celer.cpp b/engines/avalanche/celer.cpp
index 61a45c7e26..37a01ed6a0 100644
--- a/engines/avalanche/celer.cpp
+++ b/engines/avalanche/celer.cpp
@@ -255,7 +255,8 @@ void Celer::updateBackgroundSprites() {
if (_vm->_gyro->_nextBell < 5)
_vm->_gyro->_nextBell = 12;
_vm->_gyro->_nextBell--;
- _vm->_gyro->note(_vm->_gyro->kNotes[_vm->_gyro->_nextBell]);
+ // CHECKME: 2 is a guess. No length in the original?
+ _vm->_sound->playNote(_vm->_gyro->kNotes[_vm->_gyro->_nextBell], 2);
break;
case 2:
//nosound();
diff --git a/engines/avalanche/gyro.cpp b/engines/avalanche/gyro.cpp
index cea537da31..c1ea6a2575 100644
--- a/engines/avalanche/gyro.cpp
+++ b/engines/avalanche/gyro.cpp
@@ -209,14 +209,6 @@ void Gyro::setMousePointerWait() {
newMouse(4);
}
-void Gyro::note(uint16 hertz) {
- warning("STUB: Gyro::note()");
-}
-
-void Gyro::blip() {
- warning("STUB: Gyro::blip()");
-}
-
void Gyro::drawShadow(int16 x1, int16 y1, int16 x2, int16 y2, byte hc, byte sc) {
warning("STUB: Gyro::shadow()");
}
@@ -361,10 +353,6 @@ void Gyro::newGame() {
_vm->_lucerna->spriteRun();
}
-void Gyro::click() {
- warning("STUB: Gyro::click()");
-}
-
void Gyro::slowDown() {
warning("STUB: Gyro::slowdown()");
}
diff --git a/engines/avalanche/gyro.h b/engines/avalanche/gyro.h
index 27bbcb8871..f62c250604 100644
--- a/engines/avalanche/gyro.h
+++ b/engines/avalanche/gyro.h
@@ -370,10 +370,6 @@ public:
void setMousePointerWait(); // Makes hourglass.
void loadMouse(byte which);
- void note(uint16 hertz);
- void blip();
- void click(); // "Audio keyboard feedback"
-
void setBackgroundColor(byte x);
void drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String t);
diff --git a/engines/avalanche/lucerna.cpp b/engines/avalanche/lucerna.cpp
index ae6e8b71db..0206d0ab9c 100644
--- a/engines/avalanche/lucerna.cpp
+++ b/engines/avalanche/lucerna.cpp
@@ -946,13 +946,11 @@ void Lucerna::incScore(byte num) { // Add on no. of points
for (int i = 1; i <= num; i++) {
_vm->_gyro->_dnascore++;
-#if 0
- if (soundfx) {
+// if (soundfx) {
for (int j = 1; j <= 97; j++)
- sound(177 + dna.score * 3);
- }
- nosound;
-#endif
+ // Length os 2 is a guess, the original doesn't have a delay specified
+ _vm->_sound->playNote(177 + _vm->_gyro->_dnascore * 3, 2);
+// }
}
warning("STUB: Lucerna::points()");
diff --git a/engines/avalanche/menu.cpp b/engines/avalanche/menu.cpp
index a51ec4693e..aa7cba7a82 100644
--- a/engines/avalanche/menu.cpp
+++ b/engines/avalanche/menu.cpp
@@ -214,7 +214,7 @@ void MenuItem::parseKey(char c) {
}
}
if (!found)
- _dr->_vm->_gyro->blip();
+ _dr->_vm->_sound->blip();
}
void MenuBar::init(Menu *dr) {
diff --git a/engines/avalanche/module.mk b/engines/avalanche/module.mk
index 4a0c7034b6..0fea70e88e 100644
--- a/engines/avalanche/module.mk
+++ b/engines/avalanche/module.mk
@@ -17,7 +17,8 @@ MODULE_OBJS = \
animation.o \
acci.o \
menu.o \
- closing.o
+ closing.o \
+ sound.o
# This module can be built as a plugin
ifeq ($(ENABLE_AVALANCHE), DYNAMIC_PLUGIN)
diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp
index 903a01b796..5f9e5d8965 100644
--- a/engines/avalanche/parser.cpp
+++ b/engines/avalanche/parser.cpp
@@ -60,7 +60,7 @@ void Parser::handleInputText(const Common::Event &event) {
_inputTextPos++;
plotText();
} else
- _vm->_gyro->blip();
+ _vm->_sound->blip();
// }
}
@@ -73,7 +73,7 @@ void Parser::handleBackspace() {
_inputText.deleteChar(_inputTextPos);
plotText();
} else
- _vm->_gyro->blip();
+ _vm->_sound->blip();
}
}
diff --git a/engines/avalanche/sound.cpp b/engines/avalanche/sound.cpp
new file mode 100644
index 0000000000..bec5426594
--- /dev/null
+++ b/engines/avalanche/sound.cpp
@@ -0,0 +1,101 @@
+/* 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 "common/debug.h"
+#include "common/system.h"
+#include "common/textconsole.h"
+#include "common/config-manager.h"
+
+#include "audio/decoders/raw.h"
+#include "audio/audiostream.h"
+
+#include "avalanche/avalanche.h"
+#include "avalanche/sound.h"
+
+namespace Avalanche {
+
+SoundHandler::SoundHandler(AvalancheEngine *vm) : _vm(vm) {
+ _speakerStream = new Audio::PCSpeaker(_vm->_mixer->getOutputRate());
+ _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle,
+ _speakerStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
+}
+
+SoundHandler::~SoundHandler() {
+ _vm->_mixer->stopHandle(_speakerHandle);
+ delete _speakerStream;
+}
+
+/**
+ * Stop any sound that might be playing
+ */
+void SoundHandler::stopSound() {
+ _vm->_mixer->stopAll();
+}
+
+/**
+ * Turn digitized sound on and off
+ */
+void SoundHandler::toggleSound() {
+// _vm->_config._soundFl = !_vm->_config._soundFl;
+}
+
+/**
+ * Initialize for MCI sound and midi
+ */
+void SoundHandler::initSound() {
+ //_midiPlayer->open();
+}
+
+void SoundHandler::syncVolume() {
+ int soundVolume;
+
+ if (ConfMan.getBool("sfx_mute") || ConfMan.getBool("mute"))
+ soundVolume = -1;
+ else
+ soundVolume = MIN(255, ConfMan.getInt("sfx_volume"));
+
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolume);
+}
+
+void SoundHandler::playNote(int freq, int length) {
+ // Does the user not want any sound?
+// if (!_vm->_config._soundFl || !_vm->_mixer->isReady())
+ if (!_vm->_mixer->isReady())
+ return;
+
+ // Start a note playing (we will stop it when the timer expires).
+ _speakerStream->play(Audio::PCSpeaker::kWaveFormSquare, freq, length);
+}
+
+void SoundHandler::click() {
+ _vm->_mixer->stopAll();
+
+ playNote(7177, 1);
+}
+
+void SoundHandler::blip() {
+ _vm->_mixer->stopAll();
+
+ playNote(177, 77);
+}
+
+} // End of namespace Avalanche
diff --git a/engines/avalanche/sound.h b/engines/avalanche/sound.h
new file mode 100644
index 0000000000..65dda96406
--- /dev/null
+++ b/engines/avalanche/sound.h
@@ -0,0 +1,54 @@
+/* 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 AVALANCHE_SOUND_H
+#define AVALANCHE_SOUND_H
+
+#include "audio/mixer.h"
+#include "audio/midiplayer.h"
+#include "audio/softsynth/pcspk.h"
+
+namespace Avalanche {
+
+class SoundHandler {
+public:
+ SoundHandler(AvalancheEngine *vm);
+ ~SoundHandler();
+
+ void toggleSound();
+ void playNote(int freq, int length);
+ void click();
+ void blip();
+ void initSound();
+ void syncVolume();
+
+private:
+ AvalancheEngine *_vm;
+ Audio::PCSpeaker *_speakerStream;
+ Audio::SoundHandle _speakerHandle;
+
+ void stopSound();
+};
+
+} // End of namespace Avalanche
+
+#endif //AVALANCHE_SOUND_H
diff --git a/engines/avalanche/timer.cpp b/engines/avalanche/timer.cpp
index bd31c2d05a..cbce6cb229 100644
--- a/engines/avalanche/timer.cpp
+++ b/engines/avalanche/timer.cpp
@@ -272,7 +272,7 @@ void Timer::bang2() {
}
void Timer::stairs() {
- _vm->_gyro->blip();
+ _vm->_sound->blip();
_vm->_animation->_sprites[0].walkTo(3);
_vm->_celer->drawBackgroundSprite(-1, -1, 1);
_vm->_gyro->_brummieStairs = 2;