diff options
author | Alyssa Milburn | 2012-08-28 15:39:00 +0200 |
---|---|---|
committer | Alyssa Milburn | 2012-08-28 15:54:12 +0200 |
commit | 31801137b5c6908edd76f357b3f29b07e9e3be84 (patch) | |
tree | 33e973717545ae27da6ba4996d0d8fe1bcd437b3 /engines/dreamweb | |
parent | 35fd91793b34b72624a89f2a76f45bc8e59020d2 (diff) | |
parent | 6ab8db638e4a1d547ee67db067b5d6c3d6c940a4 (diff) | |
download | scummvm-rg350-31801137b5c6908edd76f357b3f29b07e9e3be84.tar.gz scummvm-rg350-31801137b5c6908edd76f357b3f29b07e9e3be84.tar.bz2 scummvm-rg350-31801137b5c6908edd76f357b3f29b07e9e3be84.zip |
Merge remote-tracking branch 'origin/master' into tony
Conflicts:
common/coroutines.cpp
common/coroutines.h
devtools/create_project/msbuild.cpp
devtools/create_project/visualstudio.cpp
Diffstat (limited to 'engines/dreamweb')
-rw-r--r-- | engines/dreamweb/detection.cpp | 2 | ||||
-rw-r--r-- | engines/dreamweb/detection_tables.h | 74 | ||||
-rw-r--r-- | engines/dreamweb/dreamweb.cpp | 30 | ||||
-rw-r--r-- | engines/dreamweb/dreamweb.h | 47 | ||||
-rw-r--r-- | engines/dreamweb/keypad.cpp | 23 | ||||
-rw-r--r-- | engines/dreamweb/monitor.cpp | 18 | ||||
-rw-r--r-- | engines/dreamweb/newplace.cpp | 5 | ||||
-rw-r--r-- | engines/dreamweb/object.cpp | 2 | ||||
-rw-r--r-- | engines/dreamweb/people.cpp | 16 | ||||
-rw-r--r-- | engines/dreamweb/print.cpp | 24 | ||||
-rw-r--r-- | engines/dreamweb/rain.cpp | 7 | ||||
-rw-r--r-- | engines/dreamweb/saveload.cpp | 33 | ||||
-rw-r--r-- | engines/dreamweb/sound.cpp | 161 | ||||
-rw-r--r-- | engines/dreamweb/sound.h | 91 | ||||
-rw-r--r-- | engines/dreamweb/sprite.cpp | 26 | ||||
-rw-r--r-- | engines/dreamweb/stubs.cpp | 68 | ||||
-rw-r--r-- | engines/dreamweb/talk.cpp | 32 | ||||
-rw-r--r-- | engines/dreamweb/titles.cpp | 68 | ||||
-rw-r--r-- | engines/dreamweb/use.cpp | 33 | ||||
-rw-r--r-- | engines/dreamweb/vgafades.cpp | 5 | ||||
-rw-r--r-- | engines/dreamweb/vgagrafx.cpp | 4 |
21 files changed, 429 insertions, 340 deletions
diff --git a/engines/dreamweb/detection.cpp b/engines/dreamweb/detection.cpp index 6468281ac2..f2e2f42216 100644 --- a/engines/dreamweb/detection.cpp +++ b/engines/dreamweb/detection.cpp @@ -172,8 +172,6 @@ SaveStateDescriptor DreamWebMetaEngine::querySaveMetaInfos(const char *target, i saveName += (char)in->readByte(); SaveStateDescriptor desc(slot, saveName); - desc.setDeletableFlag(true); - desc.setWriteProtectedFlag(false); // Check if there is a ScummVM data block if (header.len(6) == SCUMMVM_BLOCK_MAGIC_SIZE) { diff --git a/engines/dreamweb/detection_tables.h b/engines/dreamweb/detection_tables.h index 8ca24d1724..8a2f94f99b 100644 --- a/engines/dreamweb/detection_tables.h +++ b/engines/dreamweb/detection_tables.h @@ -41,11 +41,12 @@ static const DreamWebGameDescription gameDescriptions[] = { { {"dreamweb.r00", 0, "3b5c87717fc40cc5a5ae19c155662ee3", 152918}, {"dreamweb.r02", 0, "28458718167a040d7e988cf7d2298eae", 210466}, + {"dreamweb.exe", 0, "56b1d73aa56e964b45872ff552402341", 64985}, AD_LISTEND }, Common::EN_ANY, Common::kPlatformPC, - ADGF_UNSTABLE, + 0, GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) }, }, @@ -62,7 +63,28 @@ static const DreamWebGameDescription gameDescriptions[] = { }, Common::EN_ANY, Common::kPlatformPC, - ADGF_CD | ADGF_UNSTABLE, + ADGF_CD, + GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) + }, + }, + + // UK-V (Early UK) CD Release - From bug #3526483 + // Note: r00 and r02 files are identical to international floppy release + // so was misidentified as floppy, resulting in disabled CD speech. + // Added executable to detection to avoid this. + { + { + "dreamweb", + "CD", + { + {"dreamweb.r00", 0, "3b5c87717fc40cc5a5ae19c155662ee3", 152918}, + {"dreamweb.r02", 0, "28458718167a040d7e988cf7d2298eae", 210466}, + {"dreamweb.exe", 0, "dd1c7793b151489e67b83cd1ecab51cd", -1}, + AD_LISTEND + }, + Common::EN_GRB, + Common::kPlatformPC, + ADGF_CD, GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) }, }, @@ -96,7 +118,25 @@ static const DreamWebGameDescription gameDescriptions[] = { }, Common::FR_FRA, Common::kPlatformPC, - ADGF_CD | ADGF_UNSTABLE, + ADGF_CD, + GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) + }, + }, + + // French CD release + // From bug #3524362 + { + { + "dreamweb", + "CD", + { + {"dreamwfr.r00", 0, "e354582a8564faf5c515df92f207e8d1", 154657}, + {"dreamwfr.r02", 0, "cb99f08d5aefd04184eac76927eced80", 200575}, + AD_LISTEND + }, + Common::FR_FRA, + Common::kPlatformPC, + ADGF_CD, GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) }, }, @@ -113,7 +153,7 @@ static const DreamWebGameDescription gameDescriptions[] = { }, Common::DE_DEU, Common::kPlatformPC, - ADGF_UNSTABLE, + 0, GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) }, }, @@ -130,7 +170,7 @@ static const DreamWebGameDescription gameDescriptions[] = { }, Common::DE_DEU, Common::kPlatformPC, - ADGF_CD | ADGF_UNSTABLE, + ADGF_CD, GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) }, }, @@ -147,7 +187,7 @@ static const DreamWebGameDescription gameDescriptions[] = { }, Common::ES_ESP, Common::kPlatformPC, - ADGF_UNSTABLE, + 0, GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) }, }, @@ -164,7 +204,25 @@ static const DreamWebGameDescription gameDescriptions[] = { }, Common::ES_ESP, Common::kPlatformPC, - ADGF_CD | ADGF_UNSTABLE, + ADGF_CD, + GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) + }, + }, + + // Spanish CD release + // From bug #3524362 + { + { + "dreamweb", + "CD", + { + {"dreamwsp.r00", 0, "2df07174321de39c4f17c9ff654b268a", 153608}, + {"dreamwsp.r02", 0, "f97d435ad5da08fb1bcf6ea3dd6e0b9e", 199499}, + AD_LISTEND + }, + Common::ES_ESP, + Common::kPlatformPC, + ADGF_CD, GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) }, }, @@ -181,7 +239,7 @@ static const DreamWebGameDescription gameDescriptions[] = { }, Common::IT_ITA, Common::kPlatformPC, - ADGF_UNSTABLE, + 0, GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_BRIGHTPALETTE) }, }, diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp index 0a35bcdecc..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,31 +47,29 @@ 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"; // ES and FR CD release use a different data file prefix + // and speech directory naming. if (isCD()) { switch(getLanguage()) { case Common::ES_ESP: _datafilePrefix = "DREAMWSP."; + _speechDirName = "SPANISH"; break; case Common::FR_FRA: _datafilePrefix = "DREAMWFR."; + _speechDirName = "FRENCH"; break; default: // Nothing to do @@ -81,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; @@ -242,6 +231,7 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam DreamWebEngine::~DreamWebEngine() { DebugMan.clearAllDebugChannels(); delete _console; + delete _sound; } static void vSyncInterrupt(void *refCon) { @@ -282,7 +272,7 @@ void DreamWebEngine::processEvents() { return; } - soundHandler(); + _sound->soundHandler(); Common::Event event; int softKey, hardKey; while (_eventMan->pollEvent(event)) { @@ -378,10 +368,11 @@ 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); - _hasSpeech = Common::File::exists("speech/r01c0000.raw") && !ConfMan.getBool("speech_mute"); + _hasSpeech = Common::File::exists(_speechDirName + "/r01c0000.raw") && !ConfMan.getBool("speech_mute"); _brightPalette = ConfMan.getBool("bright_palette"); _timer->installTimerProc(vSyncInterrupt, 1000000 / 70, this, "dreamwebVSync"); @@ -522,6 +513,7 @@ uint8 DreamWebEngine::modifyChar(uint8 c) const { return c; } case Common::FR_FRA: + case Common::IT_ITA: switch(c) { case 133: return 'Z' + 1; diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h index 4065e5a860..1f6deb8566 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,41 +152,23 @@ public: uint8 modifyChar(uint8 c) const; Common::String modifyFileName(const char *); - void stopSound(uint8 channel); - - const Common::String& getDatafilePrefix() { return _datafilePrefix; }; + 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; Common::String _datafilePrefix; + Common::String _speechDirName; uint _speed; bool _turbo; 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 @@ -326,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 @@ -714,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); @@ -1134,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 95aa400c3a..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(); @@ -626,15 +627,12 @@ void DreamWebEngine::signOn() { _monAdX = prevX; _monAdY = prevY; - inputLine = (const char *)_inputLine; - inputLine.toUppercase(); - // The entered line has zeroes in-between each character uint32 len = strlen(monitorKeyEntries[foundIndex].password); bool found = true; for (uint32 i = 0; i < len; i++) { - if (monitorKeyEntries[foundIndex].password[i] != inputLine[i * 2]) { + if (monitorKeyEntries[foundIndex].password[i] != _inputLine[i * 2]) { found = false; break; } 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 5d7f02c5cf..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); @@ -839,8 +833,9 @@ void DreamWebEngine::showOpBox() { // This call displays half of the ops dialog in the CD version. It's not // in the floppy version, and if it's called, a stray red dot is shown in - // the game dialogs. - if (isCD()) + // the game dialogs. It is included in the early UK CD release, which had + // similar data files as the floppy release (bug #3528160). + if (isCD() && getLanguage() != Common::EN_GRB) showFrame(_saveGraphics, kOpsx, kOpsy + 55, 4, 0); } diff --git a/engines/dreamweb/sound.cpp b/engines/dreamweb/sound.cpp index b51527a8cd..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,36 +77,38 @@ void DreamWebEngine::volumeAdjust() { } } -void DreamWebEngine::playChannel0(uint8 index, uint8 repeat) { - _channel0Playing = index; - if (index >= 12) - index -= 12; +void DreamWebSound::playChannel0(uint8 index, uint8 repeat) { + debug(1, "playChannel0(index:%d, repeat:%d)", index, repeat); + _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() { - _channel0Repeat = 0; +void DreamWebSound::cancelCh0() { + debug(1, "cancelCh0()"); _channel0Playing = 255; + _channel0Repeat = 0; stopSound(0); } -void DreamWebEngine::cancelCh1() { +void DreamWebSound::cancelCh1() { + debug(1, "cancelCh1()"); _channel1Playing = 255; stopSound(1); } -void DreamWebEngine::loadRoomsSample() { - uint8 sample = _roomsSample; +void DreamWebSound::loadRoomsSample(uint8 sample) { + debug(1, "loadRoomsSample(sample:%d)", sample); if (sample == 255 || _currentSample == sample) return; // loaded already @@ -101,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; @@ -137,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("speech/" + filename)) + if (!file.open(_vm->getSpeechDirName() + "/" + filename)) return false; debug(1, "loadSpeech(%s)", filename.c_str()); @@ -189,8 +200,8 @@ bool DreamWebEngine::loadSpeech(const Common::String &filename) { return true; } -void DreamWebEngine::soundHandler() { - _subtitles = ConfMan.getBool("subtitles"); +void DreamWebSound::soundHandler() { + _vm->_subtitles = ConfMan.getBool("subtitles"); volumeAdjust(); uint volume = _volume; @@ -207,41 +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 (!_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)) { @@ -249,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]; @@ -261,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..f235f7c2fd 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(); @@ -2920,9 +2920,7 @@ void DreamWebEngine::setupInitialVars() { _vars._progressPoints = 0; _vars._watchOn = 0; _vars._shadesOn = 0; - _vars._secondCount = 0; - _vars._minuteCount = 30; - _vars._hourCount = 19; + getTime(); _vars._zoomOn = 1; _vars._location = 0; _vars._exPos = 0; 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); |