aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2019-08-27 16:27:19 +0200
committerEugene Sandulenko2019-11-13 22:07:08 +0100
commit022b6316ddb06c94ea2fce2f3301cb8bd8f332bb (patch)
tree9b21e699fd5fc1678d58832e03efc925b95bae94
parentb444a9ffc4ee9209c76f1d1bda481c9c7308f257 (diff)
downloadscummvm-rg350-022b6316ddb06c94ea2fce2f3301cb8bd8f332bb.tar.gz
scummvm-rg350-022b6316ddb06c94ea2fce2f3301cb8bd8f332bb.tar.bz2
scummvm-rg350-022b6316ddb06c94ea2fce2f3301cb8bd8f332bb.zip
GRIFFON: Unstubbed more sound functionality
-rw-r--r--engines/griffon/engine.cpp46
-rw-r--r--engines/griffon/griffon.cpp4
-rw-r--r--engines/griffon/griffon.h13
3 files changed, 56 insertions, 7 deletions
diff --git a/engines/griffon/engine.cpp b/engines/griffon/engine.cpp
index de70152bfa..3085fdcba4 100644
--- a/engines/griffon/engine.cpp
+++ b/engines/griffon/engine.cpp
@@ -97,12 +97,44 @@ namespace Griffon {
*/
// stubs
-void Mix_Volume(int channel, int volume) {}
-int Mix_PlayChannel(Audio::SeekableAudioStream *chunk, int par3) { return 0; }
-void Mix_Pause(int channel) {}
-void Mix_HaltChannel(int channel) {}
-void Mix_Resume(int channel) {}
-bool Mix_Playing(int channel) { return true; }
+void GriffonEngine::Mix_Volume(int channel, int volume) {}
+
+int GriffonEngine::Mix_getHandle() {
+ for (uint i = 0; i < SOUND_HANDLES; i++) {
+ if (!_mixer->isSoundHandleActive(_handles[i])) {
+ return i;
+ }
+ }
+
+ error("Mix_getHandle(): Too many sound handles");
+
+ return -1;
+}
+
+int GriffonEngine::Mix_PlayChannel(Audio::SeekableAudioStream *chunk, int par3) {
+ int ch = Mix_getHandle();
+
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[ch], chunk, -1, Audio::Mixer::kMaxChannelVolume,
+ 0, DisposeAfterUse::NO, false, false);
+
+ return ch;
+}
+
+void GriffonEngine::Mix_Pause(int channel) {
+ _mixer->pauseHandle(_handles[channel], true);
+}
+
+void GriffonEngine::Mix_HaltChannel(int channel) {
+ _mixer->stopHandle(_handles[channel]);
+}
+
+void GriffonEngine::Mix_Resume(int channel) {
+ _mixer->pauseHandle(_handles[channel], false);
+}
+
+bool GriffonEngine::Mix_Playing(int channel) {
+ return _mixer->isSoundHandleActive(_handles[channel]);
+}
Audio::SeekableAudioStream *Mix_LoadWAV(const char *name) {
Common::File file;
@@ -5045,7 +5077,7 @@ void GriffonEngine::game_saveloadnew() {
rcDest.left = 108;
if (curcol == 2)
rcDest.left = 170;
-
+
// CHECKME: Useless code? or temporary commented?
// rcDest.left = rcDest.left; // + 2 + 2 * sin(-3.14159 * 2 * itemyloc / 16)
diff --git a/engines/griffon/griffon.cpp b/engines/griffon/griffon.cpp
index 75629368a3..6bc3497a68 100644
--- a/engines/griffon/griffon.cpp
+++ b/engines/griffon/griffon.cpp
@@ -26,6 +26,7 @@
#include "common/error.h"
#include "common/file.h"
#include "common/fs.h"
+#include "common/system.h"
#include "graphics/pixelformat.h"
#include "engines/util.h"
@@ -42,6 +43,7 @@ GriffonEngine::GriffonEngine(OSystem *syst) : Engine(syst) {
_rnd = new Common::RandomSource("griffon");
_console = nullptr;
+ _mixer = nullptr;
_shouldQuit = false;
@@ -61,6 +63,8 @@ GriffonEngine::~GriffonEngine() {
Common::Error GriffonEngine::run() {
initGraphics(320, 240, new Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
+ _mixer = g_system->getMixer();
+
_console = new Console();
griffon_main();
diff --git a/engines/griffon/griffon.h b/engines/griffon/griffon.h
index 91c3365fff..7fd531e352 100644
--- a/engines/griffon/griffon.h
+++ b/engines/griffon/griffon.h
@@ -42,6 +42,7 @@
#include "engines/engine.h"
#include "audio/audiostream.h"
+#include "audio/mixer.h"
#include "graphics/transparent_surface.h"
@@ -49,6 +50,8 @@ namespace Griffon {
class Console;
+#define SOUND_HANDLES 16
+
#define kMaxNPC 32
#define kMaxFloat 32
#define kMaxSpell 32
@@ -301,6 +304,14 @@ private:
int state_load_player(int slotnum);
int state_save(int slotnum);
+ void Mix_Volume(int channel, int volume);
+ int Mix_getHandle();
+ int Mix_PlayChannel(Audio::SeekableAudioStream *chunk, int par3);
+ void Mix_Pause(int channel);
+ void Mix_HaltChannel(int channel);
+ void Mix_Resume(int channel);
+ bool Mix_Playing(int channel);
+
private:
Graphics::TransparentSurface *_video, *_videobuffer, *_videobuffer2, *_videobuffer3;
@@ -411,6 +422,8 @@ private:
int loopseta;
Audio::SeekableAudioStream *sfx[21];
+ Audio::SoundHandle _handles[SOUND_HANDLES];
+ Audio::Mixer *_mixer;
// TODO: Check those variables, at least canusekey is a boolean, and the case is wrong in all the names
// room locks