[Scummvm-git-logs] scummvm master -> bb618d3b5c15812a4b77cb4fccdc62cbc73914b9
mgerhardy
martin.gerhardy at gmail.com
Sun Mar 28 21:08:22 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c91f547bf5 TWINE: reduced debug output on lower debug levels
7c8bceee81 TWINE: debug output
db0db6c0c1 TWINE: return value of initVoxToPlay now indicates whether there is speech
bb618d3b5c TWINE: fixed vox and tts playback and aborting
Commit: c91f547bf58d45c0705fabe499d5c4873dd35124
https://github.com/scummvm/scummvm/commit/c91f547bf58d45c0705fabe499d5c4873dd35124
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-28T22:46:45+02:00
Commit Message:
TWINE: reduced debug output on lower debug levels
Changed paths:
engines/twine/scene/gamestate.h
diff --git a/engines/twine/scene/gamestate.h b/engines/twine/scene/gamestate.h
index 5fea87ae88..96802ae4cc 100644
--- a/engines/twine/scene/gamestate.h
+++ b/engines/twine/scene/gamestate.h
@@ -136,7 +136,7 @@ public:
}
inline uint8 hasGameFlag(uint8 index) const {
- debug(3, "Query gameStateFlags[%u]=%u", index, _gameStateFlags[index]);
+ debug(6, "Query gameStateFlags[%u]=%u", index, _gameStateFlags[index]);
return _gameStateFlags[index];
}
Commit: 7c8bceee816069db9cd7eb45d57d5bee696633da
https://github.com/scummvm/scummvm/commit/7c8bceee816069db9cd7eb45d57d5bee696633da
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-28T22:46:45+02:00
Commit Message:
TWINE: debug output
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index fe417d0810..5d18680594 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -558,6 +558,7 @@ ProgressiveTextState Text::updateProgressiveText() {
}
bool Text::displayText(int32 index, bool showText, bool playVox, bool loop) {
+ debug(3, "displayText(%i, %s)", index, showText ? "true" : "false");
if (playVox) {
// get right VOX entry index
initVoxToPlay(index);
Commit: db0db6c0c1631f2218f5606d75271a429939a6b4
https://github.com/scummvm/scummvm/commit/db0db6c0c1631f2218f5606d75271a429939a6b4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-28T22:46:45+02:00
Commit Message:
TWINE: return value of initVoxToPlay now indicates whether there is speech
Changed paths:
engines/twine/audio/sound.cpp
engines/twine/audio/sound.h
engines/twine/text.cpp
diff --git a/engines/twine/audio/sound.cpp b/engines/twine/audio/sound.cpp
index f779470fba..11b1997210 100644
--- a/engines/twine/audio/sound.cpp
+++ b/engines/twine/audio/sound.cpp
@@ -109,15 +109,9 @@ void Sound::playSample(int32 index, int32 repeat, int32 x, int32 y, int32 z, int
playSample(channelIdx, index, sampPtr, sampSize, repeat, Resources::HQR_SAMPLES_FILE, Audio::Mixer::kSFXSoundType, DisposeAfterUse::NO);
}
-void Sound::playVoxSample(int32 index) {
+bool Sound::playVoxSample(int32 index) {
if (!_engine->cfgfile.Sound) {
- return;
- }
-
- int channelIdx = getFreeSampleChannelIndex();
- if (channelIdx == -1) {
- warning("Failed to play vox sample for index: %i - no free channel", index);
- return;
+ return false;
}
uint8 *sampPtr = nullptr;
@@ -131,13 +125,19 @@ void Sound::playVoxSample(int32 index) {
const TextEntry *text = _engine->_resources->getText(_engine->_text->textBank(), index);
if (text) {
ttsMan->say(text->string);
+ return true;
}
- return;
}
}
#endif
warning("Failed to get vox sample for index: %i", index);
- return;
+ return false;
+ }
+
+ int channelIdx = getFreeSampleChannelIndex();
+ if (channelIdx == -1) {
+ warning("Failed to play vox sample for index: %i - no free channel", index);
+ return false;
}
// Fix incorrect sample files first byte
@@ -147,7 +147,7 @@ void Sound::playVoxSample(int32 index) {
*sampPtr = 'C';
}
- playSample(channelIdx, index, sampPtr, sampSize, 1, _engine->_text->currentVoxBankFile.c_str(), Audio::Mixer::kSpeechSoundType);
+ return playSample(channelIdx, index, sampPtr, sampSize, 1, _engine->_text->currentVoxBankFile.c_str(), Audio::Mixer::kSpeechSoundType);
}
bool Sound::playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize, int32 loop, const char *name, Audio::Mixer::SoundType soundType, DisposeAfterUse::Flag disposeFlag) {
diff --git a/engines/twine/audio/sound.h b/engines/twine/audio/sound.h
index 43859eb974..c305e6e26b 100644
--- a/engines/twine/audio/sound.h
+++ b/engines/twine/audio/sound.h
@@ -119,7 +119,7 @@ public:
int32 isSamplePlaying(int32 index);
/** Play VOX sample */
- void playVoxSample(int32 index);
+ bool playVoxSample(int32 index);
};
} // namespace TwinE
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 5d18680594..b06e5d636e 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -93,9 +93,7 @@ bool Text::initVoxToPlay(int32 index) { // setVoxFileAtDigit
const TextEntry *textEntry = _engine->_resources->getText(_currentBankIdx, index);
currDialTextEntry = textEntry ? textEntry->index : 0;
- _engine->_sound->playVoxSample(currDialTextEntry);
-
- return true;
+ return _engine->_sound->playVoxSample(currDialTextEntry);
}
bool Text::playVox(int32 index) {
Commit: bb618d3b5c15812a4b77cb4fccdc62cbc73914b9
https://github.com/scummvm/scummvm/commit/bb618d3b5c15812a4b77cb4fccdc62cbc73914b9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-28T23:08:01+02:00
Commit Message:
TWINE: fixed vox and tts playback and aborting
Changed paths:
engines/twine/audio/sound.cpp
engines/twine/audio/sound.h
engines/twine/scene/gamestate.cpp
engines/twine/script/script_life_v1.cpp
engines/twine/text.cpp
engines/twine/text.h
engines/twine/twine.cpp
diff --git a/engines/twine/audio/sound.cpp b/engines/twine/audio/sound.cpp
index 11b1997210..7e17dd8b4b 100644
--- a/engines/twine/audio/sound.cpp
+++ b/engines/twine/audio/sound.cpp
@@ -28,6 +28,7 @@
#include "common/text-to-speech.h"
#include "common/types.h"
#include "common/util.h"
+#include "twine/parser/text.h"
#include "twine/scene/collision.h"
#include "twine/flamovies.h"
#include "twine/scene/grid.h"
@@ -109,34 +110,32 @@ void Sound::playSample(int32 index, int32 repeat, int32 x, int32 y, int32 z, int
playSample(channelIdx, index, sampPtr, sampSize, repeat, Resources::HQR_SAMPLES_FILE, Audio::Mixer::kSFXSoundType, DisposeAfterUse::NO);
}
-bool Sound::playVoxSample(int32 index) {
- if (!_engine->cfgfile.Sound) {
+bool Sound::playVoxSample(const TextEntry *text) {
+ if (!_engine->cfgfile.Sound || text == nullptr) {
return false;
}
uint8 *sampPtr = nullptr;
- int32 sampSize = HQR::getAllocVoxEntry(&sampPtr, _engine->_text->currentVoxBankFile.c_str(), index, _engine->_text->voxHiddenIndex);
+ int32 sampSize = HQR::getAllocVoxEntry(&sampPtr, _engine->_text->currentVoxBankFile.c_str(), text->index, _engine->_text->voxHiddenIndex);
if (sampSize == 0) {
#ifdef USE_TTS
- if (ConfMan.getBool("tts_narrator")) {
+ if (ConfMan.hasKey("tts_narrator") && ConfMan.getBool("tts_narrator")) {
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr) {
ttsMan->stop();
- const TextEntry *text = _engine->_resources->getText(_engine->_text->textBank(), index);
- if (text) {
- ttsMan->say(text->string);
- return true;
- }
+ return ttsMan->say(text->string);
}
+ } else {
+ debug(4, "TTS disabled");
}
#endif
- warning("Failed to get vox sample for index: %i", index);
+ warning("Failed to get vox sample for index: %i", text->index);
return false;
}
int channelIdx = getFreeSampleChannelIndex();
if (channelIdx == -1) {
- warning("Failed to play vox sample for index: %i - no free channel", index);
+ warning("Failed to play vox sample for index: %i - no free channel", text->index);
return false;
}
@@ -147,7 +146,7 @@ bool Sound::playVoxSample(int32 index) {
*sampPtr = 'C';
}
- return playSample(channelIdx, index, sampPtr, sampSize, 1, _engine->_text->currentVoxBankFile.c_str(), Audio::Mixer::kSpeechSoundType);
+ return playSample(channelIdx, text->index, sampPtr, sampSize, 1, _engine->_text->currentVoxBankFile.c_str(), Audio::Mixer::kSpeechSoundType);
}
bool Sound::playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize, int32 loop, const char *name, Audio::Mixer::SoundType soundType, DisposeAfterUse::Flag disposeFlag) {
diff --git a/engines/twine/audio/sound.h b/engines/twine/audio/sound.h
index c305e6e26b..e34c7f9f89 100644
--- a/engines/twine/audio/sound.h
+++ b/engines/twine/audio/sound.h
@@ -30,6 +30,8 @@
namespace TwinE {
+class TextEntry;
+
#define NUM_CHANNELS 32
namespace Samples {
@@ -119,7 +121,7 @@ public:
int32 isSamplePlaying(int32 index);
/** Play VOX sample */
- bool playVoxSample(int32 index);
+ bool playVoxSample(const TextEntry *text);
};
} // namespace TwinE
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index e5933e4630..32731f0827 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -356,7 +356,7 @@ void GameState::processFoundItem(int32 item) {
ProgressiveTextState textState = ProgressiveTextState::ContinueRunning;
- _engine->_text->initVoxToPlay(item);
+ _engine->_text->initVoxToPlayTextId(100 + item);
const int32 bodyAnimIdx = _engine->_animations->getBodyAnimIndex(AnimationTypes::kFoundItem);
const AnimData ¤tAnimData = _engine->_resources->animData[bodyAnimIdx];
@@ -465,7 +465,7 @@ void GameState::processGameChoices(int32 choiceIdx) {
choiceAnswer = gameChoices[activeButton];
// get right VOX entry index
- if (_engine->_text->initVoxToPlay(choiceAnswer)) {
+ if (_engine->_text->initVoxToPlayTextId(choiceAnswer)) {
while (_engine->_text->playVoxSimple(_engine->_text->currDialTextEntry)) {
FrameMarker frame;
ScopedFPS scopedFps;
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index 0ecd1630e1..55783f5015 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -1368,7 +1368,7 @@ static int32 lSAY_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_redraw->addOverlay(OverlayType::koText, textEntry, 0, 0, ctx.actorIdx, OverlayPosType::koFollowActor, 2);
ScopedEngineFreeze scoped(engine);
- engine->_text->initVoxToPlay(textEntry);
+ engine->_text->initVoxToPlayTextId(textEntry);
return 0;
}
@@ -1384,13 +1384,13 @@ static int32 lSAY_MESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_redraw->addOverlay(OverlayType::koText, textEntry, 0, 0, otherActorIdx, OverlayPosType::koFollowActor, 2);
ScopedEngineFreeze scoped(engine);
- engine->_text->initVoxToPlay(textEntry);
+ engine->_text->initVoxToPlayTextId(textEntry);
return 0;
}
/**
- * Set Twinsen life point as full.
+ * Set Twinsen life point as full
* @note Opcode @c 0x4F
*/
static int32 lFULL_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index b06e5d636e..6bfd181b60 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -27,6 +27,7 @@
#include "common/scummsys.h"
#include "common/str.h"
#include "common/system.h"
+#include "common/text-to-speech.h"
#include "common/util.h"
#include "twine/audio/sound.h"
#include "twine/input.h"
@@ -82,45 +83,68 @@ void Text::initVoxBank(int32 bankIdx) {
// TODO check the rest to reverse
}
-bool Text::initVoxToPlay(int32 index) { // setVoxFileAtDigit
- currDialTextEntry = 0;
+bool Text::initVoxToPlayTextId(int textId) {
+ const TextEntry *text = _engine->_resources->getText(_currentBankIdx, textId);
+ return initVoxToPlay(text);
+}
+
+bool Text::initVoxToPlay(const TextEntry *text) {
+ currDialTextEntry = text;
voxHiddenIndex = 0;
hasHiddenVox = false;
+ if (text == nullptr) {
+ return false;
+ }
+
if (!_engine->cfgfile.Voice) {
+ debug(3, "Voices are disabled");
return false;
}
- const TextEntry *textEntry = _engine->_resources->getText(_currentBankIdx, index);
- currDialTextEntry = textEntry ? textEntry->index : 0;
return _engine->_sound->playVoxSample(currDialTextEntry);
}
-bool Text::playVox(int32 index) {
+bool Text::playVox(const TextEntry *text) {
if (!_engine->cfgfile.Voice) {
return false;
}
- if (hasHiddenVox && !_engine->_sound->isSamplePlaying(index)) {
- _engine->_sound->playVoxSample(index);
+ if (text == nullptr) {
+ return false;
+ }
+ if (hasHiddenVox && !_engine->_sound->isSamplePlaying(text->index)) {
+ _engine->_sound->playVoxSample(text);
return true;
}
return false;
}
-bool Text::playVoxSimple(int32 index) {
- if (_engine->_sound->isSamplePlaying(index)) {
+bool Text::playVoxSimple(const TextEntry *text) {
+ if (text == nullptr) {
+ return false;
+ }
+ if (_engine->_sound->isSamplePlaying(text->index)) {
return true;
}
- return playVox(index);
+ return playVox(text);
}
-bool Text::stopVox(int32 index) {
- if (!_engine->_sound->isSamplePlaying(index)) {
+bool Text::stopVox(const TextEntry *text) {
+#ifdef USE_TTS
+ Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
+ if (ttsMan != nullptr) {
+ ttsMan->stop();
+ }
+#endif
+ if (text == nullptr) {
+ return false;
+ }
+ if (!_engine->_sound->isSamplePlaying(text->index)) {
return false;
}
hasHiddenVox = false;
- _engine->_sound->stopSample(index);
+ _engine->_sound->stopSample(text->index);
return true;
}
@@ -556,10 +580,12 @@ ProgressiveTextState Text::updateProgressiveText() {
}
bool Text::displayText(int32 index, bool showText, bool playVox, bool loop) {
- debug(3, "displayText(%i, %s)", index, showText ? "true" : "false");
+ debug(3, "displayText(index = %i, showText = %s, playVox = %s)",
+ index, showText ? "true" : "false", playVox ? "true" : "false");
if (playVox) {
+ const TextEntry *textEntry = _engine->_resources->getText(_currentBankIdx, index);
// get right VOX entry index
- initVoxToPlay(index);
+ initVoxToPlay(textEntry);
}
bool aborted = false;
@@ -671,7 +697,7 @@ bool Text::getText(int32 index) {
_currDialTextSize = textEntry->string.size();
// RECHECK: this was added for vox playback
- currDialTextEntry = textEntry->index;
+ currDialTextEntry = textEntry;
debug(3, "text for bank %i with index %i (currIndex: %i): %s", _currentBankIdx, textEntry->index, textEntry->textIndex, _currDialTextPtr);
return true;
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 64b8cbf3c1..8500d5f00f 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -29,6 +29,8 @@
namespace TwinE {
+class TextEntry;
+
// lba
namespace TextBankId {
enum _TextBankId {
@@ -241,7 +243,7 @@ public:
int32 voxHiddenIndex = 0;
// ---
- int32 currDialTextEntry = 0; // ordered entry
+ const TextEntry *currDialTextEntry = nullptr; // ordered entry
Common::String currentVoxBankFile;
bool showDialogueBubble = true;
@@ -331,10 +333,11 @@ public:
void drawAskQuestion(int32 index);
void drawHolomapLocation(int32 index);
- bool playVox(int32 index);
- bool playVoxSimple(int32 index);
- bool stopVox(int32 index);
- bool initVoxToPlay(int32 index);
+ bool playVox(const TextEntry *text);
+ bool playVoxSimple(const TextEntry *text);
+ bool stopVox(const TextEntry *text);
+ bool initVoxToPlay(const TextEntry *text);
+ bool initVoxToPlayTextId(int textId);
};
} // namespace TwinE
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 31cb4f56b5..6a4f4b6b77 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -397,8 +397,8 @@ void TwinEEngine::initConfigurations() {
const char *lng = Common::getLanguageDescription(_gameLang);
cfgfile.LanguageId = getLanguageTypeIndex(lng);
- cfgfile.Voice = ConfGetIntOrDefault("voice", 1) == 1;
- cfgfile.FlagDisplayText = ConfGetIntOrDefault("displaytext", 1) == 1;
+ cfgfile.Voice = ConfGetBoolOrDefault("voice", true);
+ cfgfile.FlagDisplayText = ConfGetBoolOrDefault("displaytext", true);
const Common::String midiType = ConfGetOrDefault("miditype", "auto");
if (midiType == "None") {
cfgfile.MidiType = MIDIFILE_NONE;
More information about the Scummvm-git-logs
mailing list