From cdc8bc4e58ac2df1edac69a1a6c6f7a57cd5f7e3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 29 Oct 2021 22:10:14 -0700 Subject: [PATCH] CHEWY: Respect the ScummVM speech/subtitle setting --- engines/chewy/ailclass.cpp | 9 +++++++++ engines/chewy/ailclass.h | 10 ++++++++++ engines/chewy/atds.cpp | 40 ++++++++++++++++++++++++-------------- engines/chewy/atds.h | 4 +++- engines/chewy/file.cpp | 4 ++-- engines/chewy/inits.cpp | 2 +- 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/engines/chewy/ailclass.cpp b/engines/chewy/ailclass.cpp index c36fdf31009..19e7d1e615a 100644 --- a/engines/chewy/ailclass.cpp +++ b/engines/chewy/ailclass.cpp @@ -22,6 +22,7 @@ #include "audio/audiostream.h" #include "audio/decoders/raw.h" +#include "common/config-manager.h" #include "chewy/chewy.h" #include "chewy/ailclass.h" #include "chewy/file.h" @@ -192,6 +193,14 @@ void ailScummVM::waitForSpeechToFinish() { } } +bool ailScummVM::hasSubtitles() { + return ConfMan.getBool("subtitles"); +} + +bool ailScummVM::isSpeechMuted() { + return ConfMan.getBool("speech_mute"); +} + ailclass::ailclass() { #if 0 diff --git a/engines/chewy/ailclass.h b/engines/chewy/ailclass.h index 5270371789f..0f32ab403ad 100644 --- a/engines/chewy/ailclass.h +++ b/engines/chewy/ailclass.h @@ -56,6 +56,16 @@ public: * Helper method to wait until any playing speech is finished */ void waitForSpeechToFinish(); + + /** + * Returns true if subtitles are enabled + */ + bool hasSubtitles(); + + /** + * Returns true if speech is muted + */ + bool isSpeechMuted(); }; class ailclass : public ailScummVM { diff --git a/engines/chewy/atds.cpp b/engines/chewy/atds.cpp index 710d72fbf63..c8c3e9097d8 100644 --- a/engines/chewy/atds.cpp +++ b/engines/chewy/atds.cpp @@ -104,8 +104,19 @@ void atdsys::set_string_end_func atdsv.aad_str = str_func; } -void atdsys::set_display(int16 mode) { - atdsv.Display = mode; +void atdsys::setHasSpeech(bool hasSpeech) { + _hasSpeech = hasSpeech; + updateSoundSettings(); +} + +void atdsys::updateSoundSettings() { + atdsv.Display = DISPLAY_TXT; + + if (_hasSpeech) { + // TODO: In the future, properly implement DISPLAY_ALL + if (!ailsnd->isSpeechMuted()) + atdsv.Display = DISPLAY_VOC; + } } int16 atdsys::get_delay(int16 txt_len) { @@ -735,26 +746,25 @@ void atdsys::del_steuer_bit(int16 txt_nr, int16 bit_idx, int16 mode) { } char *atdsys::ats_search_block(int16 txt_mode, char *txt_adr) { - char *str_; - int16 ende; - str_ = txt_adr; - ende = 0; - while (!ende) { - if (str_[0] == (char)BLOCKENDE && - str_[1] == (char)BLOCKENDE && - str_[2] == (char)BLOCKENDE) { + char *strP = txt_adr; + int ende = 0; + + for (; !ende; ++strP) { + if (strP[0] == (char)BLOCKENDE && + strP[1] == (char)BLOCKENDE && + strP[2] == (char)BLOCKENDE) { ende = 2; - } else if (str_[0] == (char)0xf2 && str_[1] == (char)0xfe) { - if (str_[2] == (char)txt_mode) + } else if (strP[0] == (char)0xf2 && strP[1] == (char)0xfe) { + if (strP[2] == (char)txt_mode) ende = 1; - str_ += 3; + strP += 2; } } if (ende == 2) - str_ = 0; + strP = nullptr; - return str_; + return strP; } void atdsys::ats_search_nr(int16 txt_nr, char **str_) { diff --git a/engines/chewy/atds.h b/engines/chewy/atds.h index f7dfb665292..fd4c602542b 100644 --- a/engines/chewy/atds.h +++ b/engines/chewy/atds.h @@ -253,7 +253,8 @@ public: void set_font(byte *font_adr, int16 fvorx, int16 fhoehe); void set_delay(int16 *delay, int16 silent); - void set_display(int16 mode); + void setHasSpeech(bool hasSpeech); + void updateSoundSettings(); void set_split_win(int16 nr, SplitStringInit *ssinit); SplitStringRet *split_string(SplitStringInit *ssi); void calc_txt_win(SplitStringInit *ssi); @@ -344,6 +345,7 @@ private: char *inv_use_mem; int16 tmp_delay; in_zeiger *inzeig; + bool _hasSpeech = false; }; } // namespace Chewy diff --git a/engines/chewy/file.cpp b/engines/chewy/file.cpp index c0876af83ee..a57a59f5498 100644 --- a/engines/chewy/file.cpp +++ b/engines/chewy/file.cpp @@ -533,12 +533,12 @@ void option_menue(taf_info *ti) { if (spieler.DisplayText) { if (flags.InitSound) { spieler.DisplayText = false; - atds->set_display(DISPLAY_VOC); + atds->setHasSpeech(true); spieler.SpeechSwitch = true; } } else { spieler.DisplayText = true; - atds->set_display(DISPLAY_TXT); + atds->setHasSpeech(false); spieler.SpeechSwitch = false; } break; diff --git a/engines/chewy/inits.cpp b/engines/chewy/inits.cpp index 8c48338e114..119473b69f0 100644 --- a/engines/chewy/inits.cpp +++ b/engines/chewy/inits.cpp @@ -489,7 +489,7 @@ void sound_init() { ailsnd->init_double_buffer(SpeechBuf[0], SpeechBuf[1], SPEECH_HALF_BUF, 0); atds->set_speech_handle(speech_handle); - atds->set_display(DISPLAY_VOC); + atds->setHasSpeech(true); spieler.DisplayText = false; }