[Scummvm-git-logs] scummvm master -> e2f77bd64313aab4b1b9640b4e11a11a29819abc

bluegr noreply at scummvm.org
Sat Apr 2 09:22:39 UTC 2022


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b50c3de79f CHEWY: Cleanup member variables
e2f77bd643 CHEWY: Refactor the speech and text display logic


Commit: b50c3de79fa4bbeb458d6b9264374aa5cee3dad9
    https://github.com/scummvm/scummvm/commit/b50c3de79fa4bbeb458d6b9264374aa5cee3dad9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-04-02T12:22:13+03:00

Commit Message:
CHEWY: Cleanup member variables

Changed paths:
    engines/chewy/atds.cpp
    engines/chewy/atds.h


diff --git a/engines/chewy/atds.cpp b/engines/chewy/atds.cpp
index 2492563327b..5c937adb5f9 100644
--- a/engines/chewy/atds.cpp
+++ b/engines/chewy/atds.cpp
@@ -82,7 +82,7 @@ bool AtsStrHeader::load(Common::SeekableReadStream *src) {
 
 
 Atdsys::Atdsys() {
-	SplitStringInit init_ssi = { nullptr, 0, 0, 220, 4, SPLIT_CENTER, 8, 8 };
+	SplitStringInit init_ssi = { nullptr, 0, 0, 220, 4, SPLIT_CENTER };
 	_aadv._dialog = false;
 	_aadv._strNr = -1;
 	_aadv._silentCount = false;
@@ -169,7 +169,8 @@ void Atdsys::updateSoundSettings() {
 }
 
 int16 Atdsys::get_delay(int16 txt_len) {
-	int16 z_len = (_ssi->_width / _ssi->fontWidth) + 1;
+	const int16 w = _G(fontMgr)->getFont()->getDataWidth();
+	int16 z_len = (_ssi->_width / w) + 1;
 	int16 maxLen = z_len * _ssi->_lines;
 	if (txt_len > maxLen)
 		txt_len = maxLen;
@@ -179,11 +180,14 @@ int16 Atdsys::get_delay(int16 txt_len) {
 }
 
 SplitStringRet *Atdsys::split_string(SplitStringInit *ssi_) {
+	const int16 w = _G(fontMgr)->getFont()->getDataWidth();
+	const int16 h = _G(fontMgr)->getFont()->getDataHeight();
+
 	_ssret._nr = 0;
 	_ssret._next = false;
 	_ssret._strPtr = _splitPtr;
 	_ssret._x = _splitX;
-	int16 zeichen_anz = (ssi_->_width / ssi_->fontWidth) + 1;
+	int16 zeichen_anz = (ssi_->_width / w) + 1;
 	memset(_splitPtr, 0, sizeof(char *) * MAX_STR_SPLIT);
 	calc_txt_win(ssi_);
 	char *str_adr = ssi_->_str;
@@ -213,7 +217,7 @@ SplitStringRet *Atdsys::split_string(SplitStringInit *ssi_) {
 				_splitPtr[_ssret._nr] = start_adr;
 				start_adr[tmp_count] = 0;
 				if (ssi_->_mode == SPLIT_CENTER)
-					_splitX[_ssret._nr] = ssi_->_x + ((ssi_->_width - (strlen(start_adr) * ssi_->fontWidth)) >> 1);
+					_splitX[_ssret._nr] = ssi_->_x + ((ssi_->_width - (strlen(start_adr) * w)) >> 1);
 				else
 					_splitX[_ssret._nr] = ssi_->_x;
 				++_ssret._nr;
@@ -260,7 +264,7 @@ SplitStringRet *Atdsys::split_string(SplitStringInit *ssi_) {
 					_splitPtr[_ssret._nr] = start_adr;
 					start_adr[tmp_count] = 0;
 					if (ssi_->_mode == SPLIT_CENTER)
-						_splitX[_ssret._nr] = ssi_->_x + ((ssi_->_width - (strlen(start_adr) * ssi_->fontWidth)) >> 1);
+						_splitX[_ssret._nr] = ssi_->_x + ((ssi_->_width - (strlen(start_adr) * w)) >> 1);
 					else
 						_splitX[_ssret._nr] = ssi_->_x;
 					++_ssret._nr;
@@ -295,7 +299,7 @@ SplitStringRet *Atdsys::split_string(SplitStringInit *ssi_) {
 		}
 	}
 	if (_ssret._nr <= ssi_->_lines)
-		_ssret._y = ssi_->_y + (ssi_->_lines - _ssret._nr) * ssi_->fontHeight;
+		_ssret._y = ssi_->_y + (ssi_->_lines - _ssret._nr) * h;
 	else
 		_ssret._y = ssi_->_y;
 
@@ -311,6 +315,8 @@ void Atdsys::str_null2leer(char *strStart, char *strEnd) {
 }
 
 void Atdsys::calc_txt_win(SplitStringInit *ssi_) {
+	const int16 h = _G(fontMgr)->getFont()->getDataHeight();
+
 	if (ssi_->_x - (ssi_->_width >> 1) < 2)
 		ssi_->_x = 2;
 	else if (ssi_->_x + (ssi_->_width >> 1) > (SCREEN_WIDTH - 2))
@@ -318,12 +324,12 @@ void Atdsys::calc_txt_win(SplitStringInit *ssi_) {
 	else
 		ssi_->_x -= (ssi_->_width >> 1);
 
-	if (ssi_->_y - (ssi_->_lines * ssi_->fontHeight) < 2) {
+	if (ssi_->_y - (ssi_->_lines * h) < 2) {
 		ssi_->_y = 2;
-	} else if (ssi_->_y + (ssi_->_lines * ssi_->fontHeight) > (SCREEN_HEIGHT - 2))
-		ssi_->_y = (SCREEN_HEIGHT - 2) - (ssi_->_lines * ssi_->fontHeight);
+	} else if (ssi_->_y + (ssi_->_lines * h) > (SCREEN_HEIGHT - 2))
+		ssi_->_y = (SCREEN_HEIGHT - 2) - (ssi_->_lines * h);
 	else {
-		ssi_->_y -= (ssi_->_lines * ssi_->fontHeight);
+		ssi_->_y -= (ssi_->_lines * h);
 	}
 }
 
@@ -565,29 +571,28 @@ void Atdsys::print_ats(int16 x, int16 y, int16 scrX, int16 scrY) {
 			char *tmp_ptr = _atsv._ptr;
 			SplitStringInit *_atsSsi = &_ssi[0];
 			_atsSsi->_str = tmp_ptr;
-			_atsSsi->fontWidth = _G(fontMgr)->getFont()->getDataWidth();
-			_atsSsi->fontHeight = _G(fontMgr)->getFont()->getDataHeight();
 			_atsSsi->_x = x - scrX;
 			_atsSsi->_y = y - scrY;
 			char *start_ptr = tmp_ptr;
 			str_null2leer(start_ptr, start_ptr + _atsv._txtLen - 1);
 			_ssr = split_string(_atsSsi);
+			const int16 h = _G(fontMgr)->getFont()->getDataHeight();
 
 			for (int16 i = 0; i < _ssr->_nr; i++) {
 				_G(out)->printxy(_ssr->_x[i],
-				              _ssr->_y + (i * _atsSsi->fontHeight) + 1,
+				              _ssr->_y + (i * h) + 1,
 				              0, 300, 0, _ssr->_strPtr[i]);
 				_G(out)->printxy(_ssr->_x[i],
-				              _ssr->_y + (i * _atsSsi->fontHeight) - 1,
+				              _ssr->_y + (i * h) - 1,
 				              0, 300, 0, _ssr->_strPtr[i]);
 				_G(out)->printxy(_ssr->_x[i] + 1,
-				              _ssr->_y + (i * _atsSsi->fontHeight),
+				              _ssr->_y + (i * h),
 				              0, 300, 0, _ssr->_strPtr[i]);
 				_G(out)->printxy(_ssr->_x[i] - 1,
-				              _ssr->_y + (i * _atsSsi->fontHeight),
+				              _ssr->_y + (i * h),
 				              0, 300, 0, _ssr->_strPtr[i]);
 				_G(out)->printxy(_ssr->_x[i],
-				              _ssr->_y + (i * _atsSsi->fontHeight),
+				              _ssr->_y + (i * h),
 				              _atsv._color,
 				              300, 0, _ssr->_strPtr[i]);
 				tmp_ptr += strlen(_ssr->_strPtr[i]) + 1;
@@ -861,6 +866,10 @@ int16 Atdsys::start_aad(int16 diaNr) {
 	if (_atdsMem[AAD_HANDLE]) {
 		_aadv._ptr = _atdsMem[AAD_HANDLE];
 		aad_search_dia(diaNr, &_aadv._ptr);
+
+		//const uint8 roomNum = _G(room)->_roomInfo->_roomNr;
+		//Common::StringArray s = getTextArray(roomNum, diaNr, AAD_DATA);
+
 		if (_aadv._ptr) {
 			_aadv._person.load(_aadv._ptr, _aadv._txtHeader->_perNr);
 			_aadv._ptr += _aadv._txtHeader->_perNr * sizeof(AadInfo);
@@ -920,40 +929,40 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
 
 		if (_aadv._silentCount <= 0) {
 			char *tmp_ptr = _aadv._ptr;
-			_ssi[_aadv._strHeader->_akPerson]._str = tmp_ptr;
-			if (_aadv._person[_aadv._strHeader->_akPerson]._x != -1) {
-				_ssi[_aadv._strHeader->_akPerson]._x = _aadv._person[_aadv._strHeader->_akPerson]._x - scrX;
+			const int16 personId = _aadv._strHeader->_akPerson;
+			_ssi[personId]._str = tmp_ptr;
+			if (_aadv._person[personId]._x != -1) {
+				_ssi[personId]._x = _aadv._person[personId]._x - scrX;
 			}
-			if (_aadv._person[_aadv._strHeader->_akPerson]._y != -1) {
-				_ssi[_aadv._strHeader->_akPerson]._y = _aadv._person[_aadv._strHeader->_akPerson]._y - scrY;
+			if (_aadv._person[personId]._y != -1) {
+				_ssi[personId]._y = _aadv._person[personId]._y - scrY;
 			}
-			_ssi[_aadv._strHeader->_akPerson].fontWidth = _G(fontMgr)->getFont()->getDataWidth();
-			_ssi[_aadv._strHeader->_akPerson].fontHeight = _G(fontMgr)->getFont()->getDataHeight();
 			char *start_ptr = tmp_ptr;
 			int16 txt_len;
 			aad_get_zeilen(start_ptr, &txt_len);
 			str_null2leer(start_ptr, start_ptr + txt_len - 1);
-			SplitStringInit tmp_ssi = _ssi[_aadv._strHeader->_akPerson];
+			SplitStringInit tmp_ssi = _ssi[personId];
 			_ssr = split_string(&tmp_ssi);
 
 			if (_atdsv._display != DISPLAY_VOC ||
 			        (_aadv._strHeader->_vocNr - ATDS_VOC_OFFSET) == -1) {
+				const int16 h = _G(fontMgr)->getFont()->getDataHeight();
 				for (int16 i = 0; i < _ssr->_nr; i++) {
 					_G(out)->printxy(_ssr->_x[i] + 1,
-					              _ssr->_y + (i * _ssi[_aadv._strHeader->_akPerson].fontHeight),
+					              _ssr->_y + (i * h),
 					              0, 300, 0, _ssr->_strPtr[i]);
 					_G(out)->printxy(_ssr->_x[i] - 1,
-					              _ssr->_y + (i * _ssi[_aadv._strHeader->_akPerson].fontHeight),
+					              _ssr->_y + (i * h),
 					              0, 300, 0, _ssr->_strPtr[i]);
 					_G(out)->printxy(_ssr->_x[i],
-					              _ssr->_y + (i * _ssi[_aadv._strHeader->_akPerson].fontHeight) + 1,
+					              _ssr->_y + (i * h) + 1,
 					              0, 300, 0, _ssr->_strPtr[i]);
 					_G(out)->printxy(_ssr->_x[i],
-					              _ssr->_y + (i * _ssi[_aadv._strHeader->_akPerson].fontHeight) - 1,
+					              _ssr->_y + (i * h) - 1,
 					              0, 300, 0, _ssr->_strPtr[i]);
 					_G(out)->printxy(_ssr->_x[i],
-					              _ssr->_y + (i * _ssi[_aadv._strHeader->_akPerson].fontHeight),
-					              _aadv._person[_aadv._strHeader->_akPerson]._color,
+					              _ssr->_y + (i * h),
+					              _aadv._person[personId]._color,
 					              300, 0, _ssr->_strPtr[i]);
 					tmp_ptr += strlen(_ssr->_strPtr[i]) + 1;
 				}
@@ -967,8 +976,8 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
 					_atdsv._vocNr = _aadv._strHeader->_vocNr - ATDS_VOC_OFFSET;
 					g_engine->_sound->playSpeech(_atdsv._vocNr,
 						_atdsv._display == DISPLAY_VOC);
-					int16 vocx = _G(spieler_vector)[_aadv._strHeader->_akPerson].Xypos[0] -
-								 _G(gameState).scrollx + _G(spieler_mi)[_aadv._strHeader->_akPerson].HotX;
+					int16 vocx = _G(spieler_vector)[personId].Xypos[0] -
+								 _G(gameState).scrollx + _G(spieler_mi)[personId].HotX;
 					g_engine->_sound->setSoundChannelBalance(0, getStereoPos(vocx));
 
 					if (_atdsv._display == DISPLAY_VOC) {
@@ -992,7 +1001,7 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
 				if (tmp_ptr[1] == ATDS_END ||
 				        tmp_ptr[1] == ATDS_END_ENTRY) {
 					if (_atdsv.aad_str != 0)
-						_atdsv.aad_str(_atdsv._diaNr, _aadv._strNr, _aadv._strHeader->_akPerson, AAD_STR_END);
+						_atdsv.aad_str(_atdsv._diaNr, _aadv._strNr, personId, AAD_STR_END);
 					_aadv._dialog = false;
 					_adsv._autoDia = false;
 					_aadv._strNr = -1;
diff --git a/engines/chewy/atds.h b/engines/chewy/atds.h
index 806864921da..1a66011f51b 100644
--- a/engines/chewy/atds.h
+++ b/engines/chewy/atds.h
@@ -240,9 +240,6 @@ struct SplitStringInit {
 	int16 _width;
 	int16 _lines;
 	int16 _mode;
-
-	int16 fontWidth;
-	int16 fontHeight;
 };
 
 class Atdsys {
@@ -336,16 +333,16 @@ private:
 	SplitStringRet *_ssr = nullptr;
 
 	SplitStringInit _ssi[AAD_MAX_PERSON] = {
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
-		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
+		{ 0, 100, 0, 200, 4, SPLIT_CENTER },
 	};
 
 	char *_splitPtr[MAX_STR_SPLIT] = { nullptr };


Commit: e2f77bd64313aab4b1b9640b4e11a11a29819abc
    https://github.com/scummvm/scummvm/commit/e2f77bd64313aab4b1b9640b4e11a11a29819abc
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-04-02T12:22:14+03:00

Commit Message:
CHEWY: Refactor the speech and text display logic

Changed paths:
    engines/chewy/atds.cpp
    engines/chewy/atds.h
    engines/chewy/dialogs/options.cpp
    engines/chewy/inits.cpp
    engines/chewy/main.cpp
    engines/chewy/sound.cpp
    engines/chewy/sound.h
    engines/chewy/sprite.cpp


diff --git a/engines/chewy/atds.cpp b/engines/chewy/atds.cpp
index 5c937adb5f9..905f7d68b40 100644
--- a/engines/chewy/atds.cpp
+++ b/engines/chewy/atds.cpp
@@ -90,12 +90,9 @@ Atdsys::Atdsys() {
 	_adsv._autoDia = false;
 	_adsv._strNr = -1;
 	_adsv._silentCount = false;
-	_atsv._display = DISPLAY_NONE;
-	_atsv._silentCount = false;
-	_atdsv._delay = &_tmpDelay;
 	_tmpDelay = 1;
+	_atdsv._delay = &_tmpDelay;
 	_atdsv._silent = false;
-	_atdsv._display = DISPLAY_TXT;
 	_atdsv._diaNr = -1;
 	_atdsv.aad_str = nullptr;
 	_atdsv._vocNr = -1;
@@ -161,13 +158,6 @@ void Atdsys::set_string_end_func
 	_atdsv.aad_str = strFunc;
 }
 
-void Atdsys::updateSoundSettings() {
-	if (!g_engine->_sound->speechEnabled())
-		_atdsv._display = DISPLAY_TXT;
-	else
-		_atdsv._display = g_engine->_sound->getSpeechSubtitlesMode();
-}
-
 int16 Atdsys::get_delay(int16 txt_len) {
 	const int16 w = _G(fontMgr)->getFont()->getDataWidth();
 	int16 z_len = (_ssi->_width / w) + 1;
@@ -487,23 +477,20 @@ void Atdsys::set_ats_mem(int16 mode) {
 	}
 }
 
-DisplayMode Atdsys::start_ats(int16 txtNr, int16 txtMode, int16 color, int16 mode, int16 *vocNr) {
+bool Atdsys::start_ats(int16 txtNr, int16 txtMode, int16 color, int16 mode, int16 *vocNr) {
 	*vocNr = -1;
 	set_ats_mem(mode);
 
-	_atsv._display = DISPLAY_NONE;
+	_atsv.shown = false;
 
 	if (_atsMem) {
-		if (_atsv._display != DISPLAY_NONE)
-			stop_ats();
-
 		//const uint8 roomNum = _G(room)->_roomInfo->_roomNr;
 		int16 txt_anz;
 		_atsv._ptr = ats_get_txt(txtNr, txtMode, &txt_anz, mode);
 		//_atsv._ptr = (char *)getTextEntry(roomNum, txtNr, txtMode).c_str();
 
 		if (_atsv._ptr) {
-			_atsv._display = _atdsv._display;
+			_atsv.shown = g_engine->_sound->subtitlesEnabled();
 			char *ptr = _atsv._ptr;
 			_atsv._txtLen = 0;
 
@@ -514,8 +501,7 @@ DisplayMode Atdsys::start_ats(int16 txtNr, int16 txtMode, int16 color, int16 mod
 
 			if ((byte)*_atsv._ptr == 248) {
 				// Special code for no message to display
-				_atsv._display = (_atdsv._display == DISPLAY_TXT || *vocNr == -1) ?
-					DISPLAY_NONE : DISPLAY_VOC;
+				_atsv.shown = false;
 
 			} else {
 				_atsv._delayCount = get_delay(_atsv._txtLen);
@@ -524,26 +510,21 @@ DisplayMode Atdsys::start_ats(int16 txtNr, int16 txtMode, int16 color, int16 mod
 				_mousePush = true;
 
 				if (*vocNr == -1) {
-					_atsv._display = (_atdsv._display == DISPLAY_VOC) ?
-						DISPLAY_NONE : DISPLAY_TXT;
+					_atsv.shown = g_engine->_sound->subtitlesEnabled();
 				}
 			}
 		}
 	}
 
-	return _atsv._display;
+	return _atsv.shown;
 }
 
 void Atdsys::stop_ats() {
-	_atsv._display = DISPLAY_NONE;
-}
-
-DisplayMode &Atdsys::ats_get_status() {
-	return _atsv._display;
+	_atsv.shown = false;
 }
 
 void Atdsys::print_ats(int16 x, int16 y, int16 scrX, int16 scrY) {
-	if (_atsv._display == DISPLAY_TXT || _atsv._display == DISPLAY_ALL) {
+	if (_atsv.shown) {
 		if (_atdsv._eventsEnabled) {
 			switch (_G(in)->getSwitchCode()) {
 			case Common::KEYCODE_ESCAPE:
@@ -601,8 +582,7 @@ void Atdsys::print_ats(int16 x, int16 y, int16 scrX, int16 scrY) {
 			str_null2leer(start_ptr, start_ptr + _atsv._txtLen - 1);
 			if (_atsv._delayCount <= 0) {
 				if (_ssr->_next == false) {
-					_atsv._display = (_atsv._display == DISPLAY_ALL) ?
-						DISPLAY_VOC : DISPLAY_NONE;
+					_atsv.shown = false;
 				} else {
 					_atsv._ptr = tmp_ptr;
 					_atsv._txtLen = 0;
@@ -944,7 +924,7 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
 			SplitStringInit tmp_ssi = _ssi[personId];
 			_ssr = split_string(&tmp_ssi);
 
-			if (_atdsv._display != DISPLAY_VOC ||
+			if (g_engine->_sound->subtitlesEnabled() ||
 			        (_aadv._strHeader->_vocNr - ATDS_VOC_OFFSET) == -1) {
 				const int16 h = _G(fontMgr)->getFont()->getDataHeight();
 				for (int16 i = 0; i < _ssr->_nr; i++) {
@@ -970,28 +950,30 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
 
 			}
 
-			if (_atdsv._display != DISPLAY_TXT &&
+			if (g_engine->_sound->speechEnabled() &&
 					(_aadv._strHeader->_vocNr - ATDS_VOC_OFFSET) != -1) {
 				if (_atdsv._vocNr != _aadv._strHeader->_vocNr - ATDS_VOC_OFFSET) {
 					_atdsv._vocNr = _aadv._strHeader->_vocNr - ATDS_VOC_OFFSET;
-					g_engine->_sound->playSpeech(_atdsv._vocNr,
-						_atdsv._display == DISPLAY_VOC);
+					g_engine->_sound->playSpeech(_atdsv._vocNr, !g_engine->_sound->subtitlesEnabled());
 					int16 vocx = _G(spieler_vector)[personId].Xypos[0] -
 								 _G(gameState).scrollx + _G(spieler_mi)[personId].HotX;
 					g_engine->_sound->setSoundChannelBalance(0, getStereoPos(vocx));
 
-					if (_atdsv._display == DISPLAY_VOC) {
+					if (!g_engine->_sound->subtitlesEnabled()) {
 						_aadv._strNr = -1;
 						_aadv._delayCount = 1;
 					}
 				}
 
-				if (_atdsv._display != DISPLAY_ALL) {
-					for (int16 i = 0; i < _ssr->_nr; i++) {
-						tmp_ptr += strlen(_ssr->_strPtr[i]) + 1;
-					}
-					str_null2leer(start_ptr, start_ptr + txt_len - 1);
+				// FIXME: This breaks subtitles, as it removes
+				// all string terminators. This was previously
+				// used when either speech or subtitles (but not
+				// both) were selected, but its logic is broken.
+				// Check if it should be removed altogether.
+				/*for (int16 i = 0; i < _ssr->_nr; i++) {
+					tmp_ptr += strlen(_ssr->_strPtr[i]) + 1;
 				}
+				str_null2leer(start_ptr, start_ptr + txt_len - 1);*/
 			}
 
 			if (_aadv._delayCount <= 0) {
@@ -1011,8 +993,8 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
 						++_aadv._strNr;
 						while (*_aadv._ptr++ != ATDS_END_TEXT) {}
 
-						int16 tmp_person = _aadv._strHeader->_akPerson;
-						int16 tmp_str_nr = _aadv._strNr;
+						const int16 tmp_person = _aadv._strHeader->_akPerson;
+						const int16 tmp_str_nr = _aadv._strNr;
 						_aadv._strHeader = (AadStrHeader *)_aadv._ptr;
 						_aadv._ptr += sizeof(AadStrHeader);
 						if (_atdsv.aad_str != nullptr) {
@@ -1028,13 +1010,11 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
 					_aadv._silentCount = _atdsv._silent;
 				}
 			} else {
-				if (_atdsv._display != DISPLAY_VOC ||
+				if (g_engine->_sound->subtitlesEnabled() ||
 				        (_aadv._strHeader->_vocNr - ATDS_VOC_OFFSET) == -1)
 					--_aadv._delayCount;
 
-				else if (_atdsv._display == DISPLAY_VOC) {
-					warning("FIXME - unknown constant SMP_PLAYING");
-
+				else if (!g_engine->_sound->subtitlesEnabled()) {
 					_aadv._delayCount = 0;
 				}
 			}
diff --git a/engines/chewy/atds.h b/engines/chewy/atds.h
index 1a66011f51b..9a2c84a554b 100644
--- a/engines/chewy/atds.h
+++ b/engines/chewy/atds.h
@@ -48,13 +48,6 @@ namespace Chewy {
 #define INV_ATS_HANDLE 6
 #define ATDS_HANDLE 7
 
-enum DisplayMode {
-	DISPLAY_NONE = -1,
-	DISPLAY_TXT = 0,
-	DISPLAY_VOC = 1,
-	DISPLAY_ALL = 2
-};
-
 #define MAX_STR_SPLIT 10
 
 #define SPLIT_CENTER 1
@@ -104,7 +97,6 @@ struct AtdsVar {
 	int16 *_delay = nullptr;
 	int16 _diaNr = 0;
 
-	DisplayMode _display = DISPLAY_TXT;
 	bool _eventsEnabled = false;
 	int16 _vocNr = 0;
 
@@ -205,7 +197,6 @@ struct AtsTxtHeader {
 };
 
 struct AtsVar {
-	DisplayMode _display = DISPLAY_NONE;
 	AtsTxtHeader _txtHeader;
 	AtsStrHeader _strHeader;
 	char *_ptr;
@@ -214,6 +205,7 @@ struct AtsVar {
 	int16 _txtLen;
 	int16 _color;
 	int16 _txtMode;
+	bool shown;
 };
 
 struct SplitStringRet {
@@ -248,7 +240,6 @@ public:
 	~Atdsys();
 
 	void set_delay(int16 *delay, int16 silent);
-	void updateSoundSettings();
 	void set_split_win(int16 nr, int16 x, int16 y);
 	SplitStringRet *split_string(SplitStringInit *ssi);
 	void calc_txt_win(SplitStringInit *ssi);
@@ -261,9 +252,9 @@ public:
 	void open_handle(const char *fname, int16 mode);
 	void close_handle(int16 mode);
 	void crypt(char *txt, uint32 size);
-	DisplayMode start_ats(int16 txtNr, int16 txtMode, int16 color, int16 mode, int16 *vocNr);
+	bool start_ats(int16 txtNr, int16 txtMode, int16 color, int16 mode, int16 *vocNr);
 	void stop_ats();
-	DisplayMode &ats_get_status();
+	bool atsShown() { return _atsv.shown; }
 	void print_ats(int16 x, int16 y, int16 scrX, int16 scrY);
 	int16 getControlBit(int16 txtNr, int16 bitIdx);
 	void setControlBit(int16 txtNr, int16 bitIdx);
@@ -300,9 +291,6 @@ public:
 	void enableEvents(bool nr) {
 		_atdsv._eventsEnabled = nr;
 	}
-	int getAtdDisplay() const {
-		return _atdsv._display;	
-	}
 
 	void saveAtdsStream(Common::WriteStream *stream);
 	void loadAtdsStream(Common::SeekableReadStream *stream);
diff --git a/engines/chewy/dialogs/options.cpp b/engines/chewy/dialogs/options.cpp
index 6801c6ecbc9..e617df7b2ea 100644
--- a/engines/chewy/dialogs/options.cpp
+++ b/engines/chewy/dialogs/options.cpp
@@ -178,8 +178,6 @@ void Options::execute(TafInfo *ti) {
 					g_engine->_sound->toggleSubtitles(true);
 					g_engine->_sound->toggleSpeech(false);
 				}
-
-				_G(atds)->updateSoundSettings();
 				break;
 			case 5:
 				if (g_engine->_sound->musicEnabled()) {
diff --git a/engines/chewy/inits.cpp b/engines/chewy/inits.cpp
index a866900648b..8869e7505e0 100644
--- a/engines/chewy/inits.cpp
+++ b/engines/chewy/inits.cpp
@@ -284,7 +284,6 @@ void sound_init() {
 	_G(gameState).SoundVol = 63;
 	g_engine->_sound->setMusicVolume(_G(gameState).MusicVol * Audio::Mixer::kMaxChannelVolume / 120);
 	g_engine->_sound->setSoundVolume(_G(gameState).SoundVol * Audio::Mixer::kMaxChannelVolume / 120);
-	_G(atds)->updateSoundSettings();
 }
 
 void show_intro() {
diff --git a/engines/chewy/main.cpp b/engines/chewy/main.cpp
index 16413240f9b..4f5e1f9e81a 100644
--- a/engines/chewy/main.cpp
+++ b/engines/chewy/main.cpp
@@ -1918,7 +1918,7 @@ void set_person_rnr() {
 
 bool is_chewy_busy() {
 	bool ret = true;
-	if (_G(atds)->ats_get_status() == DISPLAY_NONE) {
+	if (!_G(atds)->atsShown()) {
 		if (_G(atds)->aadGetStatus() == -1) {
 			if (_G(atds)->ads_get_status() == -1) {
 				if (!_G(mov)->auto_go_status()) {
diff --git a/engines/chewy/sound.cpp b/engines/chewy/sound.cpp
index b47a4303a7f..bfc6e174634 100644
--- a/engines/chewy/sound.cpp
+++ b/engines/chewy/sound.cpp
@@ -291,15 +291,6 @@ void Sound::waitForSpeechToFinish() {
 	}
 }
 
-DisplayMode Sound::getSpeechSubtitlesMode() const {
-	if (!ConfMan.getBool("subtitles"))
-		return DISPLAY_VOC;
-	else if (!ConfMan.getBool("speech_mute"))
-		return DISPLAY_ALL;
-	else
-		return DISPLAY_TXT;
-}
-
 bool Sound::soundEnabled() const {
 	return !ConfMan.getBool("sfx_mute");
 }
@@ -325,11 +316,11 @@ void Sound::toggleSpeech(bool enable) {
 }
 
 bool Sound::subtitlesEnabled() const {
-	return !ConfMan.getBool("subtitles");
+	return ConfMan.getBool("subtitles");
 }
 
 void Sound::toggleSubtitles(bool enable) {
-	return ConfMan.setBool("subtitles", !enable);
+	return ConfMan.setBool("subtitles", enable);
 }
 
 } // namespace Chewy
diff --git a/engines/chewy/sound.h b/engines/chewy/sound.h
index bafc50329cd..4bfccbf83e3 100644
--- a/engines/chewy/sound.h
+++ b/engines/chewy/sound.h
@@ -70,11 +70,6 @@ public:
 	 */
 	void waitForSpeechToFinish();
 
-	/**
-	 * Returns the speech, subtitles mode from the ScummVM config
-	 */
-	DisplayMode getSpeechSubtitlesMode() const;
-
 	bool soundEnabled() const;
 	void toggleSound(bool enable);
 
diff --git a/engines/chewy/sprite.cpp b/engines/chewy/sprite.cpp
index 6d1a0c17475..c6875e3b4c7 100644
--- a/engines/chewy/sprite.cpp
+++ b/engines/chewy/sprite.cpp
@@ -484,7 +484,7 @@ void start_aad(int16 diaNr) {
 }
 
 bool startAtsWait(int16 txtNr, int16 txtMode, int16 col, int16 mode) {
-	DisplayMode ret = DISPLAY_NONE;
+	bool shown = false;
 
 	const int16 oldMouseLeftClick = _G(mouseLeftClick);
 	_G(mouseLeftClick) = false;
@@ -497,28 +497,23 @@ bool startAtsWait(int16 txtNr, int16 txtMode, int16 col, int16 mode) {
 				atdsStringStart(30000, 0, 0, AAD_STR_START);
 
 			int16 VocNr;
-			ret = _G(atds)->start_ats(txtNr, txtMode, col, mode, &VocNr);
+			shown = _G(atds)->start_ats(txtNr, txtMode, col, mode, &VocNr);
 
-			if (ret == DISPLAY_VOC || ret == DISPLAY_ALL) {
-				int16 vocx = _G(spieler_vector)[P_CHEWY].Xypos[0] - _G(gameState).scrollx + _G(spieler_mi)[P_CHEWY].HotX;
+			if (shown && g_engine->_sound->speechEnabled())  {
+				const int16 vocx = _G(spieler_vector)[P_CHEWY].Xypos[0] - _G(gameState).scrollx + _G(spieler_mi)[P_CHEWY].HotX;
 
 				g_engine->_sound->setSoundChannelBalance(0, _G(atds)->getStereoPos(vocx));
 				if (VocNr >= 0) {
-					g_engine->_sound->playSpeech(VocNr,
-						_G(atds)->getAtdDisplay() == DISPLAY_VOC);
-					//warning("FIXME - unknown constant SMP_PLAYING");
+					g_engine->_sound->playSpeech(VocNr, !g_engine->_sound->subtitlesEnabled());
 				}
 
 				setupScreen(DO_SETUP);
 			}
 
-			if (ret != DISPLAY_NONE) {
- 				DisplayMode &dMode = _G(atds)->ats_get_status();
-				while (!SHOULD_QUIT && dMode != DISPLAY_NONE) {
-					if (dMode != DISPLAY_TXT && !g_engine->_sound->isSpeechActive()) {
-						dMode = (dMode == DISPLAY_ALL) ?
-							DISPLAY_TXT : DISPLAY_NONE;
-					}
+			if (shown) {
+				while (!SHOULD_QUIT && _G(atds)->atsShown()) {
+					if (g_engine->_sound->speechEnabled() && !g_engine->_sound->isSpeechActive())
+						_G(atds)->stop_ats();
 
 					if (_G(minfo)._button)
 						g_engine->_sound->stopSpeech();
@@ -540,7 +535,7 @@ bool startAtsWait(int16 txtNr, int16 txtMode, int16 col, int16 mode) {
 	g_events->_kbInfo._scanCode = Common::KEYCODE_INVALID;
 	_G(mouseLeftClick) = oldMouseLeftClick;
 
-	return ret != DISPLAY_NONE;
+	return shown;
 }
 
 void aadWait(int16 strNr) {




More information about the Scummvm-git-logs mailing list