diff options
author | Kamil Zbróg | 2013-10-20 23:53:31 +0100 |
---|---|---|
committer | Kamil Zbróg | 2013-10-20 23:53:31 +0100 |
commit | 1f0e976ea69e1e28aeb146047181eb814c0f2aef (patch) | |
tree | 6f39d3cd4aa27cf68177c02b46811ac24f1c71c1 /engines | |
parent | 852a9637119b544400984508ca20ccf47ed66a81 (diff) | |
parent | b6bace0fa070985f5301480c36318043ef7b025e (diff) | |
download | scummvm-rg350-1f0e976ea69e1e28aeb146047181eb814c0f2aef.tar.gz scummvm-rg350-1f0e976ea69e1e28aeb146047181eb814c0f2aef.tar.bz2 scummvm-rg350-1f0e976ea69e1e28aeb146047181eb814c0f2aef.zip |
Merge branch 'master' into prince
Diffstat (limited to 'engines')
-rw-r--r-- | engines/engine.cpp | 2 | ||||
-rw-r--r-- | engines/fullpipe/motion.cpp | 156 | ||||
-rw-r--r-- | engines/fullpipe/motion.h | 11 | ||||
-rw-r--r-- | engines/neverhood/resourceman.cpp | 34 | ||||
-rw-r--r-- | engines/tsage/converse.cpp | 9 | ||||
-rw-r--r-- | engines/tsage/converse.h | 1 | ||||
-rw-r--r-- | engines/tsage/core.cpp | 9 | ||||
-rw-r--r-- | engines/tsage/detection.cpp | 1 | ||||
-rw-r--r-- | engines/tsage/globals.cpp | 5 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.cpp | 5 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_speakers.cpp | 30 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_speakers.h | 6 | ||||
-rw-r--r-- | engines/tsage/sound.cpp | 42 | ||||
-rw-r--r-- | engines/tsage/sound.h | 2 |
14 files changed, 252 insertions, 61 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp index c84404cc68..52020c772e 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -183,7 +183,7 @@ void initCommonGFX(bool defaultTo1XScaler) { g_system->setGraphicsMode(gfxMode.c_str()); // HACK: For OpenGL modes, we will still honor the graphics scale override - if (defaultTo1XScaler && (gfxMode.equalsIgnoreCase("gl1") || gfxMode.equalsIgnoreCase("gl2") || gfxMode.equalsIgnoreCase("gl4"))) + if (defaultTo1XScaler && (gfxMode.equalsIgnoreCase("opengl_linear") || gfxMode.equalsIgnoreCase("opengl_nearest"))) g_system->resetGraphicsScale(); } } diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index f9158397c2..a6d32cfb48 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -536,7 +536,112 @@ void MovGraph2::addObject(StaticANIObject *obj) { } void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst) { - warning("STUB: MovGraph2::buildMovInfo1SubItems()"); + MovInfo1Sub *elem; + Common::Point point; + Common::Rect rect; + + int subIndex = movinfo->subIndex; + + movinfo->items.clear(); + + elem = new MovInfo1Sub; + elem->subIndex = subIndex; + elem->x = movinfo->pt1.x; + elem->y = movinfo->pt1.y; + elem->distance = -1; + + movinfo->items.push_back(elem); + + int prevSubIndex = movinfo->subIndex; + + for (uint i = 0; i < linkList->size(); i++) { + int idx1; + + if (linkList->size() <= 1) { + if (linkList->size() == 1) + idx1 = getShortSide((*linkList)[0], movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y); + else + idx1 = getShortSide(0, movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y); + + point.y = -1; + rect.bottom = -1; + rect.right = -1; + rect.top = -1; + rect.left = -1; + } else { + idx1 = findLink(linkList, i, &rect, &point); + } + + if (idx1 != prevSubIndex) { + prevSubIndex = idx1; + subIndex = idx1; + + elem = new MovInfo1Sub; + elem->subIndex = subIndex; + elem->x = rect.left; + elem->y = rect.top; + elem->distance = -1; + + movinfo->items.push_back(elem); + } + + if (i != linkList->size() - 1) { + while (1) { + i++; + if (findLink(linkList, i, &rect, 0) != prevSubIndex) { + i--; + findLink(linkList, i, &rect, &point); + + break; + } + + if (i == linkList->size() - 1) + break; + } + } + + if (movinfo->items.back()->subIndex != 10) { + subIndex = prevSubIndex; + + elem = new MovInfo1Sub; + elem->subIndex = 10; + elem->x = -1; + elem->y = -1; + elem->distance = -1; + + movinfo->items.push_back(elem); + + if (i == linkList->size()) { + elem = new MovInfo1Sub; + elem->subIndex = prevSubIndex; + elem->x = movinfo->pt2.x; + elem->y = movinfo->pt2.y; + elem->distance = movinfo->distance2; + + movinfo->items.push_back(elem); + } else { + elem = new MovInfo1Sub; + elem->subIndex = prevSubIndex; + elem->x = rect.right; + elem->y = rect.bottom; + elem->distance = point.y; + + movinfo->items.push_back(elem); + } + } + } + + if (subIndex != movinfo->item1Index) { + elem = new MovInfo1Sub; + elem->subIndex = movinfo->item1Index; + elem->x = movinfo->pt2.x; + elem->y = movinfo->pt2.y; + elem->distance = movinfo->distance2; + + movinfo->items.push_back(elem); + } + + movinfo->itemsCount = movinfo->items.size(); } MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) { @@ -750,7 +855,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int else movInfo1.item1Index = getShortSide(0, dx2 - dx1, dy2 - dy1); } else { - movInfo1.item1Index = findLink(&tempLinkList, tempLinkList.back(), 0, 0); + movInfo1.item1Index = findLink(&tempLinkList, tempLinkList.size() - 1, 0, 0); } movInfo1.flags = fuzzyMatch != 0; @@ -824,10 +929,51 @@ int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) { return 0; } -int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, MovGraphLink *lnk, Common::Rect *a3, Common::Point *a4) { - warning("STUB: MovGraphLink *MovGraph2::findLink()"); +int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *rect, Common::Point *point) { + MovGraphNode *node1 = (*linkList)[idx]->_movGraphNode1; + MovGraphNode *node2 = (*linkList)[idx]->_movGraphNode2; + MovGraphNode *node3 = node1; - return 0; + if (idx != 0) { + MovGraphLink *lnk = (*linkList)[idx - 1]; + + if (lnk->_movGraphNode2 != node1) { + if (lnk->_movGraphNode1 != node1) { + if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) { + node3 = node2; + node2 = node1; + } + goto LABEL_7; + } + } + node3 = node1; + } else if (idx != linkList->size() - 1) { + MovGraphLink *lnk = (*linkList)[idx + 1]; + + if (lnk->_movGraphNode1 == node1 || lnk->_movGraphNode1 == node1) { + node3 = node2; + node2 = node1; + } else if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) { + node3 = node1; + } + } + + LABEL_7: + if (rect) { + rect->left = node3->_x; + rect->top = node3->_y; + rect->right = node2->_x; + rect->bottom = node2->_y; + } + if (point) { + point->x = node3->_distance; + point->y = node2->_distance; + } + + if (abs(node3->_x - node2->_x) <= abs(node3->_y - node2->_y)) + return (node3->_y < node2->_x) + 2; + else + return node3->_x >= node2->_x; } MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) { diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index 6901a7263a..85ad084f60 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -280,6 +280,13 @@ struct LinkInfo { MovGraphNode *node; }; +struct MovInfo1Sub { + int subIndex; + int x; + int y; + int distance; +}; + struct MovInfo1 { int field_0; Common::Point pt1; @@ -288,7 +295,7 @@ struct MovInfo1 { int distance2; int subIndex; int item1Index; - int items; + Common::Array<MovInfo1Sub *> items; int itemsCount; int flags; }; @@ -316,7 +323,7 @@ public: int getItemSubIndexByMGM(int idx, StaticANIObject *ani); int getShortSide(MovGraphLink *lnk, int x, int y); - int findLink(Common::Array<MovGraphLink *> *linkList, MovGraphLink *lnk, Common::Rect *a3, Common::Point *a4); + int findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *a3, Common::Point *a4); bool initDirections(StaticANIObject *obj, MovGraph2Item *item); void buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst); diff --git a/engines/neverhood/resourceman.cpp b/engines/neverhood/resourceman.cpp index b7d560bbb3..f6937384c0 100644 --- a/engines/neverhood/resourceman.cpp +++ b/engines/neverhood/resourceman.cpp @@ -94,22 +94,30 @@ struct EntrySizeFix { }; static const EntrySizeFix entrySizeFixes[] = { - // fileHash offset diskSize size fixedSize + // fileHash offset diskSize size fixedSize // Fixes for the Russian "Dyadyushka Risech" version - { 0x41137051, 667019, 23391, 41398, 41401 }, // "Options" menu header text - { 0x0f960021, 402268, 1704, 4378, 1870 }, // "Save" menu - { 0x1301a7ea, 1220008, 2373, 4146, 2877 }, // "Load" menu - { 0x84181e81, 201409, 1622, 5058, 1833 }, // "Delete" menu - { 0x08C0AC24, 1031009, 3030, 6498, 3646 }, // Overwrite dialog - { 0xc6604282, 12813649, 19623, 35894, 35895 }, // One of the fonts when reading Willie's notes - { 0x80283101, 13104841, 1961, 3712, 3511 }, // The first message from Willie - { 0x00918480, 17676417, 581, 916, 706 }, // The first wall in the museum - { 0x00800090C,16064875, 19555, 38518, 38526 }, // The first wall in the museum - { 0x058208810,46010519, 24852, 131874, 131776}, // The entry to hut with musical lock + { 0x041137051, 667019, 23391, 41398, 41401 }, // "Options" menu header text + { 0x00f960021, 402268, 1704, 4378, 1870 }, // "Save" menu + { 0x01301a7ea, 1220008, 2373, 4146, 2877 }, // "Load" menu + { 0x084181e81, 201409, 1622, 5058, 1833 }, // "Delete" menu + { 0x008C0AC24, 1031009, 3030, 6498, 3646 }, // Overwrite dialog + { 0x0c6604282, 12813649, 19623, 35894, 35895 }, // One of the fonts when reading Willie's notes + { 0x080283101, 13104841, 1961, 3712, 3511 }, // First message from Willie + { 0x000918480, 17676417, 581, 916, 706 }, // First wall in the museum + { 0x00800090C, 16064875, 19555, 38518, 38526 }, // First wall in the museum + { 0x058208810, 46010519, 24852, 131874, 131776 }, // Entry to hut with musical lock + { 0x00008E486, 39600019, 240, 454, 271 }, // Second wall in the museum + { 0x003086004, 39621755, 482, 614, 600 }, // Second wall in the museum + { 0x02008048E, 39611075, 3798, 21089, 21087 }, // Next couple of walls in the museum + { 0x008586283, 39587864, 12155, 29731, 29730 }, // Next couple of walls in the museum + { 0x030A84C80, 39606142, 4933, 16305, 16275 }, // Next couple of walls in the museum + { 0x000C9A480, 39614873, 6882, 23915, 23913 }, // Next couple of walls in the museum + { 0x000098880, 39603114, 3028, 10860, 10859 }, // Next couple of walls in the museum + { 0x040080183, 39600259, 2855, 13400, 13395 }, // Last buggy wall in the museum // Fixes for the Russian "Fargus" version - { 0x41137051, 758264, 29037, 49590, 49591 }, // "Options" menu header text - { 0xc10b2015, 787304, 4414, 15848, 15853 }, // Text on option buttons + { 0x041137051, 758264, 29037, 49590, 49591 }, // "Options" menu header text + { 0x0c10b2015, 787304, 4414, 15848, 15853 }, // Text on option buttons // { 0, 0, 0, 0, 0 } }; diff --git a/engines/tsage/converse.cpp b/engines/tsage/converse.cpp index 9e7d84105a..919ba9f69a 100644 --- a/engines/tsage/converse.cpp +++ b/engines/tsage/converse.cpp @@ -760,6 +760,15 @@ void StripManager::remove() { Action::remove(); } +void StripManager::dispatch() { + if (g_vm->getGameID() == GType_Ringworld2) { + if (_activeSpeaker) + _activeSpeaker->dispatch(); + } + + Action::dispatch(); +} + void StripManager::signal() { int strIndex = 0; diff --git a/engines/tsage/converse.h b/engines/tsage/converse.h index 5aef0d8a7f..b1cbbeaf2b 100644 --- a/engines/tsage/converse.h +++ b/engines/tsage/converse.h @@ -237,6 +237,7 @@ public: virtual void synchronize(Serializer &s); virtual void remove(); + virtual void dispatch(); virtual void signal(); virtual void process(Event &event); diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 3332b12cf6..8021160514 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1619,7 +1619,8 @@ void SceneItem::display(int resNum, int lineNum, ...) { Common::String msg = (!resNum || (resNum == -1)) ? Common::String() : g_resourceManager->getMessage(resNum, lineNum); - if ((g_vm->getGameID() != GType_Ringworld) && T2_GLOBALS._uiElements._active) + if ((g_vm->getGameID() != GType_Ringworld) && (g_vm->getGameID() != GType_Ringworld2) + && T2_GLOBALS._uiElements._active) T2_GLOBALS._uiElements.hide(); if (g_globals->_sceneObjects->contains(&g_globals->_sceneText)) { @@ -1783,6 +1784,9 @@ void SceneItem::display(int resNum, int lineNum, ...) { if (!playList.empty()) { R2_GLOBALS._playStream.play(*playList.begin(), NULL); playList.pop_front(); + } else if (!(R2_GLOBALS._speechSubtitles & SPEECH_TEXT)) { + // If not showing text, don't both waiting for a click to end + break; } } } @@ -1794,7 +1798,8 @@ void SceneItem::display(int resNum, int lineNum, ...) { g_globals->_sceneText.remove(); } - if ((g_vm->getGameID() != GType_Ringworld) && T2_GLOBALS._uiElements._active) { + if ((g_vm->getGameID() != GType_Ringworld) && (g_vm->getGameID() != GType_Ringworld2) + && T2_GLOBALS._uiElements._active) { // Show user interface T2_GLOBALS._uiElements.show(); diff --git a/engines/tsage/detection.cpp b/engines/tsage/detection.cpp index a35d663b93..5eae7557d2 100644 --- a/engines/tsage/detection.cpp +++ b/engines/tsage/detection.cpp @@ -75,7 +75,6 @@ class TSageMetaEngine : public AdvancedMetaEngine { public: TSageMetaEngine() : AdvancedMetaEngine(TsAGE::gameDescriptions, sizeof(TsAGE::tSageGameDescription), tSageGameTitles) { _singleid = "tsage"; - _guioptions = GUIO1(GUIO_NOSPEECH); } virtual const char *getName() const { diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index ece6ae3eda..b7724f072c 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -369,6 +369,7 @@ namespace Ringworld2 { Ringworld2Globals::Ringworld2Globals() { _scannerDialog = new ScannerDialog(); + _speechSubtitles = SPEECH_TEXT; } Ringworld2Globals::~Ringworld2Globals() { @@ -480,7 +481,6 @@ void Ringworld2Globals::reset() { _s1550PlayerArea[R2_QUINN] = Common::Point(27, 4); _s1550PlayerArea[R2_SEEKER] = Common::Point(27, 4); Common::fill(&_scannerFrequencies[0], &_scannerFrequencies[MAX_CHARACTERS], 1); - _speechSubtitles = SPEECH_VOICE | SPEECH_TEXT; _insetUp = 0; _frameEdgeColor = 2; Common::fill(&_stripManager_lookupList[0], &_stripManager_lookupList[12], 0); @@ -539,10 +539,7 @@ void Ringworld2Globals::synchronize(Serializer &s) { s.syncAsSint16LE(_v5780E); s.syncAsSint16LE(_v57810); s.syncAsSint16LE(_v57C2C); - s.syncAsSint16LE(_speechSubtitles); - byte temp = 0; - s.syncAsByte(temp); s.syncAsByte(_s1550PlayerArea[R2_QUINN].x); s.syncAsByte(_s1550PlayerArea[R2_SEEKER].x); s.syncAsByte(_s1550PlayerArea[R2_QUINN].y); diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index 90df72ab32..8e5537f2d1 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -622,9 +622,8 @@ void SceneHandlerExt::process(Event &event) { } void SceneHandlerExt::postLoad(int priorSceneBeforeLoad, int currentSceneBeforeLoad) { - if (priorSceneBeforeLoad == -1 || priorSceneBeforeLoad == 50 - || currentSceneBeforeLoad == 180 || priorSceneBeforeLoad == 205) - setupPaletteMaps(); + // Set up the shading maps used for showing the player in shadows + setupPaletteMaps(); if (currentSceneBeforeLoad == 2900) { R2_GLOBALS._gfxFontNumber = 50; diff --git a/engines/tsage/ringworld2/ringworld2_speakers.cpp b/engines/tsage/ringworld2/ringworld2_speakers.cpp index a43938230e..4be3212e77 100644 --- a/engines/tsage/ringworld2/ringworld2_speakers.cpp +++ b/engines/tsage/ringworld2/ringworld2_speakers.cpp @@ -36,6 +36,7 @@ namespace Ringworld2 { VisualSpeaker::VisualSpeaker(): Speaker() { _delayAmount = 0; + _voiceDelayAmount = 0; _frameNumber = R2_GLOBALS._events.getFrameNumber(); _color1 = 8; _color2 = 0; @@ -79,8 +80,7 @@ void VisualSpeaker::signal() { _sceneText.show(); if ((R2_GLOBALS._speechSubtitles & SPEECH_VOICE) && _soundId) { - // TODO: Check global that is passed - setFrame2(/* word_55F90 */ 1); + setVoiceFrame(1); } } else if (_action && _object2) { _action->setDelay(1); @@ -108,14 +108,14 @@ void VisualSpeaker::dispatch() { } // Delay check for voice - if (_delayAmount2) { - if (frameNumber >= _frameNumber2) { - _delayAmount2 = _delayAmount2 - (_frameNumber2 - frameNumber); - _frameNumber2 = frameNumber; - - if (_delayAmount2 <= 0) { - _delayAmount2 = 0; - if (R2_GLOBALS._playStream.play(0, NULL)) { + if (_voiceDelayAmount) { + if (frameNumber >= _voiceFrameNumber) { + _voiceDelayAmount = _voiceDelayAmount - (frameNumber - _voiceFrameNumber); + _voiceFrameNumber = frameNumber; + + if (_voiceDelayAmount <= 0) { + _voiceDelayAmount = 0; + if (R2_GLOBALS._playStream.play(_soundId, NULL)) { _numFrames = 2; _soundId = 0; } else { @@ -149,8 +149,8 @@ void VisualSpeaker::synchronize(Serializer &s) { s.syncAsSint16LE(_numFrames); s.syncAsSint16LE(_delayAmount); s.syncAsUint32LE(_frameNumber); - s.syncAsSint16LE(_delayAmount2); - s.syncAsUint32LE(_frameNumber2); + s.syncAsSint16LE(_voiceDelayAmount); + s.syncAsUint32LE(_voiceFrameNumber); } void VisualSpeaker::setText(const Common::String &msg) { @@ -266,9 +266,9 @@ void VisualSpeaker::setFrame(int numFrames) { _frameNumber = R2_GLOBALS._events.getFrameNumber(); } -void VisualSpeaker::setFrame2(int numFrames) { - _delayAmount2 = numFrames; - _frameNumber2 = R2_GLOBALS._events.getFrameNumber(); +void VisualSpeaker::setVoiceFrame(int numFrames) { + _voiceDelayAmount = numFrames; + _voiceFrameNumber = R2_GLOBALS._events.getFrameNumber(); } void VisualSpeaker::setDelay(int delay) { diff --git a/engines/tsage/ringworld2/ringworld2_speakers.h b/engines/tsage/ringworld2/ringworld2_speakers.h index 1b87606381..a49bb1d3e5 100644 --- a/engines/tsage/ringworld2/ringworld2_speakers.h +++ b/engines/tsage/ringworld2/ringworld2_speakers.h @@ -49,11 +49,11 @@ public: bool _removeObject; uint32 _frameNumber; int _numFrames; - int _delayAmount2; - uint32 _frameNumber2; + int _voiceDelayAmount; + uint32 _voiceFrameNumber; private: void setFrame(int numFrames); - void setFrame2(int numFrames); + void setVoiceFrame(int numFrames); public: VisualSpeaker(); diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp index 02abc58178..844cfc1d4d 100644 --- a/engines/tsage/sound.cpp +++ b/engines/tsage/sound.cpp @@ -120,17 +120,31 @@ void SoundManager::syncSounds() { bool mute = false; if (ConfMan.hasKey("mute")) mute = ConfMan.getBool("mute"); + bool subtitles = ConfMan.hasKey("subtitles") ? ConfMan.getBool("subtitles") : true; bool music_mute = mute; + bool voice_mute = mute; if (!mute) { music_mute = ConfMan.getBool("music_mute"); + voice_mute = ConfMan.getBool("speech_mute"); } // Get the new music volume int musicVolume = music_mute ? 0 : MIN(255, ConfMan.getInt("music_volume")); this->setMasterVol(musicVolume / 2); + + // Return to Ringworld voice settings + if (g_vm->getGameID() == GType_Ringworld2) { + // If we don't have voice, then ensure that text is turned on + if (voice_mute) + subtitles = true; + + R2_GLOBALS._speechSubtitles = + (voice_mute ? 0 : SPEECH_VOICE) | + (!subtitles ? 0 : SPEECH_TEXT); + } } void SoundManager::update() { @@ -2525,6 +2539,7 @@ void PlayStream::ResFileData::load(Common::SeekableReadStream &stream) { PlayStream::PlayStream(): EventHandler() { _index = NULL; _endAction = NULL; + _audioStream = NULL; } PlayStream::~PlayStream() { @@ -2552,9 +2567,8 @@ bool PlayStream::setFile(const Common::String &filename) { bool PlayStream::play(int voiceNum, EventHandler *endAction) { uint32 offset = getFileOffset(_index, _resData._fileChunkSize, voiceNum); if (offset) { + stop(); _voiceNum = 0; - if (_sound.isPlaying()) - _sound.stop(); // Move to the offset for the start of the voice _file.seek(offset); @@ -2572,17 +2586,20 @@ bool PlayStream::play(int voiceNum, EventHandler *endAction) { _file.skip(4); // Create the stream - Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(rate, false); + _audioStream = Audio::makeQueuingAudioStream(rate, false); // Load in the first chunk byte *data = (byte *)malloc(chunkSize); _file.read(data, chunkSize); - audioStream->queueBuffer(data, chunkSize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED); + _audioStream->queueBuffer(data, chunkSize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED); // If necessary, load further chunks of the voice in while (chunkSize == (_resData._chunkSize - 16)) { // Ensure the next chunk has the 'MORE' header _file.read(&header[0], 4); + if (!strncmp(header, "FEED", 4)) + // Reached start of next voice sample, so stop + break; if (strncmp(header, "MORE", 4)) error("Invalid stream data"); @@ -2593,13 +2610,13 @@ bool PlayStream::play(int voiceNum, EventHandler *endAction) { // Read in the data for this next chunk and queue it data = (byte *)malloc(chunkSize); _file.read(data, chunkSize); - audioStream->queueBuffer(data, chunkSize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED); + _audioStream->queueBuffer(data, chunkSize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED); } - + g_vm->_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_soundHandle, - audioStream, DisposeAfterUse::YES); - - return true; + _audioStream, DisposeAfterUse::YES); + _voiceNum = voiceNum; + return true; } // If it reaches this point, no valid voice data found @@ -2607,14 +2624,17 @@ bool PlayStream::play(int voiceNum, EventHandler *endAction) { } void PlayStream::stop() { - g_vm->_mixer->stopHandle(_soundHandle); + if (_audioStream) { + g_vm->_mixer->stopHandle(_soundHandle); + } + _audioStream = NULL; _voiceNum = 0; _endAction = NULL; } bool PlayStream::isPlaying() const { - return _voiceNum != 0 && g_vm->_mixer->isSoundHandleActive(_soundHandle); + return _audioStream != NULL && !_audioStream->endOfData(); } void PlayStream::remove() { diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h index 83cd4753d5..95d0337af3 100644 --- a/engines/tsage/sound.h +++ b/engines/tsage/sound.h @@ -427,8 +427,8 @@ class PlayStream: public EventHandler { private: Common::File _file; ResFileData _resData; + Audio::QueuingAudioStream *_audioStream; Audio::SoundHandle _soundHandle; - Sound _sound; uint16 *_index; EventHandler *_endAction; int _voiceNum; |