aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb
diff options
context:
space:
mode:
Diffstat (limited to 'engines/dreamweb')
-rw-r--r--engines/dreamweb/dreamweb.cpp23
-rw-r--r--engines/dreamweb/dreamweb.h44
-rw-r--r--engines/dreamweb/keypad.cpp23
-rw-r--r--engines/dreamweb/monitor.cpp13
-rw-r--r--engines/dreamweb/newplace.cpp5
-rw-r--r--engines/dreamweb/object.cpp2
-rw-r--r--engines/dreamweb/people.cpp16
-rw-r--r--engines/dreamweb/print.cpp24
-rw-r--r--engines/dreamweb/rain.cpp7
-rw-r--r--engines/dreamweb/saveload.cpp28
-rw-r--r--engines/dreamweb/sound.cpp166
-rw-r--r--engines/dreamweb/sound.h91
-rw-r--r--engines/dreamweb/sprite.cpp26
-rw-r--r--engines/dreamweb/stubs.cpp64
-rw-r--r--engines/dreamweb/talk.cpp32
-rw-r--r--engines/dreamweb/titles.cpp68
-rw-r--r--engines/dreamweb/use.cpp33
-rw-r--r--engines/dreamweb/vgafades.cpp5
-rw-r--r--engines/dreamweb/vgagrafx.cpp4
19 files changed, 348 insertions, 326 deletions
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 11e8e3f8cc..0ca98d5a7b 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -35,6 +35,7 @@
#include "graphics/palette.h"
#include "graphics/surface.h"
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -46,21 +47,15 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam
_roomDesc(kNumRoomTexts), _freeDesc(kNumFreeTexts),
_personText(kNumPersonTexts) {
- // Setup mixer
- _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
- _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
- _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
-
_vSyncInterrupt = false;
_console = 0;
+ _sound = 0;
DebugMan.addDebugChannel(kDebugAnimation, "Animation", "Animation Debug Flag");
DebugMan.addDebugChannel(kDebugSaveLoad, "SaveLoad", "Track Save/Load Function");
_speed = 1;
_turbo = false;
_oldMouseState = 0;
- _channel0 = 0;
- _channel1 = 0;
_datafilePrefix = "DREAMWEB.";
_speechDirName = "SPEECH";
@@ -85,16 +80,6 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam
_openChangeSize = kInventx+(4*kItempicsize);
_quitRequested = false;
- _currentSample = 0xff;
- _channel0Playing = 0;
- _channel0Repeat = 0;
- _channel1Playing = 0xff;
-
- _volume = 0;
- _volumeTo = 0;
- _volumeDirection = 0;
- _volumeCount = 0;
-
_speechLoaded = false;
_backdropBlocks = 0;
@@ -246,6 +231,7 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam
DreamWebEngine::~DreamWebEngine() {
DebugMan.clearAllDebugChannels();
delete _console;
+ delete _sound;
}
static void vSyncInterrupt(void *refCon) {
@@ -286,7 +272,7 @@ void DreamWebEngine::processEvents() {
return;
}
- soundHandler();
+ _sound->soundHandler();
Common::Event event;
int softKey, hardKey;
while (_eventMan->pollEvent(event)) {
@@ -382,6 +368,7 @@ void DreamWebEngine::processEvents() {
Common::Error DreamWebEngine::run() {
syncSoundSettings();
_console = new DreamWebConsole(this);
+ _sound = new DreamWebSound(this);
ConfMan.registerDefault("originalsaveload", "false");
ConfMan.registerDefault("bright_palette", true);
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index 6744b53ebc..48d44c0380 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -99,10 +99,12 @@ enum {
};
struct DreamWebGameDescription;
+class DreamWebSound;
class DreamWebEngine : public Engine {
private:
DreamWebConsole *_console;
+ DreamWebSound *_sound;
bool _vSyncInterrupt;
protected:
@@ -142,7 +144,6 @@ public:
void quit();
- void loadSounds(uint bank, const Common::String &suffix);
bool loadSpeech(const Common::String &filename);
void enableSavingOrLoading(bool enable = true) { _enableSavingOrLoading = enable; }
@@ -151,15 +152,12 @@ public:
uint8 modifyChar(uint8 c) const;
Common::String modifyFileName(const char *);
- void stopSound(uint8 channel);
-
const Common::String& getDatafilePrefix() { return _datafilePrefix; };
+ const Common::String& getSpeechDirName() { return _speechDirName; };
private:
void keyPressed(uint16 ascii);
void setSpeed(uint speed);
- void soundHandler();
- void playSound(uint8 channel, uint8 id, uint8 loops);
const DreamWebGameDescription *_gameDescription;
Common::RandomSource _rnd;
@@ -171,22 +169,6 @@ private:
uint _oldMouseState;
bool _enableSavingOrLoading;
- struct Sample {
- uint offset;
- uint size;
- Sample(): offset(), size() {}
- };
-
- struct SoundData {
- Common::Array<Sample> samples;
- Common::Array<uint8> data;
- };
- SoundData _soundData[2];
- Common::Array<uint8> _speechData;
-
- Audio::SoundHandle _channelHandle[2];
- uint8 _channel0, _channel1;
-
protected:
GameVars _vars; // saved variables
@@ -327,16 +309,6 @@ public:
// sound related
uint8 _roomsSample;
- uint8 _currentSample;
- uint8 _channel0Playing;
- uint8 _channel0Repeat;
- uint8 _channel1Playing;
-
- uint8 _volume;
- uint8 _volumeTo;
- int8 _volumeDirection;
- uint8 _volumeCount;
-
bool _speechLoaded;
// misc variables
@@ -715,15 +687,6 @@ public:
void showSaveOps();
void showLoadOps();
- // from sound.cpp
- bool loadSpeech(byte type1, int idx1, byte type2, int idx2);
- void volumeAdjust();
- void cancelCh0();
- void cancelCh1();
- void loadRoomsSample();
- void playChannel0(uint8 index, uint8 repeat);
- void playChannel1(uint8 index);
-
// from sprite.cpp
void printSprites();
void printASprite(const Sprite *sprite);
@@ -1135,7 +1098,6 @@ public:
void frameOutBh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
void frameOutFx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
void doShake();
- void vSync();
void setMode();
void showPCX(const Common::String &suffix);
void showFrameInternal(const uint8 *pSrc, uint16 x, uint16 y, uint8 effectsFlag, uint8 width, uint8 height);
diff --git a/engines/dreamweb/keypad.cpp b/engines/dreamweb/keypad.cpp
index 2ab5835997..3580f8ad52 100644
--- a/engines/dreamweb/keypad.cpp
+++ b/engines/dreamweb/keypad.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -62,11 +63,11 @@ void DreamWebEngine::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 d
readMouse();
showKeypad();
showPointer();
- vSync();
+ waitForVSync();
if (_pressCount == 0) {
_pressed = 255;
_graphicPress = 255;
- vSync();
+ waitForVSync();
} else
--_pressCount;
@@ -85,7 +86,7 @@ void DreamWebEngine::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 d
if (_pressed == 11) {
if (isItRight(digit0, digit1, digit2, digit3))
_vars._lockStatus = 0;
- playChannel1(11);
+ _sound->playChannel1(11);
_lightCount = 120;
_pressPointer = 0;
}
@@ -180,7 +181,7 @@ void DreamWebEngine::buttonPress(uint8 buttonId) {
_graphicPress = buttonId + 21;
_pressCount = 40;
if (buttonId != 11)
- playChannel1(10);
+ _sound->playChannel1(10);
}
}
@@ -252,7 +253,7 @@ void DreamWebEngine::useMenu() {
showMenu();
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpMenu();
dumpTextLine();
@@ -311,7 +312,7 @@ void DreamWebEngine::viewFolder() {
delPointer();
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
checkFolderCoords();
@@ -508,7 +509,7 @@ void DreamWebEngine::enterSymbol() {
showSymbol();
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
dumpSymbol();
@@ -532,7 +533,7 @@ void DreamWebEngine::enterSymbol() {
_symbolGraphics.clear();
restoreReels();
workToScreenM();
- playChannel1(13);
+ _sound->playChannel1(13);
} else {
removeSetObject(46);
placeSetObject(43);
@@ -743,7 +744,7 @@ void DreamWebEngine::useDiary() {
readMouse();
showDiaryKeys();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpDiaryKeys();
dumpTextLine();
@@ -820,7 +821,7 @@ void DreamWebEngine::diaryKeyP() {
_pressCount)
return; // notkeyp
- playChannel1(16);
+ _sound->playChannel1(16);
_pressCount = 12;
_pressed = 'P';
_diaryPage--;
@@ -837,7 +838,7 @@ void DreamWebEngine::diaryKeyN() {
_pressCount)
return; // notkeyn
- playChannel1(16);
+ _sound->playChannel1(16);
_pressCount = 12;
_pressed = 'N';
_diaryPage++;
diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp
index 25435ae0e9..4e9d8eecc1 100644
--- a/engines/dreamweb/monitor.cpp
+++ b/engines/dreamweb/monitor.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -97,7 +98,7 @@ void DreamWebEngine::useMon() {
_textFile3.clear();
_getBack = 1;
- playChannel1(26);
+ _sound->playChannel1(26);
_manIsOffScreen = 0;
restoreAll();
redrawMainScrn();
@@ -180,7 +181,7 @@ void DreamWebEngine::monitorLogo() {
printLogo();
//fadeUpMon(); // FIXME: Commented out in ASM
printLogo();
- playChannel1(26);
+ _sound->playChannel1(26);
randomAccess(20);
} else {
printLogo();
@@ -202,7 +203,7 @@ void DreamWebEngine::input() {
_cursLocY = _monAdY;
while (true) {
printCurs();
- vSync();
+ waitForVSync();
delCurs();
readKey();
if (_quitRequested)
@@ -288,7 +289,7 @@ void DreamWebEngine::scrollMonitor() {
printLogo();
printUnderMonitor();
workToScreen();
- playChannel1(25);
+ _sound->playChannel1(25);
}
void DreamWebEngine::showCurrentFile() {
@@ -318,8 +319,8 @@ void DreamWebEngine::accessLightOff() {
void DreamWebEngine::randomAccess(uint16 count) {
for (uint16 i = 0; i < count; ++i) {
- vSync();
- vSync();
+ waitForVSync();
+ waitForVSync();
uint16 v = _rnd.getRandomNumber(15);
if (v < 10)
accessLightOff();
diff --git a/engines/dreamweb/newplace.cpp b/engines/dreamweb/newplace.cpp
index 529c45bd4a..5b4b0260f5 100644
--- a/engines/dreamweb/newplace.cpp
+++ b/engines/dreamweb/newplace.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -55,7 +56,7 @@ void DreamWebEngine::selectLocation() {
_pointerFrame = 0;
showPointer();
workToScreen();
- playChannel0(9, 255);
+ _sound->playChannel0(9, 255);
_newLocation = 255;
while (_newLocation == 255) {
@@ -65,7 +66,7 @@ void DreamWebEngine::selectLocation() {
delPointer();
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 443366561a..b42591ef91 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -147,7 +147,7 @@ void DreamWebEngine::examineOb(bool examineAgain) {
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
delPointer();
diff --git a/engines/dreamweb/people.cpp b/engines/dreamweb/people.cpp
index dfb5c62618..36a756a49b 100644
--- a/engines/dreamweb/people.cpp
+++ b/engines/dreamweb/people.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -149,7 +150,7 @@ void DreamWebEngine::madmanText() {
if (hasSpeech()) {
if (_speechCount > 15)
return;
- if (_channel1Playing != 255)
+ if (_sound->isChannel1Playing())
return;
origCount = _speechCount;
++_speechCount;
@@ -250,7 +251,7 @@ bool DreamWebEngine::checkSpeed(ReelRoutine &routine) {
void DreamWebEngine::sparkyDrip(ReelRoutine &routine) {
if (checkSpeed(routine))
- playChannel0(14, 0);
+ _sound->playChannel0(14, 0);
}
void DreamWebEngine::genericPerson(ReelRoutine &routine) {
@@ -430,7 +431,7 @@ void DreamWebEngine::drinker(ReelRoutine &routine) {
void DreamWebEngine::alleyBarkSound(ReelRoutine &routine) {
uint16 prevReelPointer = routine.reelPointer() - 1;
if (prevReelPointer == 0) {
- playChannel1(14);
+ _sound->playChannel1(14);
routine.setReelPointer(1000);
} else {
routine.setReelPointer(prevReelPointer);
@@ -523,7 +524,7 @@ void DreamWebEngine::gates(ReelRoutine &routine) {
if (checkSpeed(routine)) {
uint16 nextReelPointer = routine.reelPointer() + 1;
if (nextReelPointer == 116)
- playChannel1(17);
+ _sound->playChannel1(17);
if (nextReelPointer >= 110)
routine.period = 2;
if (nextReelPointer == 120) {
@@ -579,12 +580,12 @@ void DreamWebEngine::carParkDrip(ReelRoutine &routine) {
if (!checkSpeed(routine))
return; // cantdrip2
- playChannel1(14);
+ _sound->playChannel1(14);
}
void DreamWebEngine::foghornSound(ReelRoutine &routine) {
if (randomNumber() == 198)
- playChannel1(13);
+ _sound->playChannel1(13);
}
void DreamWebEngine::train(ReelRoutine &routine) {
@@ -1027,8 +1028,7 @@ void DreamWebEngine::endGameSeq(ReelRoutine &routine) {
fadeScreenDownHalf();
} else if (nextReelPointer == 324) {
fadeScreenDowns();
- _volumeTo = 7;
- _volumeDirection = 1;
+ _sound->volumeChange(7, 1);
}
if (nextReelPointer == 340)
diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp
index a6b93a5590..3a2c45e07b 100644
--- a/engines/dreamweb/print.cpp
+++ b/engines/dreamweb/print.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -197,7 +198,7 @@ uint8 DreamWebEngine::kernChars(uint8 firstChar, uint8 secondChar, uint8 width)
uint16 DreamWebEngine::waitFrames() {
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
delPointer();
return _mouseButton;
@@ -231,7 +232,7 @@ const char *DreamWebEngine::monPrint(const char *string) {
_cursLocY = _monAdY;
_mainTimer = 1;
printCurs();
- vSync();
+ waitForVSync();
lockMon();
delCurs();
} while (--count);
@@ -246,10 +247,9 @@ const char *DreamWebEngine::monPrint(const char *string) {
}
void DreamWebEngine::rollEndCreditsGameWon() {
- playChannel0(16, 255);
- _volume = 7;
- _volumeTo = 0;
- _volumeDirection = -1;
+ _sound->playChannel0(16, 255);
+ _sound->volumeSet(7);
+ _sound->volumeChange(0, -1);
multiGet(_mapStore, 75, 20, 160, 160);
@@ -261,9 +261,9 @@ void DreamWebEngine::rollEndCreditsGameWon() {
// then move it up one pixel until we shifted it by a complete
// line of text.
for (int j = 0; j < linespacing; ++j) {
- vSync();
+ waitForVSync();
multiPut(_mapStore, 75, 20, 160, 160);
- vSync();
+ waitForVSync();
// Output up to 18 lines of text
uint16 y = 10 - j;
@@ -273,7 +273,7 @@ void DreamWebEngine::rollEndCreditsGameWon() {
y += linespacing;
}
- vSync();
+ waitForVSync();
multiDump(75, 20, 160, 160);
}
@@ -300,9 +300,9 @@ void DreamWebEngine::rollEndCreditsGameLost() {
// then move it up one pixel until we shifted it by a complete
// line of text.
for (int j = 0; j < linespacing; ++j) {
- vSync();
+ waitForVSync();
multiPut(_mapStore, 25, 20, 160, 160);
- vSync();
+ waitForVSync();
// Output up to 18 lines of text
uint16 y = 10 - j;
@@ -312,7 +312,7 @@ void DreamWebEngine::rollEndCreditsGameLost() {
y += linespacing;
}
- vSync();
+ waitForVSync();
multiDump(25, 20, 160, 160);
if (_lastHardKey == 1)
diff --git a/engines/dreamweb/rain.cpp b/engines/dreamweb/rain.cpp
index 7db4744cbf..8e42e0c161 100644
--- a/engines/dreamweb/rain.cpp
+++ b/engines/dreamweb/rain.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -50,7 +51,7 @@ void DreamWebEngine::showRain() {
}
}
- if (_channel1Playing != 255)
+ if (_sound->isChannel1Playing())
return;
if (_realLocation == 2 && _vars._beenMugged != 1)
return;
@@ -61,11 +62,11 @@ void DreamWebEngine::showRain() {
return;
uint8 soundIndex;
- if (_channel0Playing != 6)
+ if (_sound->getChannel0Playing() != 6)
soundIndex = 4;
else
soundIndex = 7;
- playChannel1(soundIndex);
+ _sound->playChannel1(soundIndex);
}
uint8 DreamWebEngine::getBlockOfPixel(uint8 x, uint8 y) {
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index d30bf754de..ea9cdc0249 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -20,7 +20,9 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
+
#include "engines/metaengine.h"
#include "graphics/thumbnail.h"
#include "gui/saveload.h"
@@ -136,7 +138,7 @@ void DreamWebEngine::doLoad(int savegameId) {
delPointer();
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
RectWithCallback loadlist[] = {
@@ -156,12 +158,8 @@ void DreamWebEngine::doLoad(int savegameId) {
if (savegameId == -1) {
// Open dialog to get savegameId
- const EnginePlugin *plugin = NULL;
- Common::String gameId = ConfMan.get("gameid");
- EngineMan.findGame(gameId, &plugin);
- GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"));
- dialog->setSaveMode(false);
- savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
+ GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+ savegameId = dialog->runModalWithCurrentTarget();
delete dialog;
}
@@ -181,7 +179,7 @@ void DreamWebEngine::doLoad(int savegameId) {
_saveGraphics.clear();
startLoading(g_madeUpRoomDat);
- loadRoomsSample();
+ _sound->loadRoomsSample(_roomsSample);
_roomLoaded = 1;
_newLocation = 255;
clearSprites();
@@ -227,7 +225,7 @@ void DreamWebEngine::saveGame() {
checkInput();
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
@@ -243,12 +241,8 @@ void DreamWebEngine::saveGame() {
}
return;
} else {
- const EnginePlugin *plugin = NULL;
- Common::String gameId = ConfMan.get("gameid");
- EngineMan.findGame(gameId, &plugin);
- GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"));
- dialog->setSaveMode(true);
- int savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
+ GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+ int savegameId = dialog->runModalWithCurrentTarget();
Common::String game_description = dialog->getResultString();
if (game_description.empty())
game_description = "Untitled";
@@ -348,7 +342,7 @@ void DreamWebEngine::doSaveLoad() {
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
delPointer();
@@ -429,7 +423,7 @@ void DreamWebEngine::discOps() {
delPointer();
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
checkCoords(discOpsList);
diff --git a/engines/dreamweb/sound.cpp b/engines/dreamweb/sound.cpp
index b3d5db9e0d..570f76f2f9 100644
--- a/engines/dreamweb/sound.cpp
+++ b/engines/dreamweb/sound.cpp
@@ -20,28 +20,51 @@
*
*/
-#include "dreamweb/dreamweb.h"
-
-#include "audio/mixer.h"
#include "audio/decoders/raw.h"
-
#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/file.h"
+
+#include "dreamweb/dreamweb.h"
+#include "dreamweb/sound.h"
namespace DreamWeb {
-bool DreamWebEngine::loadSpeech(byte type1, int idx1, byte type2, int idx2) {
+DreamWebSound::DreamWebSound(DreamWebEngine *vm) : _vm(vm) {
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
+
+ _currentSample = 0xff;
+ _channel0Playing = 255;
+ _channel0Repeat = 0;
+ _channel0NewSound = false;
+ _channel1Playing = 255;
+ _channel1NewSound = false;
+
+ _volume = 0;
+ _volumeTo = 0;
+ _volumeDirection = 0;
+ _volumeCount = 0;
+}
+
+DreamWebSound::~DreamWebSound() {
+}
+
+bool DreamWebSound::loadSpeech(byte type1, int idx1, byte type2, int idx2) {
cancelCh1();
Common::String name = Common::String::format("%c%02d%c%04d.RAW", type1, idx1, type2, idx2);
- //debug("name = %s", name.c_str());
- bool result = loadSpeech(name);
-
- _speechLoaded = result;
- return result;
+ debug(2, "loadSpeech() name:%s", name.c_str());
+ return loadSpeech(name);
}
+void DreamWebSound::volumeChange(uint8 value, int8 direction) {
+ _volumeTo = value;
+ _volumeDirection = direction;
+}
-void DreamWebEngine::volumeAdjust() {
+void DreamWebSound::volumeAdjust() {
if (_volumeDirection == 0)
return;
if (_volume != _volumeTo) {
@@ -54,39 +77,38 @@ void DreamWebEngine::volumeAdjust() {
}
}
-void DreamWebEngine::playChannel0(uint8 index, uint8 repeat) {
+void DreamWebSound::playChannel0(uint8 index, uint8 repeat) {
debug(1, "playChannel0(index:%d, repeat:%d)", index, repeat);
- _channel0Playing = index;
- if (index >= 12)
- index -= 12;
+ _channel0Playing = index;
_channel0Repeat = repeat;
+ _channel0NewSound = true;
}
-void DreamWebEngine::playChannel1(uint8 index) {
+void DreamWebSound::playChannel1(uint8 index) {
+ debug(1, "playChannel1(index:%d)", index);
if (_channel1Playing == 7)
return;
_channel1Playing = index;
- if (index >= 12)
- index -= 12;
+ _channel1NewSound = true;
}
-void DreamWebEngine::cancelCh0() {
+void DreamWebSound::cancelCh0() {
debug(1, "cancelCh0()");
- _channel0Repeat = 0;
_channel0Playing = 255;
+ _channel0Repeat = 0;
stopSound(0);
}
-void DreamWebEngine::cancelCh1() {
+void DreamWebSound::cancelCh1() {
+ debug(1, "cancelCh1()");
_channel1Playing = 255;
stopSound(1);
}
-void DreamWebEngine::loadRoomsSample() {
- debug(1, "loadRoomsSample() _roomsSample:%d", _roomsSample);
- uint8 sample = _roomsSample;
+void DreamWebSound::loadRoomsSample(uint8 sample) {
+ debug(1, "loadRoomsSample(sample:%d)", sample);
if (sample == 255 || _currentSample == sample)
return; // loaded already
@@ -104,13 +126,8 @@ void DreamWebEngine::loadRoomsSample() {
loadSounds(1, sampleSuffix.c_str());
}
-} // End of namespace DreamWeb
-
-
-namespace DreamWeb {
-
-void DreamWebEngine::playSound(uint8 channel, uint8 id, uint8 loops) {
- debug(1, "playSound(%u, %u, %u)", channel, id, loops);
+void DreamWebSound::playSound(uint8 channel, uint8 id, uint8 loops) {
+ debug(1, "playSound(channel:%u, id:%u, loops:%u)", channel, id, loops);
int bank = 0;
bool speech = false;
@@ -140,47 +157,38 @@ void DreamWebEngine::playSound(uint8 channel, uint8 id, uint8 loops) {
error("out of memory: cannot allocate memory for sound(%u bytes)", sample.size);
memcpy(buffer, data.data.begin() + sample.offset, sample.size);
- raw = Audio::makeRawStream(
- buffer,
- sample.size, 22050, Audio::FLAG_UNSIGNED);
+ raw = Audio::makeRawStream(buffer, sample.size, 22050, Audio::FLAG_UNSIGNED);
} else {
uint8 *buffer = (uint8 *)malloc(_speechData.size());
if (!buffer)
error("out of memory: cannot allocate memory for sound(%u bytes)", _speechData.size());
memcpy(buffer, _speechData.begin(), _speechData.size());
- raw = Audio::makeRawStream(
- buffer,
- _speechData.size(), 22050, Audio::FLAG_UNSIGNED);
-
+ raw = Audio::makeRawStream(buffer, _speechData.size(), 22050, Audio::FLAG_UNSIGNED);
}
Audio::AudioStream *stream;
if (loops > 1) {
- stream = new Audio::LoopingAudioStream(raw, loops < 255? loops: 0);
+ stream = new Audio::LoopingAudioStream(raw, (loops < 255) ? loops : 0);
} else
stream = raw;
- if (_mixer->isSoundHandleActive(_channelHandle[channel]))
- _mixer->stopHandle(_channelHandle[channel]);
- _mixer->playStream(type, &_channelHandle[channel], stream);
+ if (_vm->_mixer->isSoundHandleActive(_channelHandle[channel]))
+ _vm->_mixer->stopHandle(_channelHandle[channel]);
+ _vm->_mixer->playStream(type, &_channelHandle[channel], stream);
}
-void DreamWebEngine::stopSound(uint8 channel) {
+void DreamWebSound::stopSound(uint8 channel) {
debug(1, "stopSound(%u)", channel);
assert(channel == 0 || channel == 1);
- _mixer->stopHandle(_channelHandle[channel]);
- if (channel == 0)
- _channel0 = 0;
- else
- _channel1 = 0;
+ _vm->_mixer->stopHandle(_channelHandle[channel]);
}
-bool DreamWebEngine::loadSpeech(const Common::String &filename) {
- if (!hasSpeech())
+bool DreamWebSound::loadSpeech(const Common::String &filename) {
+ if (!_vm->hasSpeech())
return false;
Common::File file;
- if (!file.open(_speechDirName + "/" + filename))
+ if (!file.open(_vm->getSpeechDirName() + "/" + filename))
return false;
debug(1, "loadSpeech(%s)", filename.c_str());
@@ -192,13 +200,8 @@ bool DreamWebEngine::loadSpeech(const Common::String &filename) {
return true;
}
-void DreamWebEngine::soundHandler() {
- static uint8 volumeOld = 0, channel0Old = 0, channel0PlayingOld = 0;
- if (_volume != volumeOld || _channel0 != channel0Old || _channel0Playing != channel0PlayingOld)
- debug(1, "soundHandler() _volume: %d _channel0: %d _channel0Playing: %d", _volume, _channel0, _channel0Playing);
- volumeOld = _volume, channel0Old = _channel0, channel0PlayingOld = _channel0Playing;
-
- _subtitles = ConfMan.getBool("subtitles");
+void DreamWebSound::soundHandler() {
+ _vm->_subtitles = ConfMan.getBool("subtitles");
volumeAdjust();
uint volume = _volume;
@@ -215,42 +218,31 @@ void DreamWebEngine::soundHandler() {
if (volume >= 8)
volume = 7;
volume = (8 - volume) * Audio::Mixer::kMaxChannelVolume / 8;
- _mixer->setChannelVolume(_channelHandle[0], volume);
+ _vm->_mixer->setChannelVolume(_channelHandle[0], volume);
- uint8 ch0 = _channel0Playing;
- if (ch0 == 255)
- ch0 = 0;
- uint8 ch1 = _channel1Playing;
- if (ch1 == 255)
- ch1 = 0;
- uint8 ch0loop = _channel0Repeat;
-
- if (_channel0 != ch0) {
- _channel0 = ch0;
- if (ch0) {
- playSound(0, ch0, ch0loop);
+ if (_channel0NewSound) {
+ _channel0NewSound = false;
+ if (_channel0Playing != 255) {
+ playSound(0, _channel0Playing, _channel0Repeat);
}
}
- if (_channel1 != ch1) {
- _channel1 = ch1;
- if (ch1) {
- playSound(1, ch1, 1);
+ if (_channel1NewSound) {
+ _channel1NewSound = false;
+ if (_channel1Playing != 255) {
+ playSound(1, _channel1Playing, 1);
}
}
- if (!_mixer->isSoundHandleActive(_channelHandle[0])) {
- if (_channel0Playing != 255 && _channel0 != 0)
- debug(1, "!_mixer->isSoundHandleActive _channelHandle[0] _channel0Playing:%d _channel0:%d", _channel0Playing, _channel0);
+
+ if (!_vm->_mixer->isSoundHandleActive(_channelHandle[0])) {
_channel0Playing = 255;
- _channel0 = 0;
}
- if (!_mixer->isSoundHandleActive(_channelHandle[1])) {
+ if (!_vm->_mixer->isSoundHandleActive(_channelHandle[1])) {
_channel1Playing = 255;
- _channel1 = 0;
}
}
-void DreamWebEngine::loadSounds(uint bank, const Common::String &suffix) {
- Common::String filename = getDatafilePrefix() + suffix;
+void DreamWebSound::loadSounds(uint bank, const Common::String &suffix) {
+ Common::String filename = _vm->getDatafilePrefix() + suffix;
debug(1, "loadSounds(%u, %s)", bank, filename.c_str());
Common::File file;
if (!file.open(filename)) {
@@ -258,9 +250,9 @@ void DreamWebEngine::loadSounds(uint bank, const Common::String &suffix) {
return;
}
- uint8 header[0x60];
+ uint8 header[96];
file.read(header, sizeof(header));
- uint tablesize = READ_LE_UINT16(header + 0x32);
+ uint tablesize = READ_LE_UINT16(header + 50);
debug(1, "table size = %u", tablesize);
SoundData &soundData = _soundData[bank];
@@ -270,8 +262,8 @@ void DreamWebEngine::loadSounds(uint bank, const Common::String &suffix) {
uint8 entry[6];
Sample &sample = soundData.samples[i];
file.read(entry, sizeof(entry));
- sample.offset = entry[0] * 0x4000 + READ_LE_UINT16(entry + 1);
- sample.size = READ_LE_UINT16(entry + 3) * 0x800;
+ sample.offset = entry[0] * 16384 + READ_LE_UINT16(entry + 1);
+ sample.size = READ_LE_UINT16(entry + 3) * 2048;
total += sample.size;
debug(1, "offset: %08x, size: %u", sample.offset, sample.size);
}
diff --git a/engines/dreamweb/sound.h b/engines/dreamweb/sound.h
new file mode 100644
index 0000000000..1ab06dc694
--- /dev/null
+++ b/engines/dreamweb/sound.h
@@ -0,0 +1,91 @@
+/* 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 DREAMWEB_SOUND_H
+#define DREAMWEB_SOUND_H
+
+#include "common/array.h"
+#include "common/str.h"
+#include "audio/mixer.h"
+
+namespace DreamWeb {
+
+class DreamWebEngine;
+
+class DreamWebSound {
+public:
+ DreamWebSound(DreamWebEngine *vm);
+ ~DreamWebSound();
+
+ bool loadSpeech(byte type1, int idx1, byte type2, int idx2);
+ void volumeSet(uint8 value) { _volume = value; }
+ void volumeChange(uint8 value, int8 direction);
+ void playChannel0(uint8 index, uint8 repeat);
+ void playChannel1(uint8 index);
+ uint8 getChannel0Playing() { return _channel0Playing; }
+ bool isChannel1Playing() { return _channel1Playing != 255; }
+ void cancelCh0();
+ void cancelCh1();
+ void loadRoomsSample(uint8 sample);
+ void soundHandler();
+ void loadSounds(uint bank, const Common::String &suffix);
+
+private:
+ DreamWebEngine *_vm;
+
+ struct Sample {
+ uint offset;
+ uint size;
+ Sample(): offset(), size() {}
+ };
+
+ struct SoundData {
+ Common::Array<Sample> samples;
+ Common::Array<uint8> data;
+ };
+
+ SoundData _soundData[2];
+ Common::Array<uint8> _speechData;
+
+ Audio::SoundHandle _channelHandle[2];
+
+ uint8 _currentSample;
+ uint8 _channel0Playing;
+ uint8 _channel0Repeat;
+ bool _channel0NewSound;
+ uint8 _channel1Playing;
+ bool _channel1NewSound;
+
+ uint8 _volume;
+ uint8 _volumeTo;
+ int8 _volumeDirection;
+ uint8 _volumeCount;
+
+ void volumeAdjust();
+ void playSound(uint8 channel, uint8 id, uint8 loops);
+ void stopSound(uint8 channel);
+ bool loadSpeech(const Common::String &filename);
+};
+
+} // End of namespace DreamWeb
+
+#endif
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 3df324abe1..5b6cf6a6ac 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -298,7 +299,7 @@ void DreamWebEngine::doDoor(Sprite *sprite, SetObject *objData, Common::Rect che
soundIndex = 13;
else
soundIndex = 0;
- playChannel1(soundIndex);
+ _sound->playChannel1(soundIndex);
}
if (objData->frames[sprite->animFrame] == 255)
--sprite->animFrame;
@@ -315,7 +316,7 @@ void DreamWebEngine::doDoor(Sprite *sprite, SetObject *objData, Common::Rect che
soundIndex = 13;
else
soundIndex = 1;
- playChannel1(soundIndex);
+ _sound->playChannel1(soundIndex);
}
if (sprite->animFrame != 0)
--sprite->animFrame;
@@ -346,7 +347,7 @@ void DreamWebEngine::lockedDoorway(Sprite *sprite, SetObject *objData) {
if (openDoor) {
if (sprite->animFrame == 1) {
- playChannel1(0);
+ _sound->playChannel1(0);
}
if (sprite->animFrame == 6)
@@ -367,7 +368,7 @@ void DreamWebEngine::lockedDoorway(Sprite *sprite, SetObject *objData) {
// shut door
if (sprite->animFrame == 5) {
- playChannel1(1);
+ _sound->playChannel1(1);
}
if (sprite->animFrame != 0)
@@ -505,7 +506,7 @@ void DreamWebEngine::intro1Text() {
if (_introCount != 2 && _introCount != 4 && _introCount != 6)
return;
- if (hasSpeech() && _channel1Playing != 255) {
+ if (hasSpeech() && _sound->isChannel1Playing()) {
_introCount--;
} else {
if (_introCount == 2)
@@ -578,7 +579,7 @@ void DreamWebEngine::textForEnd() {
}
void DreamWebEngine::textForMonkHelper(uint8 textIndex, uint8 voiceIndex, uint8 x, uint8 y, uint16 countToTimed, uint16 timeCount) {
- if (hasSpeech() && _channel1Playing != 255)
+ if (hasSpeech() && _sound->isChannel1Playing())
_introCount--;
else
setupTimedTemp(textIndex, voiceIndex, x, y, countToTimed, timeCount);
@@ -614,8 +615,7 @@ void DreamWebEngine::textForMonk() {
else if (_introCount == 53) {
fadeScreenDowns();
if (hasSpeech()) {
- _volumeTo = 7;
- _volumeDirection = 1;
+ _sound->volumeChange(7, 1);
}
}
}
@@ -905,14 +905,14 @@ void DreamWebEngine::soundOnReels(uint16 reelPointer) {
continue;
_lastSoundReel = r->_reelPointer;
if (r->_sample < 64) {
- playChannel1(r->_sample);
+ _sound->playChannel1(r->_sample);
return;
}
if (r->_sample < 128) {
- playChannel0(r->_sample & 63, 0);
+ _sound->playChannel0(r->_sample & 63, 0);
return;
}
- playChannel0(r->_sample & 63, 255);
+ _sound->playChannel0(r->_sample & 63, 255);
}
if (_lastSoundReel != reelPointer)
@@ -955,9 +955,9 @@ void DreamWebEngine::getRidOfReels() {
void DreamWebEngine::liftNoise(uint8 index) {
if (_realLocation == 5 || _realLocation == 21)
- playChannel1(13); // hiss noise
+ _sound->playChannel1(13); // hiss noise
else
- playChannel1(index);
+ _sound->playChannel1(index);
}
void DreamWebEngine::checkForExit(Sprite *sprite) {
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 750dafe7b4..4515939ebc 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
#include "common/config-manager.h"
@@ -578,7 +579,7 @@ void DreamWebEngine::dreamweb() {
readSetData();
_wonGame = false;
- loadSounds(0, "V99"); // basic sample
+ _sound->loadSounds(0, "V99"); // basic sample
bool firstLoop = true;
@@ -654,7 +655,7 @@ void DreamWebEngine::dreamweb() {
_vars._location = 255;
_vars._roomAfterDream = 1;
_newLocation = 35;
- _volume = 7;
+ _sound->volumeSet(7);
loadRoom();
clearSprites();
initMan();
@@ -664,8 +665,7 @@ void DreamWebEngine::dreamweb() {
initialInv();
_lastFlag = 32;
startup1();
- _volumeTo = 0;
- _volumeDirection = -1;
+ _sound->volumeChange(0, -1);
_commandType = 255;
}
@@ -754,7 +754,7 @@ void DreamWebEngine::screenUpdate() {
showPointer();
if ((_vars._watchingTime == 0) && (_newLocation != 0xff))
return;
- vSync();
+ waitForVSync();
uint16 mouseState = 0;
mouseState |= readMouseState();
dumpPointer();
@@ -769,7 +769,7 @@ void DreamWebEngine::screenUpdate() {
showPointer();
if (_wonGame)
return;
- vSync();
+ waitForVSync();
mouseState |= readMouseState();
dumpPointer();
@@ -781,7 +781,7 @@ void DreamWebEngine::screenUpdate() {
afterNewRoom();
showPointer();
- vSync();
+ waitForVSync();
mouseState |= readMouseState();
dumpPointer();
@@ -790,7 +790,7 @@ void DreamWebEngine::screenUpdate() {
delPointer();
showPointer();
- vSync();
+ waitForVSync();
_oldButton = _mouseButton;
mouseState |= readMouseState();
_mouseButton = mouseState;
@@ -871,7 +871,7 @@ void DreamWebEngine::loadTextSegment(TextFile &file, Common::File &inFile, unsig
void DreamWebEngine::hangOnCurs(uint16 frameCount) {
for (uint16 i = 0; i < frameCount; ++i) {
printCurs();
- vSync();
+ waitForVSync();
delCurs();
}
}
@@ -930,7 +930,7 @@ void DreamWebEngine::processTrigger() {
void DreamWebEngine::useTimedText() {
if (_previousTimedTemp._string) {
// TODO: It might be nice to make subtitles wait for the speech
- // to finish (_channel1Playing) when we're in speech+subtitles mode,
+ // to finish (_sound->isChannel1Playing()) when we're in speech+subtitles mode,
// instead of waiting the pre-specified amount of time.
@@ -967,9 +967,9 @@ void DreamWebEngine::useTimedText() {
void DreamWebEngine::setupTimedTemp(uint8 textIndex, uint8 voiceIndex, uint8 x, uint8 y, uint16 countToTimed, uint16 timeCount) {
if (hasSpeech() && voiceIndex != 0) {
- if (loadSpeech('T', voiceIndex, 'T', textIndex)) {
- playChannel1(50+12);
- }
+ _speechLoaded = _sound->loadSpeech('T', voiceIndex, 'T', textIndex);
+ if (_speechLoaded)
+ _sound->playChannel1(62);
if (_speechLoaded && !_subtitles)
return;
@@ -1634,7 +1634,7 @@ bool DreamWebEngine::checkIfSet(uint8 x, uint8 y) {
void DreamWebEngine::hangOn(uint16 frameCount) {
while (frameCount) {
- vSync();
+ waitForVSync();
--frameCount;
if (_quitRequested)
break;
@@ -1647,7 +1647,7 @@ void DreamWebEngine::hangOnW(uint16 frameCount) {
readMouse();
animPointer();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
--frameCount;
if (_quitRequested)
@@ -1665,7 +1665,7 @@ void DreamWebEngine::hangOnP(uint16 count) {
readMouse();
animPointer();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
count *= 3;
@@ -1674,7 +1674,7 @@ void DreamWebEngine::hangOnP(uint16 count) {
readMouse();
animPointer();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
if (_quitRequested)
break;
@@ -1846,7 +1846,7 @@ void DreamWebEngine::loadRoom() {
_vars._location = _newLocation;
const Room &room = g_roomData[_newLocation];
startLoading(room);
- loadRoomsSample();
+ _sound->loadRoomsSample(_roomsSample);
switchRyanOn();
drawFlags();
@@ -2132,7 +2132,7 @@ void DreamWebEngine::workToScreenM() {
animPointer();
readMouse();
showPointer();
- vSync();
+ waitForVSync();
workToScreen();
delPointer();
}
@@ -2146,12 +2146,12 @@ void DreamWebEngine::atmospheres() {
continue;
if (a->_mapX != _mapX || a->_mapY != _mapY)
continue;
- if (a->_sound != _channel0Playing) {
+ if (a->_sound != _sound->getChannel0Playing()) {
if (_vars._location == 45 && _vars._reelToWatch == 45)
continue; // "web"
- playChannel0(a->_sound, a->_repeat);
+ _sound->playChannel0(a->_sound, a->_repeat);
// NB: The asm here reads
// cmp reallocation,2
@@ -2161,21 +2161,21 @@ void DreamWebEngine::atmospheres() {
// I'm interpreting this as if the cmp reallocation is below the jz
if (_mapY == 0) {
- _volume = 0; // "fullvol"
+ _sound->volumeSet(0); // "fullvol"
return;
}
if (_realLocation == 2 && _mapX == 22 && _mapY == 10)
- _volume = 5; // "louisvol"
+ _sound->volumeSet(5); // "louisvol"
if (hasSpeech() && _realLocation == 14) {
if (_mapX == 33) {
- _volume = 0; // "ismad2"
+ _sound->volumeSet(0); // "ismad2"
return;
}
if (_mapX == 22) {
- _volume = 5;
+ _sound->volumeSet(5);
return;
}
@@ -2184,19 +2184,19 @@ void DreamWebEngine::atmospheres() {
if (_realLocation == 2) {
if (_mapX == 22) {
- _volume = 5; // "louisvol"
+ _sound->volumeSet(5); // "louisvol"
return;
}
if (_mapX == 11) {
- _volume = 0; // "fullvol"
+ _sound->volumeSet(0); // "fullvol"
return;
}
}
return;
}
- cancelCh0();
+ _sound->cancelCh0();
}
void DreamWebEngine::readKey() {
@@ -2607,7 +2607,7 @@ void DreamWebEngine::decide() {
readMouse();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
delPointer();
@@ -2642,8 +2642,8 @@ void DreamWebEngine::showGun() {
_numToFade = 128;
hangOn(200);
_roomsSample = 34;
- loadRoomsSample();
- _volume = 0;
+ _sound->loadRoomsSample(_roomsSample);
+ _sound->volumeSet(0);
GraphicsFile graphics;
loadGraphicsFile(graphics, "G13");
createPanel2();
@@ -2653,7 +2653,7 @@ void DreamWebEngine::showGun() {
graphics.clear();
fadeScreenUp();
hangOn(160);
- playChannel0(12, 0);
+ _sound->playChannel0(12, 0);
loadTempText("T83");
rollEndCreditsGameLost();
getRidOfTempText();
diff --git a/engines/dreamweb/talk.cpp b/engines/dreamweb/talk.cpp
index 0f59cad895..2629c23355 100644
--- a/engines/dreamweb/talk.cpp
+++ b/engines/dreamweb/talk.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -52,7 +53,7 @@ void DreamWebEngine::talk() {
readMouse();
animPointer();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
_getBack = 0;
@@ -67,9 +68,8 @@ void DreamWebEngine::talk() {
redrawMainScrn();
workToScreenM();
if (_speechLoaded) {
- cancelCh1();
- _volumeDirection = -1;
- _volumeTo = 0;
+ _sound->cancelCh1();
+ _sound->volumeChange(0, -1);
}
}
@@ -99,12 +99,10 @@ void DreamWebEngine::startTalk() {
printDirect(&str, 66, &y, 241, true);
if (hasSpeech()) {
- _speechLoaded = false;
- loadSpeech('R', _realLocation, 'C', 64*(_character & 0x7F));
+ _speechLoaded = _sound->loadSpeech('R', _realLocation, 'C', 64*(_character & 0x7F));
if (_speechLoaded) {
- _volumeDirection = 1;
- _volumeTo = 6;
- playChannel1(50 + 12);
+ _sound->volumeChange(6, 1);
+ _sound->playChannel1(62);
}
}
}
@@ -155,9 +153,9 @@ void DreamWebEngine::doSomeTalk() {
printDirect(str, 164, 64, 144, false);
- loadSpeech('R', _realLocation, 'C', (64 * (_character & 0x7F)) + _talkPos);
+ _speechLoaded = _sound->loadSpeech('R', _realLocation, 'C', (64 * (_character & 0x7F)) + _talkPos);
if (_speechLoaded)
- playChannel1(62);
+ _sound->playChannel1(62);
_pointerMode = 3;
workToScreenM();
@@ -181,9 +179,9 @@ void DreamWebEngine::doSomeTalk() {
convIcons();
printDirect(str, 48, 128, 144, false);
- loadSpeech('R', _realLocation, 'C', (64 * (_character & 0x7F)) + _talkPos);
+ _speechLoaded = _sound->loadSpeech('R', _realLocation, 'C', (64 * (_character & 0x7F)) + _talkPos);
if (_speechLoaded)
- playChannel1(62);
+ _sound->playChannel1(62);
_pointerMode = 3;
workToScreenM();
@@ -211,7 +209,7 @@ bool DreamWebEngine::hangOnPQ() {
readMouse();
animPointer();
showPointer();
- vSync();
+ waitForVSync();
dumpPointer();
dumpTextLine();
checkCoords(quitList);
@@ -220,11 +218,11 @@ bool DreamWebEngine::hangOnPQ() {
// Quit conversation
delPointer();
_pointerMode = 0;
- cancelCh1();
+ _sound->cancelCh1();
return true;
}
- if (_speechLoaded && _channel1Playing == 255) {
+ if (_speechLoaded && !_sound->isChannel1Playing()) {
speechFlag++;
if (speechFlag == 40)
break;
@@ -237,7 +235,7 @@ bool DreamWebEngine::hangOnPQ() {
}
void DreamWebEngine::redes() {
- if (_channel1Playing != 255 || _talkMode != 2) {
+ if (_sound->isChannel1Playing() || _talkMode != 2) {
blank();
return;
}
diff --git a/engines/dreamweb/titles.cpp b/engines/dreamweb/titles.cpp
index f7486ce687..f005279ba0 100644
--- a/engines/dreamweb/titles.cpp
+++ b/engines/dreamweb/titles.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
#include "engines/util.h"
@@ -32,38 +33,36 @@ void DreamWebEngine::endGame() {
return;
gettingShot();
getRidOfTempText();
- _volumeTo = 7;
- _volumeDirection = 1;
+ _sound->volumeChange(7, 1);
hangOn(200);
}
void DreamWebEngine::monkSpeaking() {
_roomsSample = 35;
- loadRoomsSample();
+ _sound->loadRoomsSample(_roomsSample);
GraphicsFile graphics;
loadGraphicsFile(graphics, "G15");
clearWork();
showFrame(graphics, 160, 72, 0, 128); // show monk
workToScreen();
- _volume = 7;
- _volumeDirection = -1;
- _volumeTo = hasSpeech() ? 5 : 0;
- playChannel0(12, 255);
+ _sound->volumeSet(7);
+ _sound->volumeChange(hasSpeech() ? 5 : 0, -1);
+ _sound->playChannel0(12, 255);
fadeScreenUps();
hangOn(300);
// TODO: Subtitles+speech mode
if (hasSpeech()) {
for (int i = 40; i < 48; i++) {
- loadSpeech('T', 83, 'T', i);
+ _speechLoaded = _sound->loadSpeech('T', 83, 'T', i);
- playChannel1(50 + 12);
+ _sound->playChannel1(62);
do {
waitForVSync();
if (_quitRequested)
return;
- } while (_channel1Playing != 255);
+ } while (_sound->isChannel1Playing());
}
} else {
for (int i = 40; i <= 44; i++) {
@@ -83,8 +82,7 @@ void DreamWebEngine::monkSpeaking() {
}
}
- _volumeDirection = 1;
- _volumeTo = 7;
+ _sound->volumeChange(7, 1);
fadeScreenDowns();
hangOn(300);
graphics.clear();
@@ -95,8 +93,7 @@ void DreamWebEngine::gettingShot() {
clearPalette();
loadIntroRoom();
fadeScreenUps();
- _volumeTo = 0;
- _volumeDirection = -1;
+ _sound->volumeChange(0, -1);
runEndSeq();
clearBeforeLoad();
}
@@ -127,14 +124,14 @@ void DreamWebEngine::bibleQuote() {
return; // "biblequotearly"
}
- cancelCh0();
+ _sound->cancelCh0();
_lastHardKey = 0;
}
void DreamWebEngine::hangOne(uint16 delay) {
do {
- vSync();
+ waitForVSync();
if (_lastHardKey == 1)
return; // "hangonearly"
} while (--delay);
@@ -147,10 +144,9 @@ void DreamWebEngine::intro() {
_newLocation = 50;
clearPalette();
loadIntroRoom();
- _volume = 7;
- _volumeDirection = -1;
- _volumeTo = hasSpeech() ? 4 : 0;
- playChannel0(12, 255);
+ _sound->volumeSet(7);
+ _sound->volumeChange(hasSpeech() ? 4 : 0, -1);
+ _sound->playChannel0(12, 255);
fadeScreenUps();
runIntroSeq();
@@ -200,13 +196,13 @@ void DreamWebEngine::runIntroSeq() {
_getBack = 0;
do {
- vSync();
+ waitForVSync();
if (_lastHardKey == 1)
break;
spriteUpdate();
- vSync();
+ waitForVSync();
if (_lastHardKey == 1)
break;
@@ -216,14 +212,14 @@ void DreamWebEngine::runIntroSeq() {
reelsOnScreen();
afterIntroRoom();
useTimedText();
- vSync();
+ waitForVSync();
if (_lastHardKey == 1)
break;
dumpMap();
dumpTimedText();
- vSync();
+ waitForVSync();
if (_lastHardKey == 1)
break;
@@ -247,18 +243,18 @@ void DreamWebEngine::runEndSeq() {
_getBack = 0;
do {
- vSync();
+ waitForVSync();
spriteUpdate();
- vSync();
+ waitForVSync();
delEverything();
printSprites();
reelsOnScreen();
afterIntroRoom();
useTimedText();
- vSync();
+ waitForVSync();
dumpMap();
dumpTimedText();
- vSync();
+ waitForVSync();
} while (_getBack != 1 && !_quitRequested);
}
@@ -286,14 +282,14 @@ void DreamWebEngine::set16ColPalette() {
void DreamWebEngine::realCredits() {
_roomsSample = 33;
- loadRoomsSample();
- _volume = 0;
+ _sound->loadRoomsSample(_roomsSample);
+ _sound->volumeSet(0);
initGraphics(640, 480, true);
hangOn(35);
showPCX("I01");
- playChannel0(12, 0);
+ _sound->playChannel0(12, 0);
hangOne(2);
@@ -319,7 +315,7 @@ void DreamWebEngine::realCredits() {
}
showPCX("I02");
- playChannel0(12, 0);
+ _sound->playChannel0(12, 0);
hangOne(2);
if (_lastHardKey == 1) {
@@ -344,7 +340,7 @@ void DreamWebEngine::realCredits() {
}
showPCX("I03");
- playChannel0(12, 0);
+ _sound->playChannel0(12, 0);
hangOne(2);
if (_lastHardKey == 1) {
@@ -369,7 +365,7 @@ void DreamWebEngine::realCredits() {
}
showPCX("I04");
- playChannel0(12, 0);
+ _sound->playChannel0(12, 0);
hangOne(2);
if (_lastHardKey == 1) {
@@ -394,7 +390,7 @@ void DreamWebEngine::realCredits() {
}
showPCX("I05");
- playChannel0(12, 0);
+ _sound->playChannel0(12, 0);
hangOne(2);
if (_lastHardKey == 1) {
@@ -427,7 +423,7 @@ void DreamWebEngine::realCredits() {
return; // "realcreditsearly"
}
- playChannel0(13, 0);
+ _sound->playChannel0(13, 0);
hangOne(350);
if (_lastHardKey == 1) {
diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp
index e59843539f..995eef04cd 100644
--- a/engines/dreamweb/use.cpp
+++ b/engines/dreamweb/use.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -201,13 +202,13 @@ void DreamWebEngine::edensCDPlayer() {
}
void DreamWebEngine::hotelBell() {
- playChannel1(12);
+ _sound->playChannel1(12);
showFirstUse();
putBackObStuff();
}
void DreamWebEngine::playGuitar() {
- playChannel1(14);
+ _sound->playChannel1(14);
showFirstUse();
putBackObStuff();
}
@@ -273,13 +274,13 @@ void DreamWebEngine::useHatch() {
}
void DreamWebEngine::wheelSound() {
- playChannel1(17);
+ _sound->playChannel1(17);
showFirstUse();
putBackObStuff();
}
void DreamWebEngine::callHotelLift() {
- playChannel1(12);
+ _sound->playChannel1(12);
showFirstUse();
_vars._countToOpen = 8;
_getBack = 1;
@@ -382,7 +383,7 @@ void DreamWebEngine::sitDownInBar() {
}
void DreamWebEngine::useDryer() {
- playChannel1(12);
+ _sound->playChannel1(12);
showFirstUse();
_getBack = 1;
}
@@ -887,7 +888,7 @@ void DreamWebEngine::usePlate() {
if (compare(_withObject, _withType, "SCRW")) {
// Unscrew plate
- playChannel1(20);
+ _sound->playChannel1(20);
showFirstUse();
placeSetObject(28);
placeSetObject(24);
@@ -992,7 +993,7 @@ void DreamWebEngine::useCart() {
removeSetObject(_command);
placeSetObject(_command + 1);
_vars._progressPoints++;
- playChannel1(17);
+ _sound->playChannel1(17);
showFirstUse();
_getBack = 1;
}
@@ -1035,7 +1036,7 @@ void DreamWebEngine::openHotelDoor() {
if (defaultUseHandler("KEYA"))
return;
- playChannel1(16);
+ _sound->playChannel1(16);
showFirstUse();
_vars._lockStatus = 0;
_getBack = 1;
@@ -1045,7 +1046,7 @@ void DreamWebEngine::openHotelDoor2() {
if (defaultUseHandler("KEYA"))
return;
- playChannel1(16);
+ _sound->playChannel1(16);
showFirstUse();
putBackObStuff();
}
@@ -1067,7 +1068,7 @@ void DreamWebEngine::usePoolReader() {
showSecondUse();
putBackObStuff();
} else {
- playChannel1(17);
+ _sound->playChannel1(17);
showFirstUse();
_vars._countToOpen = 6;
_getBack = 1;
@@ -1088,7 +1089,7 @@ void DreamWebEngine::useCardReader1() {
putBackObStuff();
} else {
// Get cash
- playChannel1(16);
+ _sound->playChannel1(16);
showPuzText(18, 300);
_vars._progressPoints++;
_vars._card1Money = 12432;
@@ -1113,7 +1114,7 @@ void DreamWebEngine::useCardReader2() {
showPuzText(22, 300);
putBackObStuff();
} else {
- playChannel1(18);
+ _sound->playChannel1(18);
showPuzText(19, 300);
placeSetObject(94);
_vars._gunPassFlag = 1;
@@ -1136,7 +1137,7 @@ void DreamWebEngine::useCardReader3() {
showPuzText(26, 300);
putBackObStuff();
} else {
- playChannel1(16);
+ _sound->playChannel1(16);
showPuzText(25, 300);
_vars._progressPoints++;
_vars._card1Money -= 8300;
@@ -1232,7 +1233,7 @@ void DreamWebEngine::useControl() {
}
if (compare(_withObject, _withType, "KEYA")) { // Right key
- playChannel1(16);
+ _sound->playChannel1(16);
if (_vars._location == 21) { // Going down
showPuzText(3, 300);
_newLocation = 30;
@@ -1257,7 +1258,7 @@ void DreamWebEngine::useControl() {
placeSetObject(30);
removeSetObject(16);
removeSetObject(17);
- playChannel1(14);
+ _sound->playChannel1(14);
showPuzText(10, 300);
_vars._progressPoints++;
_getBack = 1;
@@ -1375,7 +1376,7 @@ void DreamWebEngine::runTap() {
// Fill cup from tap
DynObject *exObject = getExAd(_withObject);
exObject->objId[3] = 'F'-'A'; // CUPE (empty cup) -> CUPF (full cup)
- playChannel1(8);
+ _sound->playChannel1(8);
showPuzText(57, 300);
putBackObStuff();
return;
diff --git a/engines/dreamweb/vgafades.cpp b/engines/dreamweb/vgafades.cpp
index e8999ab18c..c8f05641b5 100644
--- a/engines/dreamweb/vgafades.cpp
+++ b/engines/dreamweb/vgafades.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "dreamweb/sound.h"
#include "dreamweb/dreamweb.h"
namespace DreamWeb {
@@ -52,7 +53,7 @@ void DreamWebEngine::fadeDOS() {
return; // FIXME later
waitForVSync();
- //processEvents will be called from vsync
+ //processEvents will be called from waitForVSync
uint8 *dst = _startPal;
getPalette(dst, 0, 64);
for (int fade = 0; fade < 64; ++fade) {
@@ -123,7 +124,7 @@ void DreamWebEngine::fadeUpMonFirst() {
_colourPos = 0;
_numToFade = 128;
hangOn(64);
- playChannel1(26);
+ _sound->playChannel1(26);
hangOn(64);
}
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index a66f156a1d..ec306c4924 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -144,10 +144,6 @@ void DreamWebEngine::doShake() {
setShakePos(offset >= 0 ? offset : -offset);
}
-void DreamWebEngine::vSync() {
- waitForVSync();
-}
-
void DreamWebEngine::setMode() {
waitForVSync();
initGraphics(320, 200, false);