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

bluegr noreply at scummvm.org
Mon Jun 20 14:43:44 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:
6712b35d42 CHEWY: Use the ScummVM volume - bug #13595
cb64a46030 CHEWY: Slight cleanup of the barrier code


Commit: 6712b35d420cded75ec858b2364b424fd5c92bd5
    https://github.com/scummvm/scummvm/commit/6712b35d420cded75ec858b2364b424fd5c92bd5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-06-20T12:45:19+03:00

Commit Message:
CHEWY: Use the ScummVM volume - bug #13595

This avoids having the volume reset on game startup. Also, volume is
no longer stored in saved games

Changed paths:
    engines/chewy/dialogs/main_menu.cpp
    engines/chewy/dialogs/options.cpp
    engines/chewy/globals.h
    engines/chewy/inits.cpp
    engines/chewy/r_event.cpp
    engines/chewy/sound.cpp
    engines/chewy/sound.h
    engines/chewy/types.cpp
    engines/chewy/types.h
    engines/chewy/video/video_player.cpp


diff --git a/engines/chewy/dialogs/main_menu.cpp b/engines/chewy/dialogs/main_menu.cpp
index f5afa53af6c..3c3b7b6da45 100644
--- a/engines/chewy/dialogs/main_menu.cpp
+++ b/engines/chewy/dialogs/main_menu.cpp
@@ -173,15 +173,11 @@ void MainMenu::startGame() {
 	animate();
 	exit_room(-1);
 
-	uint8 soundVol = _G(gameState).SoundVol;
-	uint8 musicVol = _G(gameState).MusicVol;
 	uint8 framesPerSecond = _G(gameState).FramesPerSecond;
 	int sndLoopMode = _G(gameState).soundLoopMode;
 
 	var_init();
 
-	_G(gameState).SoundVol = soundVol;
-	_G(gameState).MusicVol = musicVol;
 	_G(gameState).FramesPerSecond = framesPerSecond;
 	_G(gameState).soundLoopMode = sndLoopMode;
 
diff --git a/engines/chewy/dialogs/options.cpp b/engines/chewy/dialogs/options.cpp
index e93f490d87d..3032118089a 100644
--- a/engines/chewy/dialogs/options.cpp
+++ b/engines/chewy/dialogs/options.cpp
@@ -65,17 +65,17 @@ void Options::execute(TafInfo *ti) {
 	int16 tdisp_count = tdisp_delay;
 	_G(FrameSpeed) = 0;
 	int16 delay_count = _G(gameState).DelaySpeed;
-	warning("stop_clock = (clock() / CLK_TCK) + 1;");
+	//warning("stop_clock = (clock() / CLK_TCK) + 1;");
 	while (key != Common::KEYCODE_ESCAPE) {
 		_G(out)->map_spr2screen(_G(ablage)[_G(room_blk).AkAblage], 0, 0);
 		++_G(FrameSpeed);
-		warning("akt_clock = clock() / CLK_TCK;");
+		//warning("akt_clock = clock() / CLK_TCK;");
 		if (akt_clock >= stop_clock) {
 			//TmpFrame = _G(FrameSpeed);
 			_G(gameState).DelaySpeed = (_G(FrameSpeed) >> 1) / _G(gameState).FramesPerSecond;
 
 			_G(FrameSpeed) = 0;
-			warning("stop_clock = (clock() / CLK_TCK) + 1;");
+			//warning("stop_clock = (clock() / CLK_TCK) + 1;");
 		}
 
 		_G(out)->spriteSet(ti->image[surimy_ani], 18 + ti->correction[surimy_ani << 1],
@@ -100,13 +100,16 @@ void Options::execute(TafInfo *ti) {
 				18 + ti->correction[SCHNULL_BAND << 1],
 				8 + ti->correction[(SCHNULL_BAND << 1) + 1], 0);
 		}
+
+		const int soundVolume = g_engine->_sound->getSoundVolume() * Audio::Mixer::kMaxChannelVolume / 2 * 120;
 		_G(out)->pop_box(32 - 2, 104 - 12, 42 + 4, 136 + 2, 192, 183, 182);
 		_G(out)->printxy(32 + 3, 104 - 10, 15, 300, 0, "S");
-		_G(out)->boxFill(33, 136 - (_G(gameState).SoundVol >> 1), 42, 136, 15);
+		_G(out)->boxFill(33, 136 - (soundVolume >> 1), 42, 136, 15);
 
+		const int musicVolume = g_engine->_sound->getSoundVolume() * Audio::Mixer::kMaxChannelVolume / 2 * 120;
 		_G(out)->pop_box(52 - 2, 104 - 12, 62 + 4, 136 + 2, 192, 183, 182);
 		_G(out)->printxy(52 + 3, 104 - 10, 31, 300, 0, "M");
-		_G(out)->boxFill(53, 136 - (_G(gameState).MusicVol >> 1), 62, 136, 31);
+		_G(out)->boxFill(53, 136 - (musicVolume >> 1), 62, 136, 31);
 		if (g_engine->_sound->musicEnabled()) {
 			_G(out)->spriteSet(ti->image[MUSIC_ON1],
 				18 + ti->correction[MUSIC_ON1 << 1],
@@ -181,12 +184,10 @@ void Options::execute(TafInfo *ti) {
 				key = Common::KEYCODE_ESCAPE;
 				break;
 			case 7:
-				_G(gameState).SoundVol = (136 - g_events->_mousePos.y) << 1;
-				g_engine->_sound->setSoundVolume(_G(gameState).SoundVol * Audio::Mixer::kMaxChannelVolume / 120);
+				g_engine->_sound->setSoundVolume(((136 - g_events->_mousePos.y) << 1) * Audio::Mixer::kMaxChannelVolume / 120);
 				break;
 			case 8:
-				_G(gameState).MusicVol = (136 - g_events->_mousePos.y) << 1;
-				g_engine->_sound->setMusicVolume(_G(gameState).MusicVol * Audio::Mixer::kMaxChannelVolume / 120);
+				g_engine->_sound->setMusicVolume(((136 - g_events->_mousePos.y) << 1) * Audio::Mixer::kMaxChannelVolume / 120);
 				break;
 
 			default:
diff --git a/engines/chewy/globals.h b/engines/chewy/globals.h
index ad5bdc5822a..02d23cb408d 100644
--- a/engines/chewy/globals.h
+++ b/engines/chewy/globals.h
@@ -389,7 +389,6 @@ void init_load();
 void var_init();
 
 void new_game();
-void sound_init();
 void show_intro();
 void register_cutscene(int cutsceneNum);
 void getCutscenes(Common::Array<int> &cutscenes);
diff --git a/engines/chewy/inits.cpp b/engines/chewy/inits.cpp
index ee85087db71..a628f935bfd 100644
--- a/engines/chewy/inits.cpp
+++ b/engines/chewy/inits.cpp
@@ -79,7 +79,6 @@ void standard_init() {
 	_G(out)->cls();
 	_G(uhr)->setNewTimer(0, 5, SEC_10_MODE);
 
-	sound_init();
 	init_load();
 }
 
@@ -249,13 +248,6 @@ void tidy() {
 	_G(mem) = nullptr;
 }
 
-void sound_init() {
-	_G(gameState).MusicVol = 63;
-	_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);
-}
-
 void show_intro() {
 	if (!ConfMan.getBool("shown_intro")) {
 		ConfMan.setBool("shown_intro", true);
diff --git a/engines/chewy/r_event.cpp b/engines/chewy/r_event.cpp
index 79cff1160da..2058cac70a2 100644
--- a/engines/chewy/r_event.cpp
+++ b/engines/chewy/r_event.cpp
@@ -789,8 +789,6 @@ void flic_cut(int16 nr) {
 	SHOULD_QUIT_RETURN;
 
 	g_events->delay(50);
-	g_engine->_sound->setSoundVolume(_G(gameState).SoundVol * Audio::Mixer::kMaxChannelVolume / 120);
-	g_engine->_sound->setMusicVolume(_G(gameState).MusicVol * Audio::Mixer::kMaxChannelVolume / 120);
 
 	if (nr != FCUT_135) {
 		g_engine->_sound->playRoomMusic(_G(gameState)._personRoomNr[0]);
diff --git a/engines/chewy/sound.cpp b/engines/chewy/sound.cpp
index e8bf3d29cf0..c2c3da0262b 100644
--- a/engines/chewy/sound.cpp
+++ b/engines/chewy/sound.cpp
@@ -35,24 +35,6 @@
 
 namespace Chewy {
 
-const uint8 Sound::TMF_MOD_SONG_NAME[] = {
-	'S', 'C', 'U', 'M', 'M',
-	'V', 'M', ' ', 'M', 'O',
-	'D', 'U', 'L', 'E', '\0',
-	'\0', '\0', '\0', '\0', '\0'};
-const uint8 Sound::TMF_MOD_INSTRUMENT_NAME[] = {
-	'S', 'C', 'U', 'M', 'M',
-	'V', 'M', ' ', 'I', 'N',
-	'S', 'T', 'R', 'U', 'M',
-	'E', 'N', 'T', '\0', '\0',
-	'\0', '\0'};
-// TODO Verify period values used by the game; this is an educated guess.
-const uint16 Sound::TMF_MOD_PERIODS[] = {
-	856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453,
-	428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226,
-	214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113
-};
-
 Sound::Sound(Audio::Mixer *mixer) {
 	_mixer = mixer;
 	_speechRes = new SoundResource("speech.tvp");
@@ -114,6 +96,24 @@ bool Sound::isSoundActive(uint channel) const {
 
 void Sound::setSoundVolume(uint volume) {
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume);
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume);
+}
+
+int Sound::getSoundVolume() const {
+	return _mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType);
+}
+
+void Sound::pushVolume() {
+	_soundVolume = _mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType);
+	_speechVolume = _mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType);
+	_musicVolume = _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType);
+}
+
+void Sound::popVolume() {
+	assert(_soundVolume >= 0 && _speechVolume >= 0 && _musicVolume >= 0);
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _soundVolume);
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _speechVolume);
+	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _musicVolume);
 }
 
 void Sound::setSoundChannelVolume(uint channel, uint volume) {
@@ -165,6 +165,10 @@ void Sound::setMusicVolume(uint volume) {
 	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
 }
 
+int Sound::getMusicVolume() const {
+	return _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType);
+}
+
 void Sound::playSpeech(int num, bool waitForFinish) {
 	if (isSpeechActive())
 		stopSpeech();
@@ -210,10 +214,6 @@ bool Sound::isSpeechActive() const {
 	return _mixer->isSoundHandleActive(_speechHandle);
 }
 
-void Sound::setSpeechVolume(uint volume) {
-	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume);
-}
-
 void Sound::stopAll() {
 	_mixer->stopAll();
 }
diff --git a/engines/chewy/sound.h b/engines/chewy/sound.h
index 09c0d5e5b05..e20be085fbb 100644
--- a/engines/chewy/sound.h
+++ b/engines/chewy/sound.h
@@ -51,8 +51,11 @@ public:
 	void stopAllSounds();
 	bool isSoundActive(uint channel) const;
 	void setSoundVolume(uint volume);
+	int getSoundVolume() const;
 	void setSoundChannelVolume(uint channel, uint volume);
 	void setSoundChannelBalance(uint channel, int8 balance);
+	void pushVolume();
+	void popVolume();
 
 	void playMusic(int16 num, bool loop = false);
 	void playMusic(uint8 *data, uint32 size);
@@ -61,6 +64,7 @@ public:
 	void stopMusic();
 	bool isMusicActive() const;
 	void setMusicVolume(uint volume);
+	int getMusicVolume() const;
 	void playRoomMusic(int16 roomNum);
 
 	void playSpeech(int num, bool waitForFinish);
@@ -68,7 +72,6 @@ public:
 	void resumeSpeech();
 	void stopSpeech();
 	bool isSpeechActive() const;
-	void setSpeechVolume(uint volume);
 
 	void stopAll();
 
@@ -95,6 +98,7 @@ private:
 	Audio::SoundHandle _musicHandle;
 	Audio::SoundHandle _speechHandle;
 	int16 _curMusic = -1;
+	int _soundVolume = -1, _speechVolume = -1, _musicVolume = -1;
 
 	SoundResource *_speechRes;
 	SoundResource *_soundRes;
diff --git a/engines/chewy/types.cpp b/engines/chewy/types.cpp
index a45948dbe84..7ad2072907f 100644
--- a/engines/chewy/types.cpp
+++ b/engines/chewy/types.cpp
@@ -150,9 +150,9 @@ bool GameState::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(SVal4);
 	s.syncAsSint16LE(soundLoopMode);
 	s.syncAsByte(dummy);	// sound switch
-	s.syncAsByte(SoundVol);
+	s.syncAsByte(dummy);	// sound volume
 	s.syncAsByte(dummy);	// music switch
-	s.syncAsByte(MusicVol);
+	s.syncAsByte(dummy);	// music volume
 	s.syncAsByte(dummy);	// speech switch
 	s.syncAsByte(FramesPerSecond);
 	s.syncAsByte(dummy);	// subtitles switch
diff --git a/engines/chewy/types.h b/engines/chewy/types.h
index 0d1316cd89c..d01a9018891 100644
--- a/engines/chewy/types.h
+++ b/engines/chewy/types.h
@@ -517,8 +517,6 @@ struct GameState : public GameFlags {
 	int16 SVal3 = 0;
 	int16 SVal4 = 0;
 	int16 soundLoopMode = 0;
-	uint8 SoundVol = 0;
-	uint8 MusicVol = 0;
 	uint8 FramesPerSecond = 0;
 };
 
diff --git a/engines/chewy/video/video_player.cpp b/engines/chewy/video/video_player.cpp
index d41a838f574..3043ac09c6f 100644
--- a/engines/chewy/video/video_player.cpp
+++ b/engines/chewy/video/video_player.cpp
@@ -36,6 +36,7 @@ bool VideoPlayer::playVideo(uint num, bool stopMusic) {
 	CfoDecoder *cfoDecoder = new CfoDecoder(g_engine->_sound);
 	VideoResource *videoResource = new VideoResource("cut.tap");
 	Common::SeekableReadStream *videoStream = videoResource->getVideoStream(num);
+	g_engine->_sound->pushVolume();
 	_playCount = 0;
 
 	if (stopMusic) {
@@ -101,6 +102,7 @@ bool VideoPlayer::playVideo(uint num, bool stopMusic) {
 
 	g_system->getPaletteManager()->setPalette(curPalette, 0, 256);
 	_G(cur)->show_cur();
+	g_engine->_sound->popVolume();
 
 	delete videoResource;
 	delete cfoDecoder;


Commit: cb64a460307066d5012228d98beeab7dc4c5d48d
    https://github.com/scummvm/scummvm/commit/cb64a460307066d5012228d98beeab7dc4c5d48d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-06-20T12:46:16+03:00

Commit Message:
CHEWY: Slight cleanup of the barrier code

Changed paths:
    engines/chewy/barriers.cpp


diff --git a/engines/chewy/barriers.cpp b/engines/chewy/barriers.cpp
index 3c46b269067..b0de07ac758 100644
--- a/engines/chewy/barriers.cpp
+++ b/engines/chewy/barriers.cpp
@@ -42,53 +42,51 @@ int16 Barriers::getBarrierId(int16 g_idx, const byte *buffer) {
 		switch (_G(gameState)._personRoomNr[P_CHEWY]) {
 		case 8:
 			if (_G(gameState).R8GTuer)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 9:
 			if (!_G(gameState).R9Gitter)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 16:
 			if (!_G(gameState).R16F5Exit)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 17:
 			if (_G(gameState).R17Location != 1)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 21:
 			if (!_G(gameState).R21Laser2Weg)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 31:
 			if (!_G(gameState).R31KlappeZu)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 41:
 			if (!_G(gameState).R41LolaOk)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 52:
 			if (!_G(gameState).R52LichtAn)
-				idx_nr = 2;
+				return 2;
 			else
-				idx_nr = 4;
+				return 4;
 			break;
 
 		case 71:
-			idx_nr = _G(gameState).R71LeopardVined ? 1 : 0;
-			break;
+			return _G(gameState).R71LeopardVined ? 1 : 0;
 
 		case 76:
-			idx_nr = _G(gameState).flags29_4 ? 4 : 0;
-			break;
+			return _G(gameState).flags29_4 ? 4 : 0;
 
 		case 84:
 			if (!_G(gameState).R88UsedMonkey)
@@ -97,17 +95,17 @@ int16 Barriers::getBarrierId(int16 g_idx, const byte *buffer) {
 
 		case 86:
 			if (!_G(gameState).flags32_2)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 94:
 			if (!_G(gameState).flags35_10)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 97:
 			if (_G(gameState).flags35_80)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		default:
@@ -119,31 +117,30 @@ int16 Barriers::getBarrierId(int16 g_idx, const byte *buffer) {
 		switch (_G(gameState)._personRoomNr[P_CHEWY]) {
 		case 17:
 			if (_G(gameState).R17Location != 2)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 21:
-			if (!_G(gameState).R21Laser1Weg) {
-				idx_nr = 0;
-			} else
-				idx_nr = 3;
-			break;
+			if (!_G(gameState).R21Laser1Weg)
+				return 0;
+			else
+				return 3;
 
 		case 37:
 			if (!_G(gameState).R37Kloppe)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		case 52:
 			if (!_G(gameState).R52TuerAuf)
-				idx_nr = 2;
+				return 2;
 			else
-				idx_nr = 4;
+				return 4;
 			break;
 
 		case 97:
 			if (_G(gameState).flags36_20)
-				idx_nr = 0;
+				return 0;
 			break;
 
 		default:
@@ -152,10 +149,8 @@ int16 Barriers::getBarrierId(int16 g_idx, const byte *buffer) {
 		break;
 
 	case 42:
-		if (_G(gameState)._personRoomNr[P_CHEWY] == 97) {
-			if (!_G(gameState).flags37_1)
-				idx_nr = 0;
-		}
+		if (_G(gameState)._personRoomNr[P_CHEWY] == 97 && !_G(gameState).flags37_1)
+			return 0;
 		break;
 
 	default:




More information about the Scummvm-git-logs mailing list