aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohndoe1232014-04-18 22:08:34 +0200
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commitd57ae261791f17c8c83f51c8327d908b32afad3b (patch)
tree89e20ddbc18593e2dccb1283fba0cbf21f0e827d
parentd431d3521480d43fa646a5cd84c6a10d0d24843a (diff)
downloadscummvm-rg350-d57ae261791f17c8c83f51c8327d908b32afad3b.tar.gz
scummvm-rg350-d57ae261791f17c8c83f51c8327d908b32afad3b.tar.bz2
scummvm-rg350-d57ae261791f17c8c83f51c8327d908b32afad3b.zip
ILLUSIONS: Add SoundMan and MusicPlayer
- Add remaining screen shake effects - Implement Chinese dialog puzzle in Duckman
-rw-r--r--engines/illusions/actor.cpp2
-rw-r--r--engines/illusions/illusions.cpp6
-rw-r--r--engines/illusions/illusions.h3
-rw-r--r--engines/illusions/illusions_bbdou.cpp14
-rw-r--r--engines/illusions/illusions_duckman.cpp96
-rw-r--r--engines/illusions/illusions_duckman.h7
-rw-r--r--engines/illusions/module.mk1
-rw-r--r--engines/illusions/screentext.cpp3
-rw-r--r--engines/illusions/scriptopcodes_bbdou.cpp5
-rw-r--r--engines/illusions/scriptopcodes_duckman.cpp16
-rw-r--r--engines/illusions/sound.cpp101
-rw-r--r--engines/illusions/sound.h65
-rw-r--r--engines/illusions/talkthread_duckman.cpp10
-rw-r--r--engines/illusions/talkthread_duckman.h3
14 files changed, 312 insertions, 20 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index 31f3a28613..7890d021a7 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -770,7 +770,7 @@ PointArray *Control::createPath(Common::Point destPt) {
WidthHeight bgDimensions = _vm->_backgroundItems->getMasterBgDimensions();
PointArray *path = pathFinder.findPath(_actor->_position, destPt, walkPoints, walkRects, bgDimensions);
for (uint i = 0; i < path->size(); ++i) {
- debug("Path(%d) (%d, %d)", i, (*path)[i].x, (*path)[i].y);
+ debug(0, "Path(%d) (%d, %d)", i, (*path)[i].x, (*path)[i].y);
}
return path;
}
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 5031f5e11f..1260714d17 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -35,6 +35,7 @@
#include "illusions/screentext.h"
#include "illusions/scriptresource.h"
#include "illusions/scriptman.h"
+#include "illusions/sound.h"
#include "illusions/soundresource.h"
#include "illusions/specialcode.h"
#include "illusions/talkresource.h"
@@ -204,6 +205,11 @@ int IllusionsEngine::updateSprites(uint flags) {
return 1;
}
+int IllusionsEngine::updateSoundMan(uint flags) {
+ _soundMan->update();
+ return 1;
+}
+
int IllusionsEngine::getRandom(int max) {
return _random->getRandomNumber(max - 1);
}
diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h
index 7ea49fd5ca..1a1f542001 100644
--- a/engines/illusions/illusions.h
+++ b/engines/illusions/illusions.h
@@ -70,6 +70,7 @@ class ScriptOpcodes;
class ScriptResource;
class ScriptStack;
class Sequence;
+class SoundMan;
class SpecialCode;
class TalkItems;
class ThreadList;
@@ -113,6 +114,7 @@ public:
ScriptOpcodes *_scriptOpcodes;
SpecialCode *_specialCode;
ThreadList *_threads;
+ SoundMan *_soundMan;
uint32 _nextTempThreadId;
bool _doScriptThreadInit;
@@ -146,6 +148,7 @@ public:
int updateSequences(uint flags);
int updateGraphics(uint flags);
int updateSprites(uint flags);
+ int updateSoundMan(uint flags);
uint32 getElapsedUpdateTime();
Common::Point *getObjectActorPositionPtr(uint32 objectId);
diff --git a/engines/illusions/illusions_bbdou.cpp b/engines/illusions/illusions_bbdou.cpp
index f2cb4fddd0..658732de3f 100644
--- a/engines/illusions/illusions_bbdou.cpp
+++ b/engines/illusions/illusions_bbdou.cpp
@@ -36,6 +36,7 @@
#include "illusions/scriptopcodes_bbdou.h"
#include "illusions/scriptresource.h"
#include "illusions/scriptman.h"
+#include "illusions/sound.h"
#include "illusions/soundresource.h"
#include "illusions/specialcode.h"
#include "illusions/bbdou/bbdou_specialcode.h"
@@ -216,6 +217,7 @@ Common::Error IllusionsEngine_BBDOU::run() {
_triggerFunctions = new TriggerFunctions();
_threads = new ThreadList(this);
_updateFunctions = new UpdateFunctions();
+ _soundMan = new SoundMan(this);
initUpdateFunctions();
@@ -254,6 +256,7 @@ Common::Error IllusionsEngine_BBDOU::run() {
delete _stack;
delete _scriptOpcodes;
+ delete _soundMan;
delete _updateFunctions;
delete _threads;
delete _triggerFunctions;
@@ -295,6 +298,7 @@ void IllusionsEngine_BBDOU::initUpdateFunctions() {
UPDATEFUNCTION(60, 0, updateSequences);
UPDATEFUNCTION(70, 0, updateGraphics);
UPDATEFUNCTION(90, 0, updateSprites);
+ UPDATEFUNCTION(120, 0, updateSoundMan);
}
#undef UPDATEFUNCTION
@@ -376,7 +380,15 @@ Common::Point IllusionsEngine_BBDOU::getNamedPointPosition(uint32 namedPointId)
_controls->findNamedPoint(namedPointId, pt))
return pt;
// TODO
- //debug("getNamedPointPosition(%08X) UNKNOWN", namedPointId);
+ switch (namedPointId) {
+ case 0x70001:
+ return Common::Point(0, 0);
+ case 0x70002:
+ return Common::Point(640, 0);
+ case 0x70023:
+ return Common::Point(320, 240);
+ }
+ debug("getNamedPointPosition(%08X) UNKNOWN", namedPointId);
return Common::Point(0, 0);
}
diff --git a/engines/illusions/illusions_duckman.cpp b/engines/illusions/illusions_duckman.cpp
index 3f32ad48e6..3a87b09b25 100644
--- a/engines/illusions/illusions_duckman.cpp
+++ b/engines/illusions/illusions_duckman.cpp
@@ -37,6 +37,7 @@
#include "illusions/scriptopcodes_duckman.h"
#include "illusions/scriptresource.h"
#include "illusions/scriptman.h"
+#include "illusions/sound.h"
#include "illusions/soundresource.h"
#include "illusions/specialcode.h"
//TODO#include "illusions/bbdou/bbdou_specialcode.h"
@@ -105,6 +106,7 @@ Common::Error IllusionsEngine_Duckman::run() {
_talkItems = new TalkItems(this);
_threads = new ThreadList(this);
_updateFunctions = new UpdateFunctions();
+ _soundMan = new SoundMan(this);
_fader = new Fader();
@@ -142,6 +144,15 @@ Common::Error IllusionsEngine_Duckman::run() {
startScriptThread(0x00020004, 0);
_doScriptThreadInit = true;
+ //DEBUG
+ _scriptResource->_properties.set(0x000E003A, true);
+ _scriptResource->_properties.set(0x000E0020, true);
+ _scriptResource->_properties.set(0x000E003A, true);
+ _scriptResource->_properties.set(0x000E003B, true);
+ _scriptResource->_properties.set(0x000E0009, true);
+ _scriptResource->_properties.set(0x000E003D, true);
+ _scriptResource->_properties.set(0x000E0024, true);
+
while (!shouldQuit()) {
runUpdateFunctions();
_system->updateScreen();
@@ -154,6 +165,7 @@ Common::Error IllusionsEngine_Duckman::run() {
delete _fader;
+ delete _soundMan;
delete _updateFunctions;
delete _threads;
delete _talkItems;
@@ -192,6 +204,7 @@ void IllusionsEngine_Duckman::initUpdateFunctions() {
UPDATEFUNCTION(60, 0, updateSequences);
UPDATEFUNCTION(70, 0, updateGraphics);
UPDATEFUNCTION(90, 0, updateSprites);
+ UPDATEFUNCTION(120, 0, updateSoundMan);
}
#undef UPDATEFUNCTION
@@ -1206,6 +1219,8 @@ typedef Common::Functor1Mem<OpCall&, void, IllusionsEngine_Duckman> SpecialCodeF
void IllusionsEngine_Duckman::initSpecialCode() {
SPECIAL(0x00160001, spcStartScreenShaker);
SPECIAL(0x00160002, spcSetCursorHandMode);
+ SPECIAL(0x00160003, spcResetChinesePuzzle);
+ SPECIAL(0x00160004, spcAddChinesePuzzleAnswer);
SPECIAL(0x00160005, spcOpenInventory);
SPECIAL(0x00160007, spcPutBackInventoryItem);
SPECIAL(0x00160008, spcClearInventorySlot);
@@ -1226,6 +1241,8 @@ void IllusionsEngine_Duckman::runSpecialCode(uint32 specialCodeId, OpCall &opCal
}
}
+// TODO Move to separate file
+
static const ScreenShakerPoint kShakerPoints0[] = {
{0, -2}, {0, -4}, {0, -3}, {0, -1}, {0, 1}
};
@@ -1234,15 +1251,64 @@ static const ScreenShakeEffect kShakerEffect0 = {
6, 5, kShakerPoints0
};
-static const ScreenShakeEffect *kShakerEffects = {
- &kShakerEffect0
+static const ScreenShakerPoint kShakerPoints1[] = {
+ {-4, -5}, {4, 5}, {-3, -4}, {3, 4}, {-2, -3}, {2, 3}, {-1, -2},
+ { 1, 2}, {0, -1}
+};
+
+static const ScreenShakeEffect kShakerEffect1 = {
+ 9, 2, kShakerPoints1
+};
+
+static const ScreenShakerPoint kShakerPoints2[] = {
+ {0, -3}, {0, 3}, {0, -2}, {0, 2}, {0, -2}, {0, 2}, {0, -1},
+ {0, 1}, {0, -1},
+};
+
+static const ScreenShakeEffect kShakerEffect2 = {
+ 9, 2, kShakerPoints2
+};
+
+static const ScreenShakerPoint kShakerPoints3[] = {
+ {0, 1}, {0, -1}, {0, -2}, {0, 0}, {(int16)32768, 0}
+};
+
+static const ScreenShakeEffect kShakerEffect3 = {
+ 5, 2, kShakerPoints3
+};
+
+static const ScreenShakerPoint kShakerPoints4[] = {
+ {0, 4}, {0, -1}, {0, 3}, {0, -2}, {0, 1}, {0, -1}, {0, 1}, {0, -1}
+};
+
+static const ScreenShakeEffect kShakerEffect4 = {
+ 8, 5, kShakerPoints4
+};
+
+static const ScreenShakerPoint kShakerPoints5[] = {
+ {0, -1}, {0, 0}, {0, 1}, {0, 0}, {0, -1}, {0, 0}, {0, 1}, {0, 0},
+ {0, -1}, {0, 0}, {0, 1}, {0, 0}, {0, -1}, {0, 0}, {0, 1}, {0, 0},
+ {0, -1}, {0, 0}, {0, 1}, {0, 0}, {0, -1}, {0, 0}, {0, 1}, {0, 0},
+ {0, -1}, {0, 0}, {0, 1}, {0, 0}, {0, -1}, {0, 0}, {0, 1}, {0, 0}
+};
+
+static const ScreenShakeEffect kShakerEffect5 = {
+ 31, 2, kShakerPoints5
+};
+
+static const ScreenShakeEffect *kShakerEffects[] = {
+ &kShakerEffect0,
+ &kShakerEffect1,
+ &kShakerEffect2,
+ &kShakerEffect3,
+ &kShakerEffect4,
+ &kShakerEffect5
};
void IllusionsEngine_Duckman::spcStartScreenShaker(OpCall &opCall) {
- // TODO Add more effects
ARG_BYTE(effect);
debug("### effect: %d", effect);
- const ScreenShakeEffect *shakerEffect = &kShakerEffects[effect];
+ const ScreenShakeEffect *shakerEffect = kShakerEffects[effect];
startScreenShaker(shakerEffect->_pointsCount, shakerEffect->_duration, shakerEffect->_points, opCall._threadId);
}
@@ -1252,6 +1318,28 @@ void IllusionsEngine_Duckman::spcSetCursorHandMode(OpCall &opCall) {
notifyThreadId(opCall._threadId);
}
+void IllusionsEngine_Duckman::spcResetChinesePuzzle(OpCall &opCall) {
+ _scriptResource->_properties.set(0x000E0018, false);
+ _scriptResource->_properties.set(0x000E0019, false);
+ _chinesePuzzleIndex = 0;
+ notifyThreadId(opCall._threadId);
+}
+
+void IllusionsEngine_Duckman::spcAddChinesePuzzleAnswer(OpCall &opCall) {
+ ARG_BYTE(answer);
+ _chinesePuzzleAnswers[_chinesePuzzleIndex++] = answer;
+ if (_chinesePuzzleIndex == 3) {
+ _scriptResource->_properties.set(0x000E0018, true);
+ if ((_chinesePuzzleAnswers[0] == 7 && _chinesePuzzleAnswers[1] == 2 && _chinesePuzzleAnswers[2] == 5) ||
+ (_chinesePuzzleAnswers[0] == 5 && _chinesePuzzleAnswers[1] == 2 && _chinesePuzzleAnswers[2] == 7))
+ _scriptResource->_properties.set(0x000E0019, true);
+ else if ((_chinesePuzzleAnswers[0] == 7 && _chinesePuzzleAnswers[1] == 2 && _chinesePuzzleAnswers[2] == 1) ||
+ (_chinesePuzzleAnswers[0] == 1 && _chinesePuzzleAnswers[1] == 2 && _chinesePuzzleAnswers[2] == 7))
+ _scriptResource->_properties.set(0x000E00A0, true);
+ }
+ notifyThreadId(opCall._threadId);
+}
+
void IllusionsEngine_Duckman::spcOpenInventory(OpCall &opCall) {
openInventory();
notifyThreadId(opCall._threadId);
diff --git a/engines/illusions/illusions_duckman.h b/engines/illusions/illusions_duckman.h
index 305a531c98..48d8ef28ca 100644
--- a/engines/illusions/illusions_duckman.h
+++ b/engines/illusions/illusions_duckman.h
@@ -125,6 +125,9 @@ public:
ScreenShaker *_screenShaker;
+ uint _chinesePuzzleIndex;
+ byte _chinesePuzzleAnswers[3];
+
SpecialCodeMap _specialCodeMap;
void initUpdateFunctions();
@@ -146,7 +149,7 @@ public:
Common::Point getNamedPointPosition(uint32 namedPointId);
uint32 getPriorityFromBase(int16 priority);
uint32 getCurrentScene();
- uint32 getPrevScene();
+ uint32 getPrevScene();
bool isCursorObject(uint32 actorTypeId, uint32 objectId);
void setCursorControlRoutine(Control *control);
@@ -222,6 +225,8 @@ public:
void runSpecialCode(uint32 specialCodeId, OpCall &opCall);
void spcStartScreenShaker(OpCall &opCall);
void spcSetCursorHandMode(OpCall &opCall);
+ void spcResetChinesePuzzle(OpCall &opCall);
+ void spcAddChinesePuzzleAnswer(OpCall &opCall);
void spcOpenInventory(OpCall &opCall);
void spcPutBackInventoryItem(OpCall &opCall);
void spcClearInventorySlot(OpCall &opCall);
diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk
index 4f2b58af8e..1bdec55592 100644
--- a/engines/illusions/module.mk
+++ b/engines/illusions/module.mk
@@ -33,6 +33,7 @@ MODULE_OBJS := \
scriptresource.o \
scriptthread.o \
sequenceopcodes.o \
+ sound.o \
soundresource.o \
specialcode.o \
talkresource.o \
diff --git a/engines/illusions/screentext.cpp b/engines/illusions/screentext.cpp
index 60fc9011d3..37c52c0618 100644
--- a/engines/illusions/screentext.cpp
+++ b/engines/illusions/screentext.cpp
@@ -110,7 +110,8 @@ bool ScreenText::insertText(uint16 *text, uint32 fontId, WidthHeight dimensions,
bool done = refreshScreenText(font, screenText->_info._dimensions, screenText->_info._offsPt,
text, screenText->_info._flags, screenText->_info._color2, screenText->_info._color1,
outTextPtr);
- //_vm->_screen->setPaletteEntry(font->getColorIndex(), screenText->_info._colorR, screenText->_info._colorG, screenText->_info._colorB);
+ debug("font->getColorIndex(): %d", font->getColorIndex());
+ _vm->_screen->setPaletteEntry(font->getColorIndex(), screenText->_info._colorR, screenText->_info._colorG, screenText->_info._colorB);
uint16 *textPart = screenText->_text;
while (text != outTextPtr)
diff --git a/engines/illusions/scriptopcodes_bbdou.cpp b/engines/illusions/scriptopcodes_bbdou.cpp
index ff5c98fa2b..30cd023974 100644
--- a/engines/illusions/scriptopcodes_bbdou.cpp
+++ b/engines/illusions/scriptopcodes_bbdou.cpp
@@ -30,6 +30,7 @@
#include "illusions/scriptman.h"
#include "illusions/scriptresource.h"
#include "illusions/scriptthread.h"
+#include "illusions/sound.h"
#include "illusions/specialcode.h"
#include "illusions/talkresource.h"
@@ -526,11 +527,11 @@ void ScriptOpcodes_BBDOU::opStartMusic(ScriptThread *scriptThread, OpCall &opCal
ARG_INT16(pan);
ARG_UINT32(musicId);
ARG_UINT32(type);
- // TODO _vm->playMusic(musicId, type, volume, pan);
+ _vm->_soundMan->playMusic(musicId, type, volume, pan, opCall._threadId);
}
void ScriptOpcodes_BBDOU::opStopMusic(ScriptThread *scriptThread, OpCall &opCall) {
- // TODO _vm->stopMusic();
+ _vm->_soundMan->stopMusic();
}
void ScriptOpcodes_BBDOU::opStackPushRandom(ScriptThread *scriptThread, OpCall &opCall) {
diff --git a/engines/illusions/scriptopcodes_duckman.cpp b/engines/illusions/scriptopcodes_duckman.cpp
index 971a8eeb7e..a1e5e1cb9a 100644
--- a/engines/illusions/scriptopcodes_duckman.cpp
+++ b/engines/illusions/scriptopcodes_duckman.cpp
@@ -244,18 +244,20 @@ void ScriptOpcodes_Duckman::opEnterScene18(ScriptThread *scriptThread, OpCall &o
//static uint dsceneId = 0, dthreadId = 0;
//static uint dsceneId = 0x00010008, dthreadId = 0x00020029;//Beginning in Jac
+//static uint dsceneId = 0x0001000A, dthreadId = 0x00020043;//Home front
+//static uint dsceneId = 0x0001000E, dthreadId = 0x0002007C;
//static uint dsceneId = 0x00010012, dthreadId = 0x0002009D;//Paramount
-//static uint dsceneId = 0x00010039, dthreadId = 0x00020089;//Map
-//static uint dsceneId = 0x00010033, dthreadId = 0x000201A4;//Chinese
//static uint dsceneId = 0x00010020, dthreadId = 0x00020112;//Xmas
-//static uint dsceneId = 0x00010039, dthreadId = 0x00020089;//Pizza
-//static uint dsceneId = 0x0001002D, dthreadId = 0x00020141;
-//static uint dsceneId = 0x0001004B, dthreadId = 0x0002029B;
//static uint dsceneId = 0x00010021, dthreadId = 0x00020113;
-static uint dsceneId = 0x0001000A, dthreadId = 0x00020043;//Home front
-//static uint dsceneId = 0x0001000E, dthreadId = 0x0002007C;
//static uint dsceneId = 0x00010022, dthreadId = 0x00020114;
+//static uint dsceneId = 0x0001002D, dthreadId = 0x00020141;
+static uint dsceneId = 0x00010033, dthreadId = 0x000201A4;//Chinese
+//static uint dsceneId = 0x00010036, dthreadId = 0x000201B5;
+//static uint dsceneId = 0x00010039, dthreadId = 0x00020089;//Map
//static uint dsceneId = 0x0001003D, dthreadId = 0x000201E0;
+//static uint dsceneId = 0x0001004B, dthreadId = 0x0002029B;
+//static uint dsceneId = 0x0001005B, dthreadId = 0x00020341;
+
void ScriptOpcodes_Duckman::opChangeScene(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
diff --git a/engines/illusions/sound.cpp b/engines/illusions/sound.cpp
new file mode 100644
index 0000000000..632b842d6f
--- /dev/null
+++ b/engines/illusions/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 "illusions/illusions.h"
+#include "illusions/sound.h"
+
+namespace Illusions {
+
+// MusicPlayer
+
+MusicPlayer::MusicPlayer(Audio::Mixer *mixer)
+ : _mixer(mixer), _musicId(0), _flags(0) {
+ _flags = 1; // TODO?
+}
+
+MusicPlayer::~MusicPlayer() {
+}
+
+void MusicPlayer::play(uint32 musicId, bool looping, int16 volume, int16 pan) {
+ debug("MusicPlayer::play(%08X)", musicId);
+ if (_flags & 1) {
+ stop();
+ _musicId = musicId;
+ Common::String filename = Common::String::format("%08x.wav", _musicId);
+ _flags |= 2;
+ _flags &= ~4;
+ if (looping) {
+ _flags |= 8;
+ } else {
+ _flags &= ~8;
+ }
+ Common::File *fd = new Common::File();
+ fd->open(filename);
+ Audio::AudioStream *audioStream = Audio::makeLoopingAudioStream(Audio::makeWAVStream(fd, DisposeAfterUse::YES), looping ? 0 : 1);
+ _mixer->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, audioStream, -1, volume, pan);
+ }
+}
+
+void MusicPlayer::stop() {
+ debug("MusicPlayer::stop()");
+ if ((_flags & 1) && (_flags & 2)) {
+ if (_mixer->isSoundHandleActive(_soundHandle))
+ _mixer->stopHandle(_soundHandle);
+ _flags &= ~2;
+ _flags &= ~4;
+ _flags &= ~8;
+ _musicId = 0;
+ }
+}
+
+bool MusicPlayer::isPlaying() {
+ return (_flags & 1) && (_flags & 2) && _mixer->isSoundHandleActive(_soundHandle);
+}
+
+// SoundMan
+
+SoundMan::SoundMan(IllusionsEngine *vm)
+ : _vm(vm), _musicNotifyThreadId(0) {
+ _musicPlayer = new MusicPlayer(_vm->_mixer);
+}
+
+SoundMan::~SoundMan() {
+ delete _musicPlayer;
+}
+
+void SoundMan::update() {
+ // TODO voc_testCued();
+ if (_musicNotifyThreadId && !_musicPlayer->isPlaying())
+ _vm->notifyThreadId(_musicNotifyThreadId);
+}
+
+void SoundMan::playMusic(uint32 musicId, int16 type, int16 volume, int16 pan, uint32 notifyThreadId) {
+ _vm->notifyThreadId(_musicNotifyThreadId);
+ _musicPlayer->play(musicId, type == 2, volume, pan);
+ _musicNotifyThreadId = notifyThreadId;
+}
+
+void SoundMan::stopMusic() {
+ _musicPlayer->stop();
+}
+
+} // End of namespace Illusions
diff --git a/engines/illusions/sound.h b/engines/illusions/sound.h
new file mode 100644
index 0000000000..e5139d3161
--- /dev/null
+++ b/engines/illusions/sound.h
@@ -0,0 +1,65 @@
+/* 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 ILLUSIONS_SOUND_H
+#define ILLUSIONS_SOUND_H
+
+#include "illusions/graphics.h"
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "audio/decoders/wave.h"
+#include "common/list.h"
+
+namespace Illusions {
+
+class IllusionsEngine;
+
+class MusicPlayer {
+public:
+ MusicPlayer(Audio::Mixer *mixer);
+ ~MusicPlayer();
+ void play(uint32 musicId, bool looping, int16 volume, int16 pan);
+ void stop();
+ bool isPlaying();
+protected:
+ Audio::Mixer *_mixer;
+ Audio::SoundHandle _soundHandle;
+ uint32 _musicId;
+ uint _flags;
+};
+
+class SoundMan {
+public:
+ SoundMan(IllusionsEngine *vm);
+ ~SoundMan();
+ void update();
+ void playMusic(uint32 musicId, int16 type, int16 volume, int16 pan, uint32 notifyThreadId);
+ void stopMusic();
+protected:
+ IllusionsEngine *_vm;
+ uint32 _musicNotifyThreadId;
+ MusicPlayer *_musicPlayer;
+};
+
+} // End of namespace Illusions
+
+#endif // ILLUSIONS_SOUND_H
diff --git a/engines/illusions/talkthread_duckman.cpp b/engines/illusions/talkthread_duckman.cpp
index 8c290718d8..990d1be90b 100644
--- a/engines/illusions/talkthread_duckman.cpp
+++ b/engines/illusions/talkthread_duckman.cpp
@@ -113,7 +113,7 @@ int TalkThread_Duckman::onUpdate() {
case 4:
if (!(_flags & 8) ) {
uint32 actorTypeId = _vm->getObjectActorTypeId(_objectId);
- // TODO getActorTypeColor(actorTypeId, &_colorR, &_colorG, &_colorB);
+ getActorTypeColor(actorTypeId, _color);
refreshText();
}
if (!(_flags & 2)) {
@@ -289,7 +289,8 @@ int TalkThread_Duckman::insertText() {
WidthHeight dimensions;
_vm->getDefaultTextDimensions(dimensions);
uint16 *outTextPtr;
- _vm->_screenText->insertText((uint16*)_currEntryText, 0x120001, dimensions, Common::Point(0, 0), 2, 0, 0, _colorR, _colorG, _colorB, outTextPtr);
+ _vm->_screenText->insertText((uint16*)_currEntryText, 0x120001, dimensions,
+ Common::Point(0, 0), 2, 0, 0, _color.r, _color.r, _color.r, outTextPtr);
_entryText = (byte*)outTextPtr;
Common::Point pt;
_vm->getDefaultTextPosition(pt);
@@ -303,4 +304,9 @@ TalkEntry *TalkThread_Duckman::getTalkResourceEntry(uint32 talkId) {
return talkEntry;
}
+void TalkThread_Duckman::getActorTypeColor(uint32 actorTypeId, RGB &color) {
+ ActorType *actorType = _vm->_dict->findActorType(actorTypeId);
+ color = actorType->_color;
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/talkthread_duckman.h b/engines/illusions/talkthread_duckman.h
index 656dab72f0..b729ad2d8f 100644
--- a/engines/illusions/talkthread_duckman.h
+++ b/engines/illusions/talkthread_duckman.h
@@ -75,10 +75,11 @@ public:
uint32 _voiceDuration;
uint32 _voiceDurationElapsed;
int *_pauseCtrPtr;
- byte _colorR, _colorG, _colorB;
+ RGB _color;
void refreshText();
int insertText();
TalkEntry *getTalkResourceEntry(uint32 talkId);
+ void getActorTypeColor(uint32 actorTypeId, RGB &color);
};
} // End of namespace Illusions