From ca84b2737f6bd1c6c971d5ff7451cfb164afadb8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Sep 2012 21:43:33 +1000 Subject: HOPKINS: Add object loading --- engines/hopkins/sound.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 engines/hopkins/sound.cpp (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp new file mode 100644 index 0000000000..f11bc25cae --- /dev/null +++ b/engines/hopkins/sound.cpp @@ -0,0 +1,32 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/system.h" +#include "hopkins/sound.h" + +namespace Hopkins { + +void SoundManager::WSOUND_INIT() { + // TODO: WSOUND_INIT +} + +} // End of namespace Hopkins -- cgit v1.2.3 From f1fce64994e687aada097f6293776108bdedcd68 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Sep 2012 10:27:15 +1000 Subject: HOPKINS: Initial implementation of main animation player method --- engines/hopkins/sound.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index f11bc25cae..15e8e3b61b 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -25,8 +25,24 @@ namespace Hopkins { +void SoundManager::setParent(HopkinsEngine *vm) { + _vm = vm; +} + void SoundManager::WSOUND_INIT() { // TODO: WSOUND_INIT } +void SoundManager::VERIF_SOUND() { + +} + +void SoundManager::LOAD_ANM_SOUND() { + +} + +void SoundManager::PLAY_ANM_SOUND(int soundNumber) { + +} + } // End of namespace Hopkins -- cgit v1.2.3 From d007e0aafe7932899cdf87d6007bf10ebed1cad6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Sep 2012 13:23:46 +1000 Subject: HOPKINS: initial implementation of INTORUN method --- engines/hopkins/sound.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 15e8e3b61b..f38deb408b 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -21,28 +21,38 @@ */ #include "common/system.h" +#include "common/textconsole.h" #include "hopkins/sound.h" namespace Hopkins { void SoundManager::setParent(HopkinsEngine *vm) { _vm = vm; + SPECIAL_SOUND = 0; } void SoundManager::WSOUND_INIT() { - // TODO: WSOUND_INIT + warning("TODO: WSOUND_INIT"); } void SoundManager::VERIF_SOUND() { - + warning("TODO: VERIF_SOUND"); } void SoundManager::LOAD_ANM_SOUND() { - + warning("TODO: LOAD_ANIM_SOUND"); } void SoundManager::PLAY_ANM_SOUND(int soundNumber) { + warning("TODO: PLAAY_ANIM_SOUND"); +} + +void SoundManager::WSOUND(int soundNumber) { + warning("TODO: WSOUND"); +} +void SoundManager::VOICE_MIX(int a1, int a2) { + warning("TODO: VOICE_MIX"); } } // End of namespace Hopkins -- cgit v1.2.3 From 0b610c45dff6b715f1f5e3e5161619dc57d19061 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 17 Sep 2012 16:53:21 +1000 Subject: HOPKINS: Implemented rest of main method, with stubs for sub-method calls --- engines/hopkins/sound.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index f38deb408b..219797b190 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -55,4 +55,8 @@ void SoundManager::VOICE_MIX(int a1, int a2) { warning("TODO: VOICE_MIX"); } +void SoundManager::DEL_SAMPLE(int soundNumber) { + warning("TODO: DEL_SAMPLE"); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 1597aff3c7e39fd7c6b0acf6ae4d2a9cffbef460 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Sep 2012 19:54:30 +1000 Subject: HOPKINS: Clean up of moving Txt array from Globals to FontManager --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 219797b190..ea19b8fba7 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -36,7 +36,7 @@ void SoundManager::WSOUND_INIT() { } void SoundManager::VERIF_SOUND() { - warning("TODO: VERIF_SOUND"); +// warning("TODO: VERIF_SOUND"); } void SoundManager::LOAD_ANM_SOUND() { -- cgit v1.2.3 From 01bcd87ba43482ef5e773fc6abdf3cb0e918bbe5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Sep 2012 10:59:52 +1000 Subject: HOPKINS: Initial implementation of CHOICE_OPTION and AFF_SPRITES --- engines/hopkins/sound.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index ea19b8fba7..14576da7f1 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -59,4 +59,21 @@ void SoundManager::DEL_SAMPLE(int soundNumber) { warning("TODO: DEL_SAMPLE"); } +void SoundManager::PLAY_SOUND(const Common::String &file) { + warning("TODO: PLAY_SOUND"); +} + +void SoundManager::MODSetSampleVolume() { + warning("TODO MODSetSampleVolume"); +} + +void SoundManager::MODSetVoiceVolume() { + warning("TODO MODSetVoiceVolume"); +} + +void SoundManager::MODSetMusicVolume(int volume) { + warning("TODO MODSetMusicVolume"); +} + + } // End of namespace Hopkins -- cgit v1.2.3 From 221050f39f677bcbc1396d7e24d70a3e8ed98a75 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Sep 2012 23:05:09 +1000 Subject: HOPKINS: Implemented more talk manager methods --- engines/hopkins/sound.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 14576da7f1..813eb26933 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -51,8 +51,9 @@ void SoundManager::WSOUND(int soundNumber) { warning("TODO: WSOUND"); } -void SoundManager::VOICE_MIX(int a1, int a2) { +bool SoundManager::VOICE_MIX(int a1, int a2) { warning("TODO: VOICE_MIX"); + return false; } void SoundManager::DEL_SAMPLE(int soundNumber) { -- cgit v1.2.3 From 8fa33e7714fca1aeb80834ee5d97bcfdf8a3efb1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Sep 2012 21:02:39 +1000 Subject: HOPKINS: Implemented more object manager methods --- engines/hopkins/sound.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 813eb26933..b138ee36ba 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -43,6 +43,10 @@ void SoundManager::LOAD_ANM_SOUND() { warning("TODO: LOAD_ANIM_SOUND"); } +void SoundManager::LOAD_WAV(const Common::String &file, int a2) { + warning("TODO: LOAD_WAV"); +} + void SoundManager::PLAY_ANM_SOUND(int soundNumber) { warning("TODO: PLAAY_ANIM_SOUND"); } @@ -64,6 +68,10 @@ void SoundManager::PLAY_SOUND(const Common::String &file) { warning("TODO: PLAY_SOUND"); } +void SoundManager::PLAY_SOUND2(const Common::String &file) { + warning("TODO: PLAY_SOUND2"); +} + void SoundManager::MODSetSampleVolume() { warning("TODO MODSetSampleVolume"); } @@ -76,5 +84,24 @@ void SoundManager::MODSetMusicVolume(int volume) { warning("TODO MODSetMusicVolume"); } +void SoundManager::CHARGE_SAMPLE(int a1, const Common::String &file) { + warning("TODO: CHARGE_SAMPLE"); +} + +void SoundManager::PLAY_SAMPLE2(int idx) { + warning("PLAY_SAMPLE2"); +} + +void SoundManager::PLAY_SEQ(int a1, const Common::String &a2, int a3, int a4, int a5) { + warning("PLAY_SEQ"); +} + +void SoundManager::PLAY_SEQ2(const Common::String &a1, int a2, int a3, int a4) { + warning("PLAY_SEQ2"); +} + +void SoundManager::PLAY_WAV(int a1) { + warning("PLAY_WAV"); +} } // End of namespace Hopkins -- cgit v1.2.3 From 86bf409540a6a7767bd57f51c134bf1ff21ae1ab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 5 Oct 2012 08:09:09 +1000 Subject: HOPKINS: Implemented sequence player --- engines/hopkins/sound.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index b138ee36ba..9b58f42d18 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -92,14 +92,6 @@ void SoundManager::PLAY_SAMPLE2(int idx) { warning("PLAY_SAMPLE2"); } -void SoundManager::PLAY_SEQ(int a1, const Common::String &a2, int a3, int a4, int a5) { - warning("PLAY_SEQ"); -} - -void SoundManager::PLAY_SEQ2(const Common::String &a1, int a2, int a3, int a4) { - warning("PLAY_SEQ2"); -} - void SoundManager::PLAY_WAV(int a1) { warning("PLAY_WAV"); } -- cgit v1.2.3 From 2bf5306353081ffaeba085e95cada37b8ecdfcb3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 23 Oct 2012 20:49:22 +1100 Subject: HOPKINS: fix SoundManager initialisation and some references --- engines/hopkins/sound.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 9b58f42d18..b81cc63191 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -26,6 +26,21 @@ namespace Hopkins { +SoundManager::SoundManager() { + SPECIAL_SOUND; + SOUNDVOL = 0; + VOICEVOL = 0; + MUSICVOL = 0; + OLD_SOUNDVOL = 0; + OLD_MUSICVOL = 0; + OLD_VOICEVOL = 0; + SOUNDOFF = true; + MUSICOFF = true; + VOICEOFF = true; + TEXTOFF = false; + SOUND_FLAG = false; +} + void SoundManager::setParent(HopkinsEngine *vm) { _vm = vm; SPECIAL_SOUND = 0; -- cgit v1.2.3 From ff1659ec7e2e38063179f0703e653ae979452be9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 25 Oct 2012 08:08:00 +1100 Subject: HOPKINS: Fix missing assignment in sound manager initialisation --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index b81cc63191..42eb98ec63 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -27,7 +27,7 @@ namespace Hopkins { SoundManager::SoundManager() { - SPECIAL_SOUND; + SPECIAL_SOUND = 0; SOUNDVOL = 0; VOICEVOL = 0; MUSICVOL = 0; -- cgit v1.2.3 From 11d73dfc8d383e1fe8084aafdcb5a5be83de09cb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 10 Nov 2012 23:32:06 +1100 Subject: HOPKINS: Beginnings of implementation of sound code --- engines/hopkins/sound.cpp | 249 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 245 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 42eb98ec63..e43f66fd4a 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -21,8 +21,11 @@ */ #include "common/system.h" +#include "common/file.h" #include "common/textconsole.h" #include "hopkins/sound.h" +#include "hopkins/globals.h" +#include "hopkins/hopkins.h" namespace Hopkins { @@ -39,6 +42,15 @@ SoundManager::SoundManager() { VOICEOFF = true; TEXTOFF = false; SOUND_FLAG = false; + VBL_MERDE = false; + CARD_SB = false; + + for (int i = 0; i < VOICE_COUNT; ++i) + Common::fill((byte *)&Voice[i], (byte *)&Voice[i] + sizeof(VoiceItem), 0); + for (int i = 0; i < SWAV_COUNT; ++i) + Common::fill((byte *)&Swav[i], (byte *)&Swav[i] + sizeof(SwavItem), 0); + for (int i = 0; i < 2; ++i) + Common::fill((byte *)&Music[i], (byte *)&Music[i] + sizeof(MusicItem), 0); } void SoundManager::setParent(HopkinsEngine *vm) { @@ -63,16 +75,174 @@ void SoundManager::LOAD_WAV(const Common::String &file, int a2) { } void SoundManager::PLAY_ANM_SOUND(int soundNumber) { - warning("TODO: PLAAY_ANIM_SOUND"); + if (!_vm->_globals.CENSURE && SPECIAL_SOUND == 2) { + if (soundNumber == 20) + PLAY_SAMPLE2(5); + if (soundNumber == 57) + PLAY_SAMPLE2(1); + if (soundNumber == 63) + PLAY_SAMPLE2(1); + if (soundNumber == 69) + PLAY_SAMPLE2(1); + if (soundNumber == 75) + PLAY_SAMPLE2(2); + if (soundNumber == 109) + PLAY_SAMPLE2(3); + if (soundNumber == 122) + PLAY_SAMPLE2(4); + } + if (SPECIAL_SOUND == 1 && soundNumber == 17) + PLAY_SOUND("SOUND42.WAV"); + if (SPECIAL_SOUND == 199 && soundNumber == 72) + PLAY_WAV(1); + if (SPECIAL_SOUND == 198 && soundNumber == 15) + PLAY_WAV(1); + if (SPECIAL_SOUND == 16 && soundNumber == 25) + PLAY_WAV(1); + if (SPECIAL_SOUND == 14 && soundNumber == 625) + PLAY_WAV(1); + if (SPECIAL_SOUND == 208 && soundNumber == 40) + PLAY_WAV(1); + if (SPECIAL_SOUND == 210 && soundNumber == 2) + PLAY_WAV(1); + if (SPECIAL_SOUND == 211 && soundNumber == 22) + PLAY_WAV(1); + if (SPECIAL_SOUND == 5 && soundNumber == 19) + PLAY_WAV(1); + if (SPECIAL_SOUND == 17) { + if (soundNumber == 6) + PLAY_SAMPLE2(1); + if (soundNumber == 14) + PLAY_SAMPLE2(2); + if (soundNumber == 67) + PLAY_SAMPLE2(3); + } + if (SPECIAL_SOUND == 229) { + if (soundNumber == 15) + PLAY_WAV(1); + if (soundNumber == 91) + PLAY_WAV(2); + } } void SoundManager::WSOUND(int soundNumber) { warning("TODO: WSOUND"); } -bool SoundManager::VOICE_MIX(int a1, int a2) { - warning("TODO: VOICE_MIX"); - return false; +bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { + int fileNumber; + int oldMusicVol; + bool breakFlag; + Common::String prefix; + Common::String filename; + Common::File f; + int catPos; + + fileNumber = voiceId; + if (!CARD_SB || VOICEOFF == 1) + return false; + + if ((unsigned int)(voiceMode - 1) <= 1 + && (voiceId == 4 + || voiceId == 16 + || voiceId == 121 + || voiceId == 142 + || voiceId == 182 + || voiceId == 191 + || voiceId == 212 + || voiceId == 225 + || voiceId == 239 + || voiceId == 245 + || voiceId == 297 + || voiceId == 308 + || voiceId == 333 + || voiceId == 348 + || voiceId == 352 + || voiceId == 358 + || voiceId == 364 + || voiceId == 371 + || voiceId == 394 + || voiceId == 414 + || voiceId == 429 + || voiceId == 442 + || voiceId == 446 + || voiceId == 461 + || voiceId == 468 + || voiceId == 476 + || voiceId == 484 + || voiceId == 491 + || voiceId == 497 + || voiceId == 501 + || voiceId == 511 + || voiceId == 520 + || voiceId == 536 + || voiceId == 554 + || voiceId == 566 + || voiceId == 573 + || voiceId == 632 + || voiceId == 645)) + fileNumber = 684; + + if ((unsigned int)(voiceMode - 1) <= 1) { + prefix = "DF"; + } + if (voiceMode == 3) { + prefix = "IF"; + } + if (voiceMode == 4) { + prefix = "TF"; + } + if (voiceMode == 5) { + prefix = "OF"; + } + + filename = Common::String::format("%s%d.WAV", prefix.c_str(), fileNumber); + + if (!_vm->_fileManager.RECHERCHE_CAT(filename, 9)) { + if (_vm->_globals.FR == 1) + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VFR.RES"); + if (!_vm->_globals.FR) + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VAN.RES"); + if (_vm->_globals.FR == 2) + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VES.RES"); + + catPos = _vm->_globals.CAT_POSI; + } else { + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename); + + if (!f.exists(_vm->_globals.NFICHIER)) + return false; + + catPos = 0; + } + + SDL_LVOICE(catPos); + oldMusicVol = MUSICVOL; + if (!MUSICOFF && MUSICVOL > 2) + MUSICVOL = (signed int)((long double)MUSICVOL - (long double)MUSICVOL / 100.0 * 45.0); + + PLAY_VOICE_SDL(); + + breakFlag = 0; + do { + if (SPECIAL_SOUND != 4 && !VBL_MERDE) + _vm->_eventsManager.VBL(); + if (_vm->_eventsManager.BMOUSE()) + break; + _vm->_eventsManager.CONTROLE_MES(); + if (_vm->_eventsManager.ESC_KEY) + break; + if (!VOICE_STAT(2)) + breakFlag = true; + } while (!_vm->shouldQuit() && !breakFlag); + + + STOP_VOICE(2); + DEL_SAMPLE_SDL(20); + MUSICVOL = oldMusicVol; + _vm->_eventsManager.ESC_KEY = false; + VBL_MERDE = 0; + return true; } void SoundManager::DEL_SAMPLE(int soundNumber) { @@ -111,4 +281,75 @@ void SoundManager::PLAY_WAV(int a1) { warning("PLAY_WAV"); } +bool SoundManager::VOICE_STAT(int voiceIndex) { + return Voice[voiceIndex].active; +} + +void SoundManager::STOP_VOICE(int voiceIndex) { + int wavIndex; + + if (Voice[voiceIndex].active) { + Voice[voiceIndex].active = false; + wavIndex = Voice[voiceIndex].wavIndex; + if (Swav[wavIndex].active) { + if (Swav[wavIndex].field24 == 1) + DEL_SAMPLE_SDL(wavIndex); + } + } + Voice[voiceIndex].audioLen = 0; + Voice[voiceIndex].fieldC = 0; + Voice[voiceIndex].audioBuf = NULL; + Voice[voiceIndex].active = false; + Voice[voiceIndex].field14 = 0; + Voice[voiceIndex].audioStream = NULL; +} + +void SoundManager::SDL_LVOICE(int catPos) { + if (!SDL_LoadVoice(_vm->_globals.NFICHIER, catPos, Swav[20])) + error("Couldn't load the sample %s", _vm->_globals.NFICHIER.c_str()); + + Swav[20].active = true; +} + +void SoundManager::PLAY_VOICE_SDL() { + if (!Swav[20].active) + error("Bad handle"); + + if (!Voice[2].active) { + int wavIndex = Voice[2].wavIndex; + if (Swav[wavIndex].active && Swav[wavIndex].field24 == 1) + DEL_SAMPLE_SDL(wavIndex); + } + + Voice[2].audioLen = Swav[20].audioLen; + Voice[2].fieldC = 0; + Voice[2].audioBuf = Swav[20].audioBuf; + Voice[2].active = true; + Voice[2].field14 = 4; + Voice[2].audioStream = Swav[20].audioStream; +} + +bool SoundManager::DEL_SAMPLE_SDL(int wavIndex) { + if (Swav[wavIndex].active) { + Swav[wavIndex].active = false; + free(Swav[wavIndex].audioBuf); + delete Swav[wavIndex].audioStream; + return true; + } else { + return false; + } +} + +bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffset, SwavItem &item) { + Common::File f; + if (!f.open(filename)) + error("Could not open %s for reading", filename.c_str()); + + f.seek(fileOffset); + item.audioStream = Audio::makeWAVStream(&f, DisposeAfterUse::NO); + f.close(); + + return true; +} + } // End of namespace Hopkins -- cgit v1.2.3 From ebb1b80a71d11b087a6448d6117fd04fddbc1da9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Nov 2012 15:21:30 +1100 Subject: HOPKINS: Basic voice playback now working --- engines/hopkins/sound.cpp | 302 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 265 insertions(+), 37 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e43f66fd4a..c3f9f86b7b 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -21,6 +21,7 @@ */ #include "common/system.h" +#include "common/config-manager.h" #include "common/file.h" #include "common/textconsole.h" #include "hopkins/sound.h" @@ -43,7 +44,8 @@ SoundManager::SoundManager() { TEXTOFF = false; SOUND_FLAG = false; VBL_MERDE = false; - CARD_SB = false; + CARD_SB = true; + SOUND_NUM = 0; for (int i = 0; i < VOICE_COUNT; ++i) Common::fill((byte *)&Voice[i], (byte *)&Voice[i] + sizeof(VoiceItem), 0); @@ -51,6 +53,8 @@ SoundManager::SoundManager() { Common::fill((byte *)&Swav[i], (byte *)&Swav[i] + sizeof(SwavItem), 0); for (int i = 0; i < 2; ++i) Common::fill((byte *)&Music[i], (byte *)&Music[i] + sizeof(MusicItem), 0); + for (int i = 0; i < SOUND_COUNT; ++i) + Common::fill((byte *)&SOUND[i], (byte *)&SOUND[i] + sizeof(SoundItem), 0); } void SoundManager::setParent(HopkinsEngine *vm) { @@ -63,15 +67,44 @@ void SoundManager::WSOUND_INIT() { } void SoundManager::VERIF_SOUND() { -// warning("TODO: VERIF_SOUND"); + if (CARD_SB && !SOUNDOFF && SOUND_FLAG) { + if (!VOICE_STAT(1)) { + STOP_VOICE(1); + DEL_NWAV(SOUND_NUM); + } + } } void SoundManager::LOAD_ANM_SOUND() { - warning("TODO: LOAD_ANIM_SOUND"); -} - -void SoundManager::LOAD_WAV(const Common::String &file, int a2) { - warning("TODO: LOAD_WAV"); + if (SPECIAL_SOUND == 200) + VOICE_MIX(682, 1); + if (SPECIAL_SOUND == 199) + LOAD_WAV("SOUND22.WAV", 1); + if (SPECIAL_SOUND == 198) + LOAD_WAV("SOUND3.WAV", 1); + if (SPECIAL_SOUND == 16) + LOAD_WAV("SOUND16.WAV", 1); + if (SPECIAL_SOUND == 14) + LOAD_WAV("SOUND14.WAV", 1); + if (SPECIAL_SOUND == 208) + LOAD_WAV("SOUND77.WAV", 1); + if (SPECIAL_SOUND == 210) + LOAD_WAV("SOUND78.WAV", 1); + if (SPECIAL_SOUND == 211) + LOAD_WAV("SOUND78.WAV", 1); + if (SPECIAL_SOUND == 5) + LOAD_WAV("CRIE.WAV", 1); + if (SPECIAL_SOUND == 2) { + CHARGE_SAMPLE(5, "mitra1.wav"); + CHARGE_SAMPLE(1, "tir2.wav"); + CHARGE_SAMPLE(2, "sound6.wav"); + CHARGE_SAMPLE(3, "sound5.WAV"); + CHARGE_SAMPLE(4, "sound4.WAV"); + } + if (SPECIAL_SOUND == 229) { + LOAD_WAV("SOUND80.WAV", 1); + LOAD_WAV("SOUND82.WAV", 2); + } } void SoundManager::PLAY_ANM_SOUND(int soundNumber) { @@ -127,6 +160,75 @@ void SoundManager::PLAY_ANM_SOUND(int soundNumber) { void SoundManager::WSOUND(int soundNumber) { warning("TODO: WSOUND"); +/* + if (CARD_SB && (old_music != a1 || !MOD_FLAG)) { + if (MOD_FLAG == 1) + result = WSOUND_OFF(); + if (a1 == 1) + result = PLAY_MOD("appar"); + if (a1 == 2) + result = PLAY_MOD("ville"); + if (a1 == 3) + result = PLAY_MOD("Rock"); + if (a1 == 4) + result = PLAY_MOD("polic"); + if (a1 == 5) + result = PLAY_MOD("deep"); + if (a1 == 6) + result = PLAY_MOD("purga"); + if (a1 == 12) + result = PLAY_MOD("purg2"); + if (a1 == 7) + result = PLAY_MOD("rivie"); + if (a1 == 8) + result = PLAY_MOD("SUSPE"); + if (a1 == 9) + result = PLAY_MOD("labo"); + if (a1 == 10) + result = PLAY_MOD("cadav"); + if (a1 == 11) + result = PLAY_MOD("caban"); + if (a1 == 13) + result = PLAY_MOD("foret"); + if (a1 == 14) + result = PLAY_MOD("ile"); + if (a1 == 15) + result = PLAY_MOD("ile2"); + if (a1 == 16) + result = PLAY_MOD("hopki"); + if (a1 == 17) + result = PLAY_MOD("peur"); + if (a1 == 18) + result = PLAY_MOD("peur"); + if (a1 == 19) + result = PLAY_MOD("BASE"); + if (a1 == 20) + result = PLAY_MOD("cada2"); + if (a1 == 21) + result = PLAY_MOD("usine"); + if (a1 == 22) + result = PLAY_MOD("chien"); + if (a1 == 23) + result = PLAY_MOD("coeur"); + if (a1 == 24) + result = PLAY_MOD("stand"); + if (a1 == 25) + result = PLAY_MOD("ocean"); + if (a1 == 26) + result = PLAY_MOD("base3"); + if (a1 == 27) + result = PLAY_MOD("gloop"); + if (a1 == 28) + result = PLAY_MOD("cant"); + if (a1 == 29) + result = PLAY_MOD("feel"); + if (a1 == 30) + result = PLAY_MOD("lost"); + if (a1 == 31) + result = PLAY_MOD("tobac"); + old_music = a1; + } +*/ } bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { @@ -136,7 +238,7 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { Common::String prefix; Common::String filename; Common::File f; - int catPos; + size_t catPos, catLen; fileNumber = voiceId; if (!CARD_SB || VOICEOFF == 1) @@ -207,6 +309,7 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VES.RES"); catPos = _vm->_globals.CAT_POSI; + catLen = _vm->_globals.CAT_TAILLE; } else { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename); @@ -214,15 +317,17 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { return false; catPos = 0; + catLen = 0; } - SDL_LVOICE(catPos); + SDL_LVOICE(catPos, catLen); oldMusicVol = MUSICVOL; if (!MUSICOFF && MUSICVOL > 2) MUSICVOL = (signed int)((long double)MUSICVOL - (long double)MUSICVOL / 100.0 * 45.0); PLAY_VOICE_SDL(); + // Loop for playing voice breakFlag = 0; do { if (SPECIAL_SOUND != 4 && !VBL_MERDE) @@ -245,16 +350,35 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { return true; } -void SoundManager::DEL_SAMPLE(int soundNumber) { - warning("TODO: DEL_SAMPLE"); +void SoundManager::DEL_SAMPLE(int soundIndex) { + if (CARD_SB) { + if (VOICE_STAT(1) == 1) + STOP_VOICE(1); + if (VOICE_STAT(2) == 2) + STOP_VOICE(2); + if (VOICE_STAT(3) == 3) + STOP_VOICE(3); + DEL_SAMPLE_SDL(soundIndex); + SOUND[soundIndex].active = false; + } } void SoundManager::PLAY_SOUND(const Common::String &file) { - warning("TODO: PLAY_SOUND"); + if (CARD_SB && !SOUNDOFF) { + if (SOUND_FLAG) + DEL_NWAV(SOUND_NUM); + LOAD_NWAV(file, 1); + PLAY_NWAV(1); + } } void SoundManager::PLAY_SOUND2(const Common::String &file) { - warning("TODO: PLAY_SOUND2"); + if (CARD_SB) { + if (!SOUNDOFF) { + LOAD_NWAV(file, 1); + PLAY_NWAV(1); + } + } } void SoundManager::MODSetSampleVolume() { @@ -269,43 +393,62 @@ void SoundManager::MODSetMusicVolume(int volume) { warning("TODO MODSetMusicVolume"); } -void SoundManager::CHARGE_SAMPLE(int a1, const Common::String &file) { - warning("TODO: CHARGE_SAMPLE"); +void SoundManager::CHARGE_SAMPLE(int wavIndex, const Common::String &file) { + if (CARD_SB) { + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); + LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 0); + SOUND[wavIndex].active = true; + } } void SoundManager::PLAY_SAMPLE2(int idx) { - warning("PLAY_SAMPLE2"); + if (CARD_SB && !SOUNDOFF && SOUND[idx].active) { + if (SOUND_FLAG) + DEL_NWAV(SOUND_NUM); + if (VOICE_STAT(1) == 1) + STOP_VOICE(1); + PLAY_SAMPLE_SDL(1, idx); + } +} + +void SoundManager::LOAD_WAV(const Common::String &file, int wavIndex) { + if (CARD_SB) + LOAD_NWAV(file, wavIndex); } -void SoundManager::PLAY_WAV(int a1) { - warning("PLAY_WAV"); +void SoundManager::PLAY_WAV(int wavIndex) { + if (CARD_SB) + PLAY_NWAV(wavIndex); } -bool SoundManager::VOICE_STAT(int voiceIndex) { - return Voice[voiceIndex].active; +int SoundManager::VOICE_STAT(int voiceIndex) { + if (Voice[voiceIndex].status) { + if (Voice[voiceIndex].audioStream->endOfStream()) + STOP_VOICE(voiceIndex); + } + + return Voice[voiceIndex].status; } void SoundManager::STOP_VOICE(int voiceIndex) { int wavIndex; - if (Voice[voiceIndex].active) { - Voice[voiceIndex].active = false; + if (Voice[voiceIndex].status) { + Voice[voiceIndex].status = 0; wavIndex = Voice[voiceIndex].wavIndex; if (Swav[wavIndex].active) { if (Swav[wavIndex].field24 == 1) DEL_SAMPLE_SDL(wavIndex); } } - Voice[voiceIndex].audioLen = 0; Voice[voiceIndex].fieldC = 0; - Voice[voiceIndex].audioBuf = NULL; - Voice[voiceIndex].active = false; + Voice[voiceIndex].status = 0; Voice[voiceIndex].field14 = 0; Voice[voiceIndex].audioStream = NULL; } -void SoundManager::SDL_LVOICE(int catPos) { - if (!SDL_LoadVoice(_vm->_globals.NFICHIER, catPos, Swav[20])) +void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) { + if (!SDL_LoadVoice(_vm->_globals.NFICHIER, filePosition, entryLength, Swav[20])) error("Couldn't load the sample %s", _vm->_globals.NFICHIER.c_str()); Swav[20].active = true; @@ -315,24 +458,20 @@ void SoundManager::PLAY_VOICE_SDL() { if (!Swav[20].active) error("Bad handle"); - if (!Voice[2].active) { + if (!Voice[2].status) { int wavIndex = Voice[2].wavIndex; if (Swav[wavIndex].active && Swav[wavIndex].field24 == 1) DEL_SAMPLE_SDL(wavIndex); } - Voice[2].audioLen = Swav[20].audioLen; - Voice[2].fieldC = 0; - Voice[2].audioBuf = Swav[20].audioBuf; - Voice[2].active = true; - Voice[2].field14 = 4; - Voice[2].audioStream = Swav[20].audioStream; + PLAY_SAMPLE_SDL(2, 20); } bool SoundManager::DEL_SAMPLE_SDL(int wavIndex) { if (Swav[wavIndex].active) { Swav[wavIndex].active = false; - free(Swav[wavIndex].audioBuf); + + _vm->_mixer->stopHandle(Swav[wavIndex]._soundHandle); delete Swav[wavIndex].audioStream; return true; } else { @@ -340,16 +479,105 @@ bool SoundManager::DEL_SAMPLE_SDL(int wavIndex) { } } -bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffset, SwavItem &item) { +bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffset, size_t entryLength, SwavItem &item) { Common::File f; if (!f.open(filename)) error("Could not open %s for reading", filename.c_str()); f.seek(fileOffset); - item.audioStream = Audio::makeWAVStream(&f, DisposeAfterUse::NO); + item.audioStream = Audio::makeWAVStream(f.readStream((entryLength == 0) ? f.size() : entryLength), + DisposeAfterUse::YES); f.close(); return true; } +void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename, int field24) { + if (Swav[wavIndex].active) + DEL_SAMPLE_SDL(wavIndex); + + SDL_LoadVoice(filename, 0, 0, Swav[wavIndex]); + Swav[wavIndex].active = true; + Swav[wavIndex].field24 = field24; +} + +void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { + if (CARD_SB) { + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); + LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 1); + } +} + +void SoundManager::PLAY_NWAV(int wavIndex) { + if (CARD_SB && !SOUND_FLAG && !SOUNDOFF) { + SOUND_FLAG = true; + SOUND_NUM = wavIndex; + PLAY_SAMPLE_SDL(1, wavIndex); + } +} + +void SoundManager::DEL_NWAV(int wavIndex) { + if (CARD_SB) { + if (DEL_SAMPLE_SDL(wavIndex)) { + if (VOICE_STAT(1) == 1) + STOP_VOICE(1); + + SOUND_NUM = 0; + SOUND_FLAG = false; + } + } +} + +void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { + if (!Swav[wavIndex].active) + warning("Bad handle"); + + if (Voice[voiceIndex].status == 1 && Swav[wavIndex].active && Swav[wavIndex].field24 == 1) + DEL_SAMPLE_SDL(wavIndex); + + Voice[voiceIndex].fieldC = 0; + Voice[voiceIndex].audioStream = Swav[wavIndex].audioStream; + Voice[voiceIndex].status = 1; + Voice[voiceIndex].field14 = 4; + + int volume = (voiceIndex == 2) ? VOICEVOL * 255 / 16 : SOUNDVOL * 255 / 16; + + // Start the voice playing + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Swav[wavIndex]._soundHandle, + Swav[wavIndex].audioStream, -1, volume, 0, DisposeAfterUse::NO); +} + +void SoundManager::syncSoundSettings() { + bool muteAll = false; + if (ConfMan.hasKey("mute")) + muteAll = ConfMan.getBool("mute"); + + // Update the mute settings + MUSICOFF = muteAll || (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute")); + SOUNDOFF = muteAll || (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute")); + VOICEOFF = muteAll || (ConfMan.hasKey("speech_mute") && ConfMan.getBool("speech_mute")); + + // Update the volume levels + MUSICVOL = MIN(255, ConfMan.getInt("music_volume")) * 16 / 255; + SOUNDVOL = MIN(255, ConfMan.getInt("sfx_volume")) * 16 / 255; + VOICEVOL = MIN(255, ConfMan.getInt("speech_volume")) * 16 / 255; + + // + for (int idx = 0; idx < SWAV_COUNT; ++idx) { + if (Swav[idx].active) { + } + } +} + +void SoundManager::updateScummVMSoundSettings() { + ConfMan.setBool("mute", MUSICOFF && SOUNDOFF && VOICEOFF); + ConfMan.setBool("music_mute", MUSICOFF); + ConfMan.setBool("sfx_mute", SOUNDOFF); + ConfMan.setBool("speech_mute", VOICEOFF); + + ConfMan.setInt("music_volume", MUSICVOL * 255 / 16); + ConfMan.setInt("sfx_volume", SOUNDVOL * 255 / 16); + ConfMan.setInt("speech_volume", VOICEVOL * 255 / 16); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 3f86ca2c7947b983c911080e6aeba7f3fdd37fb4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Nov 2012 18:58:45 +1100 Subject: HOPKINS: Music playback is now working --- engines/hopkins/sound.cpp | 364 +++++++++++++++++++++++++++++++++------------- 1 file changed, 261 insertions(+), 103 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index c3f9f86b7b..4fc20540f5 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -44,17 +44,21 @@ SoundManager::SoundManager() { TEXTOFF = false; SOUND_FLAG = false; VBL_MERDE = false; - CARD_SB = true; SOUND_NUM = 0; + old_music = 0; + MOD_FLAG = false; + + CARD_SB = true; for (int i = 0; i < VOICE_COUNT; ++i) Common::fill((byte *)&Voice[i], (byte *)&Voice[i] + sizeof(VoiceItem), 0); for (int i = 0; i < SWAV_COUNT; ++i) Common::fill((byte *)&Swav[i], (byte *)&Swav[i] + sizeof(SwavItem), 0); - for (int i = 0; i < 2; ++i) - Common::fill((byte *)&Music[i], (byte *)&Music[i] + sizeof(MusicItem), 0); + for (int i = 0; i < MWAV_COUNT; ++i) + Common::fill((byte *)&Mwav[i], (byte *)&Mwav[i] + sizeof(MwavItem), 0); for (int i = 0; i < SOUND_COUNT; ++i) Common::fill((byte *)&SOUND[i], (byte *)&SOUND[i] + sizeof(SoundItem), 0); + Common::fill((byte *)&Music, (byte *)&Music + sizeof(MusicItem), 0); } void SoundManager::setParent(HopkinsEngine *vm) { @@ -159,76 +163,230 @@ void SoundManager::PLAY_ANM_SOUND(int soundNumber) { } void SoundManager::WSOUND(int soundNumber) { - warning("TODO: WSOUND"); -/* - if (CARD_SB && (old_music != a1 || !MOD_FLAG)) { + if (CARD_SB && (old_music != soundNumber || !MOD_FLAG)) { if (MOD_FLAG == 1) - result = WSOUND_OFF(); - if (a1 == 1) - result = PLAY_MOD("appar"); - if (a1 == 2) - result = PLAY_MOD("ville"); - if (a1 == 3) - result = PLAY_MOD("Rock"); - if (a1 == 4) - result = PLAY_MOD("polic"); - if (a1 == 5) - result = PLAY_MOD("deep"); - if (a1 == 6) - result = PLAY_MOD("purga"); - if (a1 == 12) - result = PLAY_MOD("purg2"); - if (a1 == 7) - result = PLAY_MOD("rivie"); - if (a1 == 8) - result = PLAY_MOD("SUSPE"); - if (a1 == 9) - result = PLAY_MOD("labo"); - if (a1 == 10) - result = PLAY_MOD("cadav"); - if (a1 == 11) - result = PLAY_MOD("caban"); - if (a1 == 13) - result = PLAY_MOD("foret"); - if (a1 == 14) - result = PLAY_MOD("ile"); - if (a1 == 15) - result = PLAY_MOD("ile2"); - if (a1 == 16) - result = PLAY_MOD("hopki"); - if (a1 == 17) - result = PLAY_MOD("peur"); - if (a1 == 18) - result = PLAY_MOD("peur"); - if (a1 == 19) - result = PLAY_MOD("BASE"); - if (a1 == 20) - result = PLAY_MOD("cada2"); - if (a1 == 21) - result = PLAY_MOD("usine"); - if (a1 == 22) - result = PLAY_MOD("chien"); - if (a1 == 23) - result = PLAY_MOD("coeur"); - if (a1 == 24) - result = PLAY_MOD("stand"); - if (a1 == 25) - result = PLAY_MOD("ocean"); - if (a1 == 26) - result = PLAY_MOD("base3"); - if (a1 == 27) - result = PLAY_MOD("gloop"); - if (a1 == 28) - result = PLAY_MOD("cant"); - if (a1 == 29) - result = PLAY_MOD("feel"); - if (a1 == 30) - result = PLAY_MOD("lost"); - if (a1 == 31) - result = PLAY_MOD("tobac"); - old_music = a1; + WSOUND_OFF(); + if (soundNumber == 1) + PLAY_MOD("appar"); + if (soundNumber == 2) + PLAY_MOD("ville"); + if (soundNumber == 3) + PLAY_MOD("Rock"); + if (soundNumber == 4) + PLAY_MOD("polic"); + if (soundNumber == 5) + PLAY_MOD("deep"); + if (soundNumber == 6) + PLAY_MOD("purga"); + if (soundNumber == 12) + PLAY_MOD("purg2"); + if (soundNumber == 7) + PLAY_MOD("rivie"); + if (soundNumber == 8) + PLAY_MOD("SUSPE"); + if (soundNumber == 9) + PLAY_MOD("labo"); + if (soundNumber == 10) + PLAY_MOD("cadav"); + if (soundNumber == 11) + PLAY_MOD("caban"); + if (soundNumber == 13) + PLAY_MOD("foret"); + if (soundNumber == 14) + PLAY_MOD("ile"); + if (soundNumber == 15) + PLAY_MOD("ile2"); + if (soundNumber == 16) + PLAY_MOD("hopki"); + if (soundNumber == 17) + PLAY_MOD("peur"); + if (soundNumber == 18) + PLAY_MOD("peur"); + if (soundNumber == 19) + PLAY_MOD("BASE"); + if (soundNumber == 20) + PLAY_MOD("cada2"); + if (soundNumber == 21) + PLAY_MOD("usine"); + if (soundNumber == 22) + PLAY_MOD("chien"); + if (soundNumber == 23) + PLAY_MOD("coeur"); + if (soundNumber == 24) + PLAY_MOD("stand"); + if (soundNumber == 25) + PLAY_MOD("ocean"); + if (soundNumber == 26) + PLAY_MOD("base3"); + if (soundNumber == 27) + PLAY_MOD("gloop"); + if (soundNumber == 28) + PLAY_MOD("cant"); + if (soundNumber == 29) + PLAY_MOD("feel"); + if (soundNumber == 30) + PLAY_MOD("lost"); + if (soundNumber == 31) + PLAY_MOD("tobac"); + old_music = soundNumber; + } +} + +void SoundManager::WSOUND_OFF() { + if (CARD_SB) { + STOP_VOICE(0); + STOP_VOICE(1); + STOP_VOICE(2); + if (_vm->_soundManager.SOUND_FLAG) + DEL_NWAV(SOUND_NUM); + + for (int i = 1; i <= 48; ++i) + DEL_SAMPLE_SDL(i); + + if (MOD_FLAG) { + STOP_MUSIC(); + DEL_MUSIC(); + MOD_FLAG = false; + } + } +} + +void SoundManager::PLAY_MOD(const Common::String &file) { + if (CARD_SB) { + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPMUSIC, file); + if (MOD_FLAG) { + STOP_MUSIC(); + DEL_MUSIC(); + MOD_FLAG = false; + } + + LOAD_MUSIC(_vm->_globals.NFICHIER); + PLAY_MUSIC(); + MOD_FLAG = true; + } +} + +void SoundManager::LOAD_MUSIC(const Common::String &file) { + if (Music._active) + DEL_MUSIC(); + + Common::File f; + Common::String filename = Common::String::format("%s.TWA", file.c_str()); + + if (!f.open(filename)) + error("Error opening file %s", filename.c_str()); + + char s[8]; + int destIndex = 0; + int mwavIndex; + + bool breakFlag = false; + do { + f.read(&s[0], 3); + + if (s[0] == 'x') { + // End of list reached + Music._mwavIndexes[destIndex] = -1; + breakFlag = true; + } else { + // Convert two digits to a number + s[2] = '\0'; + mwavIndex = atol(&s[0]); + + Common::String filename = Common::String::format("%s_%s.WAV", file.c_str(), &s[0]); + LOAD_MSAMPLE(mwavIndex, filename); + + Music._mwavIndexes[destIndex++] = mwavIndex; + } + } while (!breakFlag); + + f.close(); + + Music._active = true; + Music._isPlaying = false; + Music._currentIndex = -1; + Music.fieldE0 = 0; + Music.fieldE4 = 0; + Music.fieldE8 = 0; + Music.fieldF0 = 3; +} + +void SoundManager::PLAY_MUSIC() { + if (Music._active) + Music._isPlaying = true; +} + +void SoundManager::STOP_MUSIC() { + if (Music._active) + Music._isPlaying = false; +} + +void SoundManager::DEL_MUSIC() { + if (Music._active) { + for (int i = 0; i < 50; ++i) { + DEL_MSAMPLE(i); + } + } + + Music._active = false; + Music._isPlaying = false; + Music._string = " "; + Music._currentIndex = -1; + Music.fieldE0 = 0; + Music.fieldE4 = 0; + Music.fieldE8 = 0; + Music.fieldF0 = 0; +} + +void SoundManager::checkMusic() { + if (Music._active && Music._isPlaying) { + int mwavIndex = Music._mwavIndexes[Music._currentIndex]; + if (mwavIndex == -1) + return; + + if (Music._currentIndex >= 0 && Music._currentIndex < MWAV_COUNT) { + if (mwavIndex != -1 && !Mwav[mwavIndex]._audioStream->endOfStream()) + // Currently playing wav has not finished, so exit + return; + + _vm->_mixer->stopHandle(Mwav[mwavIndex]._soundHandle); + } + + // Time to move to the next index + if (++Music._currentIndex >= MWAV_COUNT) + return; + + mwavIndex = Music._mwavIndexes[Music._currentIndex]; + if (mwavIndex != -1) { + int volume = MUSICVOL * 255 / 16; + + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Mwav[mwavIndex]._soundHandle, + Mwav[mwavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); + } + } +} + +void SoundManager::LOAD_MSAMPLE(int mwavIndex, const Common::String &file) { + if (!Mwav[mwavIndex]._active) { + Common::File f; + if (!f.open(file)) + error("Could not open %s for reading", file.c_str()); + + Mwav[mwavIndex]._audioStream = Audio::makeWAVStream(f.readStream(f.size()), DisposeAfterUse::YES); + Mwav[mwavIndex]._active = true; + + f.close(); + } +} + +void SoundManager::DEL_MSAMPLE(int mwavIndex) { + if (Mwav[mwavIndex]._active) { + Mwav[mwavIndex]._active = false; + _vm->_mixer->stopHandle(Mwav[mwavIndex]._soundHandle); + + delete Mwav[mwavIndex]._audioStream; + Mwav[mwavIndex]._audioStream = NULL; } -*/ } bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { @@ -359,7 +517,7 @@ void SoundManager::DEL_SAMPLE(int soundIndex) { if (VOICE_STAT(3) == 3) STOP_VOICE(3); DEL_SAMPLE_SDL(soundIndex); - SOUND[soundIndex].active = false; + SOUND[soundIndex]._active = false; } } @@ -382,27 +540,27 @@ void SoundManager::PLAY_SOUND2(const Common::String &file) { } void SoundManager::MODSetSampleVolume() { - warning("TODO MODSetSampleVolume"); + // No implementatoin needed } void SoundManager::MODSetVoiceVolume() { - warning("TODO MODSetVoiceVolume"); + // No implementatoin needed } void SoundManager::MODSetMusicVolume(int volume) { - warning("TODO MODSetMusicVolume"); + // No implementatoin needed } void SoundManager::CHARGE_SAMPLE(int wavIndex, const Common::String &file) { if (CARD_SB) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 0); - SOUND[wavIndex].active = true; + SOUND[wavIndex]._active = true; } } void SoundManager::PLAY_SAMPLE2(int idx) { - if (CARD_SB && !SOUNDOFF && SOUND[idx].active) { + if (CARD_SB && !SOUNDOFF && SOUND[idx]._active) { if (SOUND_FLAG) DEL_NWAV(SOUND_NUM); if (VOICE_STAT(1) == 1) @@ -422,45 +580,45 @@ void SoundManager::PLAY_WAV(int wavIndex) { } int SoundManager::VOICE_STAT(int voiceIndex) { - if (Voice[voiceIndex].status) { - if (Voice[voiceIndex].audioStream->endOfStream()) + if (Voice[voiceIndex]._status) { + if (Voice[voiceIndex]._audioStream->endOfStream()) STOP_VOICE(voiceIndex); } - return Voice[voiceIndex].status; + return Voice[voiceIndex]._status; } void SoundManager::STOP_VOICE(int voiceIndex) { int wavIndex; - if (Voice[voiceIndex].status) { - Voice[voiceIndex].status = 0; - wavIndex = Voice[voiceIndex].wavIndex; - if (Swav[wavIndex].active) { + if (Voice[voiceIndex]._status) { + Voice[voiceIndex]._status = 0; + wavIndex = Voice[voiceIndex]._wavIndex; + if (Swav[wavIndex]._active) { if (Swav[wavIndex].field24 == 1) DEL_SAMPLE_SDL(wavIndex); } } Voice[voiceIndex].fieldC = 0; - Voice[voiceIndex].status = 0; + Voice[voiceIndex]._status = 0; Voice[voiceIndex].field14 = 0; - Voice[voiceIndex].audioStream = NULL; + Voice[voiceIndex]._audioStream = NULL; } void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) { if (!SDL_LoadVoice(_vm->_globals.NFICHIER, filePosition, entryLength, Swav[20])) error("Couldn't load the sample %s", _vm->_globals.NFICHIER.c_str()); - Swav[20].active = true; + Swav[20]._active = true; } void SoundManager::PLAY_VOICE_SDL() { - if (!Swav[20].active) + if (!Swav[20]._active) error("Bad handle"); - if (!Voice[2].status) { - int wavIndex = Voice[2].wavIndex; - if (Swav[wavIndex].active && Swav[wavIndex].field24 == 1) + if (!Voice[2]._status) { + int wavIndex = Voice[2]._wavIndex; + if (Swav[wavIndex]._active && Swav[wavIndex].field24 == 1) DEL_SAMPLE_SDL(wavIndex); } @@ -468,11 +626,11 @@ void SoundManager::PLAY_VOICE_SDL() { } bool SoundManager::DEL_SAMPLE_SDL(int wavIndex) { - if (Swav[wavIndex].active) { - Swav[wavIndex].active = false; + if (Swav[wavIndex]._active) { + Swav[wavIndex]._active = false; _vm->_mixer->stopHandle(Swav[wavIndex]._soundHandle); - delete Swav[wavIndex].audioStream; + delete Swav[wavIndex]._audioStream; return true; } else { return false; @@ -485,7 +643,7 @@ bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffs error("Could not open %s for reading", filename.c_str()); f.seek(fileOffset); - item.audioStream = Audio::makeWAVStream(f.readStream((entryLength == 0) ? f.size() : entryLength), + item._audioStream = Audio::makeWAVStream(f.readStream((entryLength == 0) ? f.size() : entryLength), DisposeAfterUse::YES); f.close(); @@ -493,11 +651,11 @@ bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffs } void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename, int field24) { - if (Swav[wavIndex].active) + if (Swav[wavIndex]._active) DEL_SAMPLE_SDL(wavIndex); SDL_LoadVoice(filename, 0, 0, Swav[wavIndex]); - Swav[wavIndex].active = true; + Swav[wavIndex]._active = true; Swav[wavIndex].field24 = field24; } @@ -529,22 +687,22 @@ void SoundManager::DEL_NWAV(int wavIndex) { } void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { - if (!Swav[wavIndex].active) + if (!Swav[wavIndex]._active) warning("Bad handle"); - if (Voice[voiceIndex].status == 1 && Swav[wavIndex].active && Swav[wavIndex].field24 == 1) + if (Voice[voiceIndex]._status == 1 && Swav[wavIndex]._active && Swav[wavIndex].field24 == 1) DEL_SAMPLE_SDL(wavIndex); Voice[voiceIndex].fieldC = 0; - Voice[voiceIndex].audioStream = Swav[wavIndex].audioStream; - Voice[voiceIndex].status = 1; + Voice[voiceIndex]._audioStream = Swav[wavIndex]._audioStream; + Voice[voiceIndex]._status = 1; Voice[voiceIndex].field14 = 4; int volume = (voiceIndex == 2) ? VOICEVOL * 255 / 16 : SOUNDVOL * 255 / 16; // Start the voice playing _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Swav[wavIndex]._soundHandle, - Swav[wavIndex].audioStream, -1, volume, 0, DisposeAfterUse::NO); + Swav[wavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); } void SoundManager::syncSoundSettings() { @@ -564,7 +722,7 @@ void SoundManager::syncSoundSettings() { // for (int idx = 0; idx < SWAV_COUNT; ++idx) { - if (Swav[idx].active) { + if (Swav[idx]._active) { } } } -- cgit v1.2.3 From 29a8d2aa95b2c3c137e313cf2d8efd2cfa685c08 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Nov 2012 19:28:28 +1100 Subject: HOPKINS: Bugfix to make music playback loop --- engines/hopkins/sound.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 4fc20540f5..ffb19a9aa2 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -357,12 +357,16 @@ void SoundManager::checkMusic() { return; mwavIndex = Music._mwavIndexes[Music._currentIndex]; - if (mwavIndex != -1) { - int volume = MUSICVOL * 255 / 16; + if (mwavIndex == -1) { + Music._currentIndex = 0; + mwavIndex = Music._mwavIndexes[Music._currentIndex]; + } - _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Mwav[mwavIndex]._soundHandle, - Mwav[mwavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); - } + int volume = MUSICVOL * 255 / 16; + + Mwav[mwavIndex]._audioStream->rewind(); + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Mwav[mwavIndex]._soundHandle, + Mwav[mwavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); } } -- cgit v1.2.3 From 0ef8703833c556ab8ace5db7abf7c7087a299587 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Nov 2012 19:40:05 +1100 Subject: HOPKINS: Fix to not play music if it is muted --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index ffb19a9aa2..00da0ffb64 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -252,7 +252,7 @@ void SoundManager::WSOUND_OFF() { } void SoundManager::PLAY_MOD(const Common::String &file) { - if (CARD_SB) { + if (CARD_SB && !MUSICOFF) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPMUSIC, file); if (MOD_FLAG) { STOP_MUSIC(); -- cgit v1.2.3 From 1844e4faa24bd31da89db49751ee80b201d061e9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Nov 2012 19:54:48 +1100 Subject: HOPKINS: Clean up of un-needed sound structure fields --- engines/hopkins/sound.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 00da0ffb64..7aaa373d45 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -296,6 +296,7 @@ void SoundManager::LOAD_MUSIC(const Common::String &file) { Common::String filename = Common::String::format("%s_%s.WAV", file.c_str(), &s[0]); LOAD_MSAMPLE(mwavIndex, filename); + assert(destIndex < MUSIC_WAVE_COUNT); Music._mwavIndexes[destIndex++] = mwavIndex; } } while (!breakFlag); @@ -305,10 +306,6 @@ void SoundManager::LOAD_MUSIC(const Common::String &file) { Music._active = true; Music._isPlaying = false; Music._currentIndex = -1; - Music.fieldE0 = 0; - Music.fieldE4 = 0; - Music.fieldE8 = 0; - Music.fieldF0 = 3; } void SoundManager::PLAY_MUSIC() { @@ -332,10 +329,6 @@ void SoundManager::DEL_MUSIC() { Music._isPlaying = false; Music._string = " "; Music._currentIndex = -1; - Music.fieldE0 = 0; - Music.fieldE4 = 0; - Music.fieldE8 = 0; - Music.fieldF0 = 0; } void SoundManager::checkMusic() { @@ -599,7 +592,7 @@ void SoundManager::STOP_VOICE(int voiceIndex) { Voice[voiceIndex]._status = 0; wavIndex = Voice[voiceIndex]._wavIndex; if (Swav[wavIndex]._active) { - if (Swav[wavIndex].field24 == 1) + if (Swav[wavIndex].freeSample) DEL_SAMPLE_SDL(wavIndex); } } @@ -622,7 +615,7 @@ void SoundManager::PLAY_VOICE_SDL() { if (!Voice[2]._status) { int wavIndex = Voice[2]._wavIndex; - if (Swav[wavIndex]._active && Swav[wavIndex].field24 == 1) + if (Swav[wavIndex]._active && Swav[wavIndex].freeSample) DEL_SAMPLE_SDL(wavIndex); } @@ -654,13 +647,13 @@ bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffs return true; } -void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename, int field24) { +void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename, bool freeSample) { if (Swav[wavIndex]._active) DEL_SAMPLE_SDL(wavIndex); SDL_LoadVoice(filename, 0, 0, Swav[wavIndex]); Swav[wavIndex]._active = true; - Swav[wavIndex].field24 = field24; + Swav[wavIndex].freeSample = freeSample; } void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { @@ -694,7 +687,7 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { if (!Swav[wavIndex]._active) warning("Bad handle"); - if (Voice[voiceIndex]._status == 1 && Swav[wavIndex]._active && Swav[wavIndex].field24 == 1) + if (Voice[voiceIndex]._status == 1 && Swav[wavIndex]._active && Swav[wavIndex].freeSample) DEL_SAMPLE_SDL(wavIndex); Voice[voiceIndex].fieldC = 0; -- cgit v1.2.3 From 4def58832ddde8e6ec73c2174754019e1b5da0d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Nov 2012 20:00:57 +1100 Subject: HOPKINS: Added missing flush of changed sound settings to disk --- engines/hopkins/sound.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 7aaa373d45..819877bc20 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -733,6 +733,8 @@ void SoundManager::updateScummVMSoundSettings() { ConfMan.setInt("music_volume", MUSICVOL * 255 / 16); ConfMan.setInt("sfx_volume", SOUNDVOL * 255 / 16); ConfMan.setInt("speech_volume", VOICEVOL * 255 / 16); + + ConfMan.flushToDisk(); } } // End of namespace Hopkins -- cgit v1.2.3 From 9fd36c32f27dd203529ebc597e4f44ec85d80253 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Nov 2012 20:58:33 +1100 Subject: HOPKINS: Update playing sounds when the volumes are changed in the GMM --- engines/hopkins/sound.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 819877bc20..e23c7e525f 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -717,9 +717,16 @@ void SoundManager::syncSoundSettings() { SOUNDVOL = MIN(255, ConfMan.getInt("sfx_volume")) * 16 / 255; VOICEVOL = MIN(255, ConfMan.getInt("speech_volume")) * 16 / 255; - // + // Update any active sounds for (int idx = 0; idx < SWAV_COUNT; ++idx) { if (Swav[idx]._active) { + int volume = (idx == 20) ? (VOICEVOL * 255 / 16) : (SOUNDVOL * 255 / 16); + _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); + } + } + for (int idx = 0; idx < MWAV_COUNT; ++idx) { + if (Mwav[idx]._active) { + _vm->_mixer->setChannelVolume(Mwav[idx]._soundHandle, MUSICVOL * 255 / 16); } } } -- cgit v1.2.3 From ff9dc4ab248e47c15076dd822b635927f7b27161 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 12 Nov 2012 20:09:29 +1100 Subject: HOPKINS: Bugfix for freeze when looking at the cat when voices are turned on. --- engines/hopkins/sound.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e23c7e525f..9cbfa39f71 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -331,6 +331,11 @@ void SoundManager::DEL_MUSIC() { Music._currentIndex = -1; } +void SoundManager::checkSounds() { + checkMusic(); + checkVoices(); +} + void SoundManager::checkMusic() { if (Music._active && Music._isPlaying) { int mwavIndex = Music._mwavIndexes[Music._currentIndex]; @@ -363,6 +368,20 @@ void SoundManager::checkMusic() { } } +void SoundManager::checkVoices() { + // Check the status of each voice. + bool hasActiveVoice = false; + for (int i = 0; i < VOICE_COUNT; ++i) { + VOICE_STAT(i); + hasActiveVoice |= Voice[i]._status != 0; + } + + if (!hasActiveVoice && SOUND_FLAG) { + SOUND_FLAG = false; + SOUND_NUM = 0; + } +} + void SoundManager::LOAD_MSAMPLE(int mwavIndex, const Common::String &file) { if (!Mwav[mwavIndex]._active) { Common::File f; @@ -578,7 +597,8 @@ void SoundManager::PLAY_WAV(int wavIndex) { int SoundManager::VOICE_STAT(int voiceIndex) { if (Voice[voiceIndex]._status) { - if (Voice[voiceIndex]._audioStream->endOfStream()) + int wavIndex = Voice[voiceIndex]._wavIndex; + if (Swav[wavIndex]._audioStream->endOfStream()) STOP_VOICE(voiceIndex); } @@ -599,7 +619,6 @@ void SoundManager::STOP_VOICE(int voiceIndex) { Voice[voiceIndex].fieldC = 0; Voice[voiceIndex]._status = 0; Voice[voiceIndex].field14 = 0; - Voice[voiceIndex]._audioStream = NULL; } void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) { @@ -691,9 +710,9 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { DEL_SAMPLE_SDL(wavIndex); Voice[voiceIndex].fieldC = 0; - Voice[voiceIndex]._audioStream = Swav[wavIndex]._audioStream; Voice[voiceIndex]._status = 1; Voice[voiceIndex].field14 = 4; + Voice[voiceIndex]._wavIndex = wavIndex; int volume = (voiceIndex == 2) ? VOICEVOL * 255 / 16 : SOUNDVOL * 255 / 16; -- cgit v1.2.3 From 5f21d3d00a4b1f821d8fc98e37a31a872d835d08 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 13 Nov 2012 20:40:24 +1100 Subject: HOPKINS: Fix gcc warning about shadowed variable --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 9cbfa39f71..13979c5cd8 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -293,7 +293,7 @@ void SoundManager::LOAD_MUSIC(const Common::String &file) { s[2] = '\0'; mwavIndex = atol(&s[0]); - Common::String filename = Common::String::format("%s_%s.WAV", file.c_str(), &s[0]); + filename = Common::String::format("%s_%s.WAV", file.c_str(), &s[0]); LOAD_MSAMPLE(mwavIndex, filename); assert(destIndex < MUSIC_WAVE_COUNT); -- cgit v1.2.3 From 0fdea57c544c8c1bd1c816262d9319367334eb83 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 17 Nov 2012 20:49:07 +1100 Subject: HOPKINS: Lots of code implemented for Hopkin's computer --- engines/hopkins/sound.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 13979c5cd8..519d43b05a 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -575,6 +575,33 @@ void SoundManager::CHARGE_SAMPLE(int wavIndex, const Common::String &file) { } } +void SoundManager::PLAY_SAMPLE(int wavIndex, int voiceMode) { + if (CARD_SB && !SOUNDOFF && SOUND[wavIndex]._active) { + if (SOUND_FLAG) + DEL_NWAV(SOUND_NUM); + if (voiceMode == 5) { + if (VOICE_STAT(1) == 1) + STOP_VOICE(1); + PLAY_SAMPLE_SDL(1, wavIndex); + } + if (voiceMode == 6) { + if (VOICE_STAT(2) == 1) + STOP_VOICE(1); + PLAY_SAMPLE_SDL(2, wavIndex); + } + if (voiceMode == 7) { + if (VOICE_STAT(3) == 1) + STOP_VOICE(1); + PLAY_SAMPLE_SDL(3, wavIndex); + } + if (voiceMode == 8) { + if (VOICE_STAT(1) == 1) + STOP_VOICE(1); + PLAY_SAMPLE_SDL(1, wavIndex); + } + } +} + void SoundManager::PLAY_SAMPLE2(int idx) { if (CARD_SB && !SOUNDOFF && SOUND[idx]._active) { if (SOUND_FLAG) -- cgit v1.2.3 From 832f06fa8ac761e8cae5811a54629fd77e83e336 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 18 Nov 2012 10:31:58 +1100 Subject: HOPKINS: Bugfix for crash when pushing button in purgatory control room --- engines/hopkins/sound.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 519d43b05a..8974d3e9fe 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -625,7 +625,7 @@ void SoundManager::PLAY_WAV(int wavIndex) { int SoundManager::VOICE_STAT(int voiceIndex) { if (Voice[voiceIndex]._status) { int wavIndex = Voice[voiceIndex]._wavIndex; - if (Swav[wavIndex]._audioStream->endOfStream()) + if (Swav[wavIndex]._audioStream != NULL && Swav[wavIndex]._audioStream->endOfStream()) STOP_VOICE(voiceIndex); } @@ -670,10 +670,11 @@ void SoundManager::PLAY_VOICE_SDL() { bool SoundManager::DEL_SAMPLE_SDL(int wavIndex) { if (Swav[wavIndex]._active) { - Swav[wavIndex]._active = false; - _vm->_mixer->stopHandle(Swav[wavIndex]._soundHandle); delete Swav[wavIndex]._audioStream; + Swav[wavIndex]._audioStream = NULL; + Swav[wavIndex]._active = false; + return true; } else { return false; -- cgit v1.2.3 From 38acdce7358a92d78faecd618f1905ad5fe8462b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 24 Nov 2012 00:16:44 +0100 Subject: HOPKINS: Fix more CppCheck warnings --- engines/hopkins/sound.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 8974d3e9fe..da3a3de747 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -633,11 +633,9 @@ int SoundManager::VOICE_STAT(int voiceIndex) { } void SoundManager::STOP_VOICE(int voiceIndex) { - int wavIndex; - if (Voice[voiceIndex]._status) { Voice[voiceIndex]._status = 0; - wavIndex = Voice[voiceIndex]._wavIndex; + int wavIndex = Voice[voiceIndex]._wavIndex; if (Swav[wavIndex]._active) { if (Swav[wavIndex].freeSample) DEL_SAMPLE_SDL(wavIndex); -- cgit v1.2.3 From 5cd2633b3bf4ce80517afc9de618278e4f004d85 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Dec 2012 17:16:00 +1100 Subject: HOPKINS: Initial implementation of new codec for Windows APC sound files --- engines/hopkins/sound.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index da3a3de747..6f9f17a937 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -20,6 +20,7 @@ * */ +#include "audio/decoders/adpcm_intern.h" #include "common/system.h" #include "common/config-manager.h" #include "common/file.h" @@ -28,6 +29,45 @@ #include "hopkins/globals.h" #include "hopkins/hopkins.h" +namespace Audio { + +class APC_ADPCMStream : public Audio::DVI_ADPCMStream { +public: + APC_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, int rate, int channels) : DVI_ADPCMStream(stream, disposeAfterUse, stream->size(), rate, channels, 0) { + stream->seek(-12, SEEK_CUR); + _status.ima_ch[0].last = _startValue[0] = stream->readUint32LE(); + _status.ima_ch[1].last = _startValue[1] = stream->readUint32LE(); + stream->seek(4, SEEK_CUR); + } + + void reset() { + DVI_ADPCMStream::reset(); + _status.ima_ch[0].last = _startValue[0]; + _status.ima_ch[1].last = _startValue[1]; + } + +private: + int16 _startValue[2]; +}; + +Audio::RewindableAudioStream *makeAPCStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse) { + if (stream->readUint32BE() != MKTAG('C', 'R', 'Y', 'O')) + return 0; + if (stream->readUint32BE() != MKTAG('_', 'A', 'P', 'C')) + return 0; + stream->readUint32BE(); // version + stream->readUint32LE(); // out size + uint32 rate = stream->readUint32LE(); + stream->skip(8); // initial values, will be handled by the class + bool stereo = stream->readUint32LE() != 0; + + return new APC_ADPCMStream(stream, disposeAfterUse, rate, stereo ? 2 : 1); +} + +} + +/*------------------------------------------------------------------------*/ + namespace Hopkins { SoundManager::SoundManager() { @@ -388,7 +428,7 @@ void SoundManager::LOAD_MSAMPLE(int mwavIndex, const Common::String &file) { if (!f.open(file)) error("Could not open %s for reading", file.c_str()); - Mwav[mwavIndex]._audioStream = Audio::makeWAVStream(f.readStream(f.size()), DisposeAfterUse::YES); + Mwav[mwavIndex]._audioStream = makeSoundStream(f.readStream(f.size())); Mwav[mwavIndex]._active = true; f.close(); @@ -685,8 +725,7 @@ bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffs error("Could not open %s for reading", filename.c_str()); f.seek(fileOffset); - item._audioStream = Audio::makeWAVStream(f.readStream((entryLength == 0) ? f.size() : entryLength), - DisposeAfterUse::YES); + item._audioStream = makeSoundStream(f.readStream((entryLength == 0) ? f.size() : entryLength)); f.close(); return true; @@ -789,4 +828,11 @@ void SoundManager::updateScummVMSoundSettings() { ConfMan.flushToDisk(); } +Audio::RewindableAudioStream *SoundManager::makeSoundStream(Common::SeekableReadStream *stream) { + if (_vm->getPlatform() == Common::kPlatformWindows) + return Audio::makeAPCStream(stream, DisposeAfterUse::YES); + else + return Audio::makeWAVStream(stream, DisposeAfterUse::YES); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 3841a0d0068498e23895a565c441bda62d65dc03 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Dec 2012 22:33:01 +1100 Subject: HOPKINS: Bugfix for loading APC music files in the Windows versions --- engines/hopkins/sound.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 6f9f17a937..08f6f4abff 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -333,7 +333,8 @@ void SoundManager::LOAD_MUSIC(const Common::String &file) { s[2] = '\0'; mwavIndex = atol(&s[0]); - filename = Common::String::format("%s_%s.WAV", file.c_str(), &s[0]); + filename = Common::String::format("%s_%s.%s", file.c_str(), &s[0], + (_vm->getPlatform() == Common::kPlatformWindows) ? "APC" : "WAV"); LOAD_MSAMPLE(mwavIndex, filename); assert(destIndex < MUSIC_WAVE_COUNT); -- cgit v1.2.3 From 5dd1776228555bdc698cae2261ace5ebc3dafa12 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 3 Dec 2012 07:48:37 +0100 Subject: HOPKINS: Win95 demo is now completable --- engines/hopkins/sound.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 08f6f4abff..6b2f5b3053 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -426,8 +426,11 @@ void SoundManager::checkVoices() { void SoundManager::LOAD_MSAMPLE(int mwavIndex, const Common::String &file) { if (!Mwav[mwavIndex]._active) { Common::File f; - if (!f.open(file)) - error("Could not open %s for reading", file.c_str()); + if (!f.open(file)) { + // Fallback from WAV to APC... + if (!f.open(setExtension(file, ".APC"))) + error("Could not open %s for reading", file.c_str()); + } Mwav[mwavIndex]._audioStream = makeSoundStream(f.readStream(f.size())); Mwav[mwavIndex]._active = true; @@ -722,8 +725,11 @@ bool SoundManager::DEL_SAMPLE_SDL(int wavIndex) { bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffset, size_t entryLength, SwavItem &item) { Common::File f; - if (!f.open(filename)) - error("Could not open %s for reading", filename.c_str()); + if (!f.open(filename)) { + // Fallback from WAV to APC... + if (!f.open(setExtension(filename, ".APC"))) + error("Could not open %s for reading", filename.c_str()); + } f.seek(fileOffset); item._audioStream = makeSoundStream(f.readStream((entryLength == 0) ? f.size() : entryLength)); @@ -836,4 +842,15 @@ Audio::RewindableAudioStream *SoundManager::makeSoundStream(Common::SeekableRead return Audio::makeWAVStream(stream, DisposeAfterUse::YES); } +// Blatant rip from gob engine. Hi DrMcCoy! +Common::String SoundManager::setExtension(const Common::String &str, const Common::String &ext) { + if (str.empty()) + return str; + + const char *dot = strrchr(str.c_str(), '.'); + if (dot) + return Common::String(str.c_str(), dot - str.c_str()) + ext; + + return str + ext; +} } // End of namespace Hopkins -- cgit v1.2.3 From a645f876c34501a088df0c945746e80ec1ac51fa Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 6 Dec 2012 07:49:55 +0100 Subject: HOPKINS: Remove CARD_SB variable. Sound card is always present. --- engines/hopkins/sound.cpp | 100 +++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 58 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 6b2f5b3053..8ffe5a4f32 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -88,8 +88,6 @@ SoundManager::SoundManager() { old_music = 0; MOD_FLAG = false; - CARD_SB = true; - for (int i = 0; i < VOICE_COUNT; ++i) Common::fill((byte *)&Voice[i], (byte *)&Voice[i] + sizeof(VoiceItem), 0); for (int i = 0; i < SWAV_COUNT; ++i) @@ -111,7 +109,7 @@ void SoundManager::WSOUND_INIT() { } void SoundManager::VERIF_SOUND() { - if (CARD_SB && !SOUNDOFF && SOUND_FLAG) { + if (!SOUNDOFF && SOUND_FLAG) { if (!VOICE_STAT(1)) { STOP_VOICE(1); DEL_NWAV(SOUND_NUM); @@ -203,7 +201,7 @@ void SoundManager::PLAY_ANM_SOUND(int soundNumber) { } void SoundManager::WSOUND(int soundNumber) { - if (CARD_SB && (old_music != soundNumber || !MOD_FLAG)) { + if (old_music != soundNumber || !MOD_FLAG) { if (MOD_FLAG == 1) WSOUND_OFF(); if (soundNumber == 1) @@ -273,26 +271,24 @@ void SoundManager::WSOUND(int soundNumber) { } void SoundManager::WSOUND_OFF() { - if (CARD_SB) { - STOP_VOICE(0); - STOP_VOICE(1); - STOP_VOICE(2); - if (_vm->_soundManager.SOUND_FLAG) - DEL_NWAV(SOUND_NUM); + STOP_VOICE(0); + STOP_VOICE(1); + STOP_VOICE(2); + if (_vm->_soundManager.SOUND_FLAG) + DEL_NWAV(SOUND_NUM); - for (int i = 1; i <= 48; ++i) - DEL_SAMPLE_SDL(i); + for (int i = 1; i <= 48; ++i) + DEL_SAMPLE_SDL(i); - if (MOD_FLAG) { - STOP_MUSIC(); - DEL_MUSIC(); - MOD_FLAG = false; - } + if (MOD_FLAG) { + STOP_MUSIC(); + DEL_MUSIC(); + MOD_FLAG = false; } } void SoundManager::PLAY_MOD(const Common::String &file) { - if (CARD_SB && !MUSICOFF) { + if (!MUSICOFF) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPMUSIC, file); if (MOD_FLAG) { STOP_MUSIC(); @@ -459,7 +455,7 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { size_t catPos, catLen; fileNumber = voiceId; - if (!CARD_SB || VOICEOFF == 1) + if (VOICEOFF == 1) return false; if ((unsigned int)(voiceMode - 1) <= 1 @@ -569,20 +565,18 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { } void SoundManager::DEL_SAMPLE(int soundIndex) { - if (CARD_SB) { - if (VOICE_STAT(1) == 1) - STOP_VOICE(1); - if (VOICE_STAT(2) == 2) - STOP_VOICE(2); - if (VOICE_STAT(3) == 3) - STOP_VOICE(3); - DEL_SAMPLE_SDL(soundIndex); - SOUND[soundIndex]._active = false; - } + if (VOICE_STAT(1) == 1) + STOP_VOICE(1); + if (VOICE_STAT(2) == 2) + STOP_VOICE(2); + if (VOICE_STAT(3) == 3) + STOP_VOICE(3); + DEL_SAMPLE_SDL(soundIndex); + SOUND[soundIndex]._active = false; } void SoundManager::PLAY_SOUND(const Common::String &file) { - if (CARD_SB && !SOUNDOFF) { + if (!SOUNDOFF) { if (SOUND_FLAG) DEL_NWAV(SOUND_NUM); LOAD_NWAV(file, 1); @@ -591,11 +585,9 @@ void SoundManager::PLAY_SOUND(const Common::String &file) { } void SoundManager::PLAY_SOUND2(const Common::String &file) { - if (CARD_SB) { - if (!SOUNDOFF) { - LOAD_NWAV(file, 1); - PLAY_NWAV(1); - } + if (!SOUNDOFF) { + LOAD_NWAV(file, 1); + PLAY_NWAV(1); } } @@ -612,15 +604,13 @@ void SoundManager::MODSetMusicVolume(int volume) { } void SoundManager::CHARGE_SAMPLE(int wavIndex, const Common::String &file) { - if (CARD_SB) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); - LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 0); - SOUND[wavIndex]._active = true; - } + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); + LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 0); + SOUND[wavIndex]._active = true; } void SoundManager::PLAY_SAMPLE(int wavIndex, int voiceMode) { - if (CARD_SB && !SOUNDOFF && SOUND[wavIndex]._active) { + if (!SOUNDOFF && SOUND[wavIndex]._active) { if (SOUND_FLAG) DEL_NWAV(SOUND_NUM); if (voiceMode == 5) { @@ -647,7 +637,7 @@ void SoundManager::PLAY_SAMPLE(int wavIndex, int voiceMode) { } void SoundManager::PLAY_SAMPLE2(int idx) { - if (CARD_SB && !SOUNDOFF && SOUND[idx]._active) { + if (!SOUNDOFF && SOUND[idx]._active) { if (SOUND_FLAG) DEL_NWAV(SOUND_NUM); if (VOICE_STAT(1) == 1) @@ -657,13 +647,11 @@ void SoundManager::PLAY_SAMPLE2(int idx) { } void SoundManager::LOAD_WAV(const Common::String &file, int wavIndex) { - if (CARD_SB) - LOAD_NWAV(file, wavIndex); + LOAD_NWAV(file, wavIndex); } void SoundManager::PLAY_WAV(int wavIndex) { - if (CARD_SB) - PLAY_NWAV(wavIndex); + PLAY_NWAV(wavIndex); } int SoundManager::VOICE_STAT(int voiceIndex) { @@ -748,14 +736,12 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename } void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { - if (CARD_SB) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); - LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 1); - } + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); + LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 1); } void SoundManager::PLAY_NWAV(int wavIndex) { - if (CARD_SB && !SOUND_FLAG && !SOUNDOFF) { + if (!SOUND_FLAG && !SOUNDOFF) { SOUND_FLAG = true; SOUND_NUM = wavIndex; PLAY_SAMPLE_SDL(1, wavIndex); @@ -763,14 +749,12 @@ void SoundManager::PLAY_NWAV(int wavIndex) { } void SoundManager::DEL_NWAV(int wavIndex) { - if (CARD_SB) { - if (DEL_SAMPLE_SDL(wavIndex)) { - if (VOICE_STAT(1) == 1) - STOP_VOICE(1); + if (DEL_SAMPLE_SDL(wavIndex)) { + if (VOICE_STAT(1) == 1) + STOP_VOICE(1); - SOUND_NUM = 0; - SOUND_FLAG = false; - } + SOUND_NUM = 0; + SOUND_FLAG = false; } } -- cgit v1.2.3 From e10f98fa5bafd762316c890b6ea71253c04bd4e3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 6 Dec 2012 08:12:00 +0100 Subject: HOPKINS: Add fallback to APC for dialogs --- engines/hopkins/sound.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 8ffe5a4f32..37ac7c4e2a 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -512,9 +512,9 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { prefix = "OF"; } - filename = Common::String::format("%s%d.WAV", prefix.c_str(), fileNumber); + filename = Common::String::format("%s%d", prefix.c_str(), fileNumber); - if (!_vm->_fileManager.RECHERCHE_CAT(filename, 9)) { + if (!_vm->_fileManager.RECHERCHE_CAT(filename + ".WAV", 9)) { if (_vm->_globals.FR == 1) _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VFR.RES"); if (!_vm->_globals.FR) @@ -524,11 +524,23 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { catPos = _vm->_globals.CAT_POSI; catLen = _vm->_globals.CAT_TAILLE; - } else { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename); - - if (!f.exists(_vm->_globals.NFICHIER)) - return false; + } else if (!_vm->_fileManager.RECHERCHE_CAT(filename + ".APC", 9)) { + if (_vm->_globals.FR == 1) + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VFR.RES"); + if (!_vm->_globals.FR) + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VAN.RES"); + if (_vm->_globals.FR == 2) + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VES.RES"); + + catPos = _vm->_globals.CAT_POSI; + catLen = _vm->_globals.CAT_TAILLE; + } else { + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename + ".WAV"); + if (!f.exists(_vm->_globals.NFICHIER)) { + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename + ".APC"); + if (!f.exists(_vm->_globals.NFICHIER)) + return false; + } catPos = 0; catLen = 0; -- cgit v1.2.3 From 91e44d8e21bb2e93cdf030823c0f0d6d4022a366 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Dec 2012 22:44:00 +1100 Subject: HOPKINS: Apply first set of memory leak fixes --- engines/hopkins/sound.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 37ac7c4e2a..4030fe0872 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -99,6 +99,12 @@ SoundManager::SoundManager() { Common::fill((byte *)&Music, (byte *)&Music + sizeof(MusicItem), 0); } +SoundManager::~SoundManager() { + STOP_MUSIC(); + DEL_MUSIC(); + MOD_FLAG = false; +} + void SoundManager::setParent(HopkinsEngine *vm) { _vm = vm; SPECIAL_SOUND = 0; -- cgit v1.2.3 From 706e1584fafb417056f404e147a6e3c86a698723 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 8 Dec 2012 20:02:33 +0100 Subject: HOPKINS: Refactor runWin95Demo and PLAY_ANM_SOUND --- engines/hopkins/sound.cpp | 61 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 4030fe0872..14a3b9d028 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -157,51 +157,54 @@ void SoundManager::LOAD_ANM_SOUND() { void SoundManager::PLAY_ANM_SOUND(int soundNumber) { if (!_vm->_globals.CENSURE && SPECIAL_SOUND == 2) { - if (soundNumber == 20) + switch (soundNumber) { + case 20: PLAY_SAMPLE2(5); - if (soundNumber == 57) - PLAY_SAMPLE2(1); - if (soundNumber == 63) - PLAY_SAMPLE2(1); - if (soundNumber == 69) + break; + case 57: + case 63: + case 69: PLAY_SAMPLE2(1); - if (soundNumber == 75) + break; + case 75: PLAY_SAMPLE2(2); - if (soundNumber == 109) + break; + case 109: PLAY_SAMPLE2(3); - if (soundNumber == 122) + break; + case 122: PLAY_SAMPLE2(4); - } - if (SPECIAL_SOUND == 1 && soundNumber == 17) + break; + } + } else if (SPECIAL_SOUND == 1 && soundNumber == 17) PLAY_SOUND("SOUND42.WAV"); - if (SPECIAL_SOUND == 199 && soundNumber == 72) + else if (SPECIAL_SOUND == 5 && soundNumber == 19) PLAY_WAV(1); - if (SPECIAL_SOUND == 198 && soundNumber == 15) + else if (SPECIAL_SOUND == 14 && soundNumber == 625) PLAY_WAV(1); - if (SPECIAL_SOUND == 16 && soundNumber == 25) + else if (SPECIAL_SOUND == 16 && soundNumber == 25) PLAY_WAV(1); - if (SPECIAL_SOUND == 14 && soundNumber == 625) + else if (SPECIAL_SOUND == 17) { + if (soundNumber == 6) + PLAY_SAMPLE2(1); + else if (soundNumber == 14) + PLAY_SAMPLE2(2); + else if (soundNumber == 67) + PLAY_SAMPLE2(3); + } else if (SPECIAL_SOUND == 198 && soundNumber == 15) PLAY_WAV(1); - if (SPECIAL_SOUND == 208 && soundNumber == 40) + else if (SPECIAL_SOUND == 199 && soundNumber == 72) PLAY_WAV(1); - if (SPECIAL_SOUND == 210 && soundNumber == 2) + else if (SPECIAL_SOUND == 208 && soundNumber == 40) PLAY_WAV(1); - if (SPECIAL_SOUND == 211 && soundNumber == 22) + else if (SPECIAL_SOUND == 210 && soundNumber == 2) PLAY_WAV(1); - if (SPECIAL_SOUND == 5 && soundNumber == 19) + else if (SPECIAL_SOUND == 211 && soundNumber == 22) PLAY_WAV(1); - if (SPECIAL_SOUND == 17) { - if (soundNumber == 6) - PLAY_SAMPLE2(1); - if (soundNumber == 14) - PLAY_SAMPLE2(2); - if (soundNumber == 67) - PLAY_SAMPLE2(3); - } - if (SPECIAL_SOUND == 229) { + else if (SPECIAL_SOUND == 229) { if (soundNumber == 15) PLAY_WAV(1); - if (soundNumber == 91) + else if (soundNumber == 91) PLAY_WAV(2); } } -- cgit v1.2.3 From 0e1eeaa5f14ce8fdc76660578a720835d8072a5c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 8 Dec 2012 20:19:14 +0100 Subject: HOPKINS: Some more refactoring --- engines/hopkins/sound.cpp | 152 ++++++++++++++++++++++++++++++---------------- 1 file changed, 99 insertions(+), 53 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 14a3b9d028..546a792b54 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -124,34 +124,45 @@ void SoundManager::VERIF_SOUND() { } void SoundManager::LOAD_ANM_SOUND() { - if (SPECIAL_SOUND == 200) - VOICE_MIX(682, 1); - if (SPECIAL_SOUND == 199) - LOAD_WAV("SOUND22.WAV", 1); - if (SPECIAL_SOUND == 198) - LOAD_WAV("SOUND3.WAV", 1); - if (SPECIAL_SOUND == 16) - LOAD_WAV("SOUND16.WAV", 1); - if (SPECIAL_SOUND == 14) - LOAD_WAV("SOUND14.WAV", 1); - if (SPECIAL_SOUND == 208) - LOAD_WAV("SOUND77.WAV", 1); - if (SPECIAL_SOUND == 210) - LOAD_WAV("SOUND78.WAV", 1); - if (SPECIAL_SOUND == 211) - LOAD_WAV("SOUND78.WAV", 1); - if (SPECIAL_SOUND == 5) - LOAD_WAV("CRIE.WAV", 1); - if (SPECIAL_SOUND == 2) { + switch (SPECIAL_SOUND) { + case 2: CHARGE_SAMPLE(5, "mitra1.wav"); CHARGE_SAMPLE(1, "tir2.wav"); CHARGE_SAMPLE(2, "sound6.wav"); CHARGE_SAMPLE(3, "sound5.WAV"); CHARGE_SAMPLE(4, "sound4.WAV"); - } - if (SPECIAL_SOUND == 229) { + break; + case 5: + LOAD_WAV("CRIE.WAV", 1); + break; + case 14: + LOAD_WAV("SOUND14.WAV", 1); + break; + case 16: + LOAD_WAV("SOUND16.WAV", 1); + break; + case 198: + LOAD_WAV("SOUND3.WAV", 1); + break; + case 199: + LOAD_WAV("SOUND22.WAV", 1); + break; + case 200: + VOICE_MIX(682, 1); + break; + case 208: + LOAD_WAV("SOUND77.WAV", 1); + break; + case 210: + LOAD_WAV("SOUND78.WAV", 1); + break; + case 211: + LOAD_WAV("SOUND78.WAV", 1); + break; + case 229: LOAD_WAV("SOUND80.WAV", 1); LOAD_WAV("SOUND82.WAV", 2); + break; } } @@ -213,68 +224,103 @@ void SoundManager::WSOUND(int soundNumber) { if (old_music != soundNumber || !MOD_FLAG) { if (MOD_FLAG == 1) WSOUND_OFF(); - if (soundNumber == 1) + + switch (soundNumber) { + case 1: PLAY_MOD("appar"); - if (soundNumber == 2) + break; + case 2: PLAY_MOD("ville"); - if (soundNumber == 3) + break; + case 3: PLAY_MOD("Rock"); - if (soundNumber == 4) + break; + case 4: PLAY_MOD("polic"); - if (soundNumber == 5) + break; + case 5: PLAY_MOD("deep"); - if (soundNumber == 6) + break; + case 6: PLAY_MOD("purga"); - if (soundNumber == 12) - PLAY_MOD("purg2"); - if (soundNumber == 7) + break; + case 7: PLAY_MOD("rivie"); - if (soundNumber == 8) + break; + case 8: PLAY_MOD("SUSPE"); - if (soundNumber == 9) + break; + case 9: PLAY_MOD("labo"); - if (soundNumber == 10) + break; + case 10: PLAY_MOD("cadav"); - if (soundNumber == 11) + break; + case 11: PLAY_MOD("caban"); - if (soundNumber == 13) + break; + case 12: + PLAY_MOD("purg2"); + break; + case 13: PLAY_MOD("foret"); - if (soundNumber == 14) + break; + case 14: PLAY_MOD("ile"); - if (soundNumber == 15) + break; + case 15: PLAY_MOD("ile2"); - if (soundNumber == 16) + break; + case 16: PLAY_MOD("hopki"); - if (soundNumber == 17) + break; + case 17: PLAY_MOD("peur"); - if (soundNumber == 18) + break; + case 18: PLAY_MOD("peur"); - if (soundNumber == 19) + break; + case 19: PLAY_MOD("BASE"); - if (soundNumber == 20) + break; + case 20: PLAY_MOD("cada2"); - if (soundNumber == 21) + break; + case 21: PLAY_MOD("usine"); - if (soundNumber == 22) + break; + case 22: PLAY_MOD("chien"); - if (soundNumber == 23) + break; + case 23: PLAY_MOD("coeur"); - if (soundNumber == 24) + break; + case 24: PLAY_MOD("stand"); - if (soundNumber == 25) + break; + case 25: PLAY_MOD("ocean"); - if (soundNumber == 26) + break; + case 26: PLAY_MOD("base3"); - if (soundNumber == 27) + break; + case 27: PLAY_MOD("gloop"); - if (soundNumber == 28) + break; + case 28: PLAY_MOD("cant"); - if (soundNumber == 29) + break; + case 29: PLAY_MOD("feel"); - if (soundNumber == 30) + break; + case 30: PLAY_MOD("lost"); - if (soundNumber == 31) + break; + case 31: PLAY_MOD("tobac"); + break; + } + old_music = soundNumber; } } -- cgit v1.2.3 From fedf2ca70f7d38e0b49adec8b61b0a6b464b9929 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Dec 2012 20:38:28 +1100 Subject: HOPKINS: Bugfix for sounds in the Breakout game --- engines/hopkins/sound.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 546a792b54..1f7e6a9ee0 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -840,6 +840,7 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { int volume = (voiceIndex == 2) ? VOICEVOL * 255 / 16 : SOUNDVOL * 255 / 16; // Start the voice playing + Swav[wavIndex]._audioStream->rewind(); _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Swav[wavIndex]._soundHandle, Swav[wavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); } -- cgit v1.2.3 From 867cbbf4ff6ddfca826724a7ff74f44a06e8d044 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 9 Dec 2012 20:22:12 +0100 Subject: HOPKINS: Refactor fileManager --- engines/hopkins/sound.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 1f7e6a9ee0..6c01051d60 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -344,7 +344,7 @@ void SoundManager::WSOUND_OFF() { void SoundManager::PLAY_MOD(const Common::String &file) { if (!MUSICOFF) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPMUSIC, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPMUSIC, file); if (MOD_FLAG) { STOP_MUSIC(); DEL_MUSIC(); @@ -569,30 +569,30 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { filename = Common::String::format("%s%d", prefix.c_str(), fileNumber); - if (!_vm->_fileManager.RECHERCHE_CAT(filename + ".WAV", 9)) { + if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { if (_vm->_globals.FR == 1) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VFR.RES"); - if (!_vm->_globals.FR) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VAN.RES"); - if (_vm->_globals.FR == 2) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VES.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); + else if (!_vm->_globals.FR) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); + else if (_vm->_globals.FR == 2) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); catPos = _vm->_globals.CAT_POSI; catLen = _vm->_globals.CAT_TAILLE; - } else if (!_vm->_fileManager.RECHERCHE_CAT(filename + ".APC", 9)) { + } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { if (_vm->_globals.FR == 1) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VFR.RES"); - if (!_vm->_globals.FR) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VAN.RES"); - if (_vm->_globals.FR == 2) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VES.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); + else if (!_vm->_globals.FR) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); + else if (_vm->_globals.FR == 2) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); catPos = _vm->_globals.CAT_POSI; catLen = _vm->_globals.CAT_TAILLE; } else { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename + ".WAV"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".WAV"); if (!f.exists(_vm->_globals.NFICHIER)) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename + ".APC"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".APC"); if (!f.exists(_vm->_globals.NFICHIER)) return false; } @@ -671,7 +671,7 @@ void SoundManager::MODSetMusicVolume(int volume) { } void SoundManager::CHARGE_SAMPLE(int wavIndex, const Common::String &file) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 0); SOUND[wavIndex]._active = true; } @@ -803,7 +803,7 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename } void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 1); } -- cgit v1.2.3 From 742b9e4750658615e57690aff228580edfd5c8b0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 9 Dec 2012 22:35:59 +0100 Subject: HOPKINS: Rename animationManager functions --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 6c01051d60..d42590f593 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -166,7 +166,7 @@ void SoundManager::LOAD_ANM_SOUND() { } } -void SoundManager::PLAY_ANM_SOUND(int soundNumber) { +void SoundManager::playAnim_SOUND(int soundNumber) { if (!_vm->_globals.CENSURE && SPECIAL_SOUND == 2) { switch (soundNumber) { case 20: -- cgit v1.2.3 From 299fbfc7c7558cd8275b86ef746ba73ea5ecbee2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 11 Dec 2012 01:53:50 +0100 Subject: HOPKINS: Start renaming EventsManager functions --- engines/hopkins/sound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index d42590f593..db1b072e95 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -613,10 +613,10 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { do { if (SPECIAL_SOUND != 4 && !VBL_MERDE) _vm->_eventsManager.VBL(); - if (_vm->_eventsManager.BMOUSE()) + if (_vm->_eventsManager.getMouseButton()) break; _vm->_eventsManager.CONTROLE_MES(); - if (_vm->_eventsManager.ESC_KEY) + if (_vm->_eventsManager._escKeyFl) break; if (!VOICE_STAT(2)) breakFlag = true; @@ -626,7 +626,7 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { STOP_VOICE(2); DEL_SAMPLE_SDL(20); MUSICVOL = oldMusicVol; - _vm->_eventsManager.ESC_KEY = false; + _vm->_eventsManager._escKeyFl = false; VBL_MERDE = 0; return true; } -- cgit v1.2.3 From d274441e12e7112620747a5129bb2af77cdb852f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 11 Dec 2012 08:31:07 +0100 Subject: HOPKINS: Some more renaming --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index db1b072e95..01a977cfe4 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -615,7 +615,7 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { _vm->_eventsManager.VBL(); if (_vm->_eventsManager.getMouseButton()) break; - _vm->_eventsManager.CONTROLE_MES(); + _vm->_eventsManager.refreshEvents(); if (_vm->_eventsManager._escKeyFl) break; if (!VOICE_STAT(2)) -- cgit v1.2.3 From 95025312a7c3b184fef3818ece1f1d55b7fb19d1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 14 Dec 2012 01:49:22 +0100 Subject: HOPKINS: Janitorial - Remove trailing space and double semi columns --- engines/hopkins/sound.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 01a977cfe4..209215bba6 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -334,7 +334,7 @@ void SoundManager::WSOUND_OFF() { for (int i = 1; i <= 48; ++i) DEL_SAMPLE_SDL(i); - + if (MOD_FLAG) { STOP_MUSIC(); DEL_MUSIC(); @@ -450,12 +450,12 @@ void SoundManager::checkMusic() { if (mwavIndex == -1) { Music._currentIndex = 0; mwavIndex = Music._mwavIndexes[Music._currentIndex]; - } + } int volume = MUSICVOL * 255 / 16; Mwav[mwavIndex]._audioStream->rewind(); - _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Mwav[mwavIndex]._soundHandle, + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Mwav[mwavIndex]._soundHandle, Mwav[mwavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); } } @@ -501,9 +501,9 @@ void SoundManager::DEL_MSAMPLE(int mwavIndex) { } bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { - int fileNumber; - int oldMusicVol; - bool breakFlag; + int fileNumber; + int oldMusicVol; + bool breakFlag; Common::String prefix; Common::String filename; Common::File f; @@ -553,7 +553,7 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { || voiceId == 632 || voiceId == 645)) fileNumber = 684; - + if ((unsigned int)(voiceMode - 1) <= 1) { prefix = "DF"; } @@ -568,7 +568,7 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { } filename = Common::String::format("%s%d", prefix.c_str(), fileNumber); - + if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { if (_vm->_globals.FR == 1) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); @@ -589,7 +589,7 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { catPos = _vm->_globals.CAT_POSI; catLen = _vm->_globals.CAT_TAILLE; - } else { + } else { _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".WAV"); if (!f.exists(_vm->_globals.NFICHIER)) { _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".APC"); @@ -751,7 +751,7 @@ void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) { Swav[20]._active = true; } - + void SoundManager::PLAY_VOICE_SDL() { if (!Swav[20]._active) error("Bad handle"); @@ -836,12 +836,12 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { Voice[voiceIndex]._status = 1; Voice[voiceIndex].field14 = 4; Voice[voiceIndex]._wavIndex = wavIndex; - + int volume = (voiceIndex == 2) ? VOICEVOL * 255 / 16 : SOUNDVOL * 255 / 16; // Start the voice playing Swav[wavIndex]._audioStream->rewind(); - _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Swav[wavIndex]._soundHandle, + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Swav[wavIndex]._soundHandle, Swav[wavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); } @@ -889,9 +889,9 @@ void SoundManager::updateScummVMSoundSettings() { Audio::RewindableAudioStream *SoundManager::makeSoundStream(Common::SeekableReadStream *stream) { if (_vm->getPlatform() == Common::kPlatformWindows) - return Audio::makeAPCStream(stream, DisposeAfterUse::YES); + return Audio::makeAPCStream(stream, DisposeAfterUse::YES); else - return Audio::makeWAVStream(stream, DisposeAfterUse::YES); + return Audio::makeWAVStream(stream, DisposeAfterUse::YES); } // Blatant rip from gob engine. Hi DrMcCoy! -- cgit v1.2.3 From 076546d41d1454c87317b5e53c2b322865331d92 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 19 Dec 2012 08:00:22 +0100 Subject: HOPKINS: More renaming --- engines/hopkins/sound.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 209215bba6..1e24346f60 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -577,8 +577,8 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { else if (_vm->_globals.FR == 2) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); - catPos = _vm->_globals.CAT_POSI; - catLen = _vm->_globals.CAT_TAILLE; + catPos = _vm->_globals._catalogPos; + catLen = _vm->_globals._catalogSize; } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { if (_vm->_globals.FR == 1) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); @@ -587,8 +587,8 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { else if (_vm->_globals.FR == 2) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); - catPos = _vm->_globals.CAT_POSI; - catLen = _vm->_globals.CAT_TAILLE; + catPos = _vm->_globals._catalogPos; + catLen = _vm->_globals._catalogSize; } else { _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".WAV"); if (!f.exists(_vm->_globals.NFICHIER)) { -- cgit v1.2.3 From 1f987a91ae9e7044fd1f6764d1232109028a8bd8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Dec 2012 19:08:23 +0100 Subject: HOPKINS: Some more renaming. Remove 2 useless palettes --- engines/hopkins/sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 1e24346f60..22c4f04f3b 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -148,7 +148,7 @@ void SoundManager::LOAD_ANM_SOUND() { LOAD_WAV("SOUND22.WAV", 1); break; case 200: - VOICE_MIX(682, 1); + mixVoice(682, 1); break; case 208: LOAD_WAV("SOUND77.WAV", 1); @@ -500,7 +500,7 @@ void SoundManager::DEL_MSAMPLE(int mwavIndex) { } } -bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { +bool SoundManager::mixVoice(int voiceId, int voiceMode) { int fileNumber; int oldMusicVol; bool breakFlag; -- cgit v1.2.3 From 8cce2721177422a65e73c9f178746403c801f242 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Dec 2012 01:43:37 +0100 Subject: HOPKINS: Some more renaming --- engines/hopkins/sound.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 22c4f04f3b..2ed7482084 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -126,11 +126,11 @@ void SoundManager::VERIF_SOUND() { void SoundManager::LOAD_ANM_SOUND() { switch (SPECIAL_SOUND) { case 2: - CHARGE_SAMPLE(5, "mitra1.wav"); - CHARGE_SAMPLE(1, "tir2.wav"); - CHARGE_SAMPLE(2, "sound6.wav"); - CHARGE_SAMPLE(3, "sound5.WAV"); - CHARGE_SAMPLE(4, "sound4.WAV"); + loadSample(5, "mitra1.wav"); + loadSample(1, "tir2.wav"); + loadSample(2, "sound6.wav"); + loadSample(3, "sound5.WAV"); + loadSample(4, "sound4.WAV"); break; case 5: LOAD_WAV("CRIE.WAV", 1); @@ -670,7 +670,7 @@ void SoundManager::MODSetMusicVolume(int volume) { // No implementatoin needed } -void SoundManager::CHARGE_SAMPLE(int wavIndex, const Common::String &file) { +void SoundManager::loadSample(int wavIndex, const Common::String &file) { _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 0); SOUND[wavIndex]._active = true; -- cgit v1.2.3 From 8c1f422bd68fe23c4e73ba3d3b13de028c905134 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Dec 2012 11:36:53 +0100 Subject: HOPKINS: Remove magic values used to check language, some renaming and refactoring --- engines/hopkins/sound.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 2ed7482084..e6e17e8521 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -80,8 +80,8 @@ SoundManager::SoundManager() { OLD_VOICEVOL = 0; SOUNDOFF = true; MUSICOFF = true; - VOICEOFF = true; - TEXTOFF = false; + _voiceOffFl = true; + _textOffFl = false; SOUND_FLAG = false; VBL_MERDE = false; SOUND_NUM = 0; @@ -510,7 +510,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { size_t catPos, catLen; fileNumber = voiceId; - if (VOICEOFF == 1) + if (_voiceOffFl) return false; if ((unsigned int)(voiceMode - 1) <= 1 @@ -570,21 +570,21 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { filename = Common::String::format("%s%d", prefix.c_str(), fileNumber); if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { - if (_vm->_globals.FR == 1) + if (_vm->_globals._language == LANG_FR) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); - else if (!_vm->_globals.FR) + else if (_vm->_globals._language == LANG_EN) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); - else if (_vm->_globals.FR == 2) + else if (_vm->_globals._language == LANG_SP) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { - if (_vm->_globals.FR == 1) + if (_vm->_globals._language == LANG_FR) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); - else if (!_vm->_globals.FR) + else if (_vm->_globals._language == LANG_EN) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); - else if (_vm->_globals.FR == 2) + else if (_vm->_globals._language == LANG_SP) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); catPos = _vm->_globals._catalogPos; @@ -853,7 +853,7 @@ void SoundManager::syncSoundSettings() { // Update the mute settings MUSICOFF = muteAll || (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute")); SOUNDOFF = muteAll || (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute")); - VOICEOFF = muteAll || (ConfMan.hasKey("speech_mute") && ConfMan.getBool("speech_mute")); + _voiceOffFl = muteAll || (ConfMan.hasKey("speech_mute") && ConfMan.getBool("speech_mute")); // Update the volume levels MUSICVOL = MIN(255, ConfMan.getInt("music_volume")) * 16 / 255; @@ -875,10 +875,10 @@ void SoundManager::syncSoundSettings() { } void SoundManager::updateScummVMSoundSettings() { - ConfMan.setBool("mute", MUSICOFF && SOUNDOFF && VOICEOFF); + ConfMan.setBool("mute", MUSICOFF && SOUNDOFF && _voiceOffFl); ConfMan.setBool("music_mute", MUSICOFF); ConfMan.setBool("sfx_mute", SOUNDOFF); - ConfMan.setBool("speech_mute", VOICEOFF); + ConfMan.setBool("speech_mute", _voiceOffFl); ConfMan.setInt("music_volume", MUSICVOL * 255 / 16); ConfMan.setInt("sfx_volume", SOUNDVOL * 255 / 16); -- cgit v1.2.3 From f89001d75c73750a67ff6c8bc392c5b526fb803c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Dec 2012 22:48:11 +0100 Subject: HOPKINS: Renaming --- engines/hopkins/sound.cpp | 115 +++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 58 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e6e17e8521..66de0356ac 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -78,11 +78,11 @@ SoundManager::SoundManager() { OLD_SOUNDVOL = 0; OLD_MUSICVOL = 0; OLD_VOICEVOL = 0; - SOUNDOFF = true; - MUSICOFF = true; + _soundOffFl = true; + _musicOff = true; _voiceOffFl = true; _textOffFl = false; - SOUND_FLAG = false; + _soundFl = false; VBL_MERDE = false; SOUND_NUM = 0; old_music = 0; @@ -100,8 +100,8 @@ SoundManager::SoundManager() { } SoundManager::~SoundManager() { - STOP_MUSIC(); - DEL_MUSIC(); + stopMusic(); + delMusic(); MOD_FLAG = false; } @@ -115,7 +115,7 @@ void SoundManager::WSOUND_INIT() { } void SoundManager::VERIF_SOUND() { - if (!SOUNDOFF && SOUND_FLAG) { + if (!_soundOffFl && _soundFl) { if (!VOICE_STAT(1)) { STOP_VOICE(1); DEL_NWAV(SOUND_NUM); @@ -188,13 +188,13 @@ void SoundManager::playAnim_SOUND(int soundNumber) { break; } } else if (SPECIAL_SOUND == 1 && soundNumber == 17) - PLAY_SOUND("SOUND42.WAV"); + playSound("SOUND42.WAV"); else if (SPECIAL_SOUND == 5 && soundNumber == 19) - PLAY_WAV(1); + playWav(1); else if (SPECIAL_SOUND == 14 && soundNumber == 625) - PLAY_WAV(1); + playWav(1); else if (SPECIAL_SOUND == 16 && soundNumber == 25) - PLAY_WAV(1); + playWav(1); else if (SPECIAL_SOUND == 17) { if (soundNumber == 6) PLAY_SAMPLE2(1); @@ -203,26 +203,26 @@ void SoundManager::playAnim_SOUND(int soundNumber) { else if (soundNumber == 67) PLAY_SAMPLE2(3); } else if (SPECIAL_SOUND == 198 && soundNumber == 15) - PLAY_WAV(1); + playWav(1); else if (SPECIAL_SOUND == 199 && soundNumber == 72) - PLAY_WAV(1); + playWav(1); else if (SPECIAL_SOUND == 208 && soundNumber == 40) - PLAY_WAV(1); + playWav(1); else if (SPECIAL_SOUND == 210 && soundNumber == 2) - PLAY_WAV(1); + playWav(1); else if (SPECIAL_SOUND == 211 && soundNumber == 22) - PLAY_WAV(1); + playWav(1); else if (SPECIAL_SOUND == 229) { if (soundNumber == 15) - PLAY_WAV(1); + playWav(1); else if (soundNumber == 91) - PLAY_WAV(2); + playWav(2); } } void SoundManager::WSOUND(int soundNumber) { if (old_music != soundNumber || !MOD_FLAG) { - if (MOD_FLAG == 1) + if (MOD_FLAG) WSOUND_OFF(); switch (soundNumber) { @@ -329,37 +329,37 @@ void SoundManager::WSOUND_OFF() { STOP_VOICE(0); STOP_VOICE(1); STOP_VOICE(2); - if (_vm->_soundManager.SOUND_FLAG) + if (_vm->_soundManager._soundFl) DEL_NWAV(SOUND_NUM); for (int i = 1; i <= 48; ++i) DEL_SAMPLE_SDL(i); if (MOD_FLAG) { - STOP_MUSIC(); - DEL_MUSIC(); + stopMusic(); + delMusic(); MOD_FLAG = false; } } void SoundManager::PLAY_MOD(const Common::String &file) { - if (!MUSICOFF) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPMUSIC, file); - if (MOD_FLAG) { - STOP_MUSIC(); - DEL_MUSIC(); - MOD_FLAG = false; - } - - LOAD_MUSIC(_vm->_globals.NFICHIER); - PLAY_MUSIC(); - MOD_FLAG = true; + if (_musicOff) + return; + _vm->_fileManager.constructFilename(_vm->_globals.HOPMUSIC, file); + if (MOD_FLAG) { + stopMusic(); + delMusic(); + MOD_FLAG = false; } + + loadMusic(_vm->_globals.NFICHIER); + playMusic(); + MOD_FLAG = true; } -void SoundManager::LOAD_MUSIC(const Common::String &file) { +void SoundManager::loadMusic(const Common::String &file) { if (Music._active) - DEL_MUSIC(); + delMusic(); Common::File f; Common::String filename = Common::String::format("%s.TWA", file.c_str()); @@ -392,7 +392,6 @@ void SoundManager::LOAD_MUSIC(const Common::String &file) { Music._mwavIndexes[destIndex++] = mwavIndex; } } while (!breakFlag); - f.close(); Music._active = true; @@ -400,17 +399,17 @@ void SoundManager::LOAD_MUSIC(const Common::String &file) { Music._currentIndex = -1; } -void SoundManager::PLAY_MUSIC() { +void SoundManager::playMusic() { if (Music._active) Music._isPlaying = true; } -void SoundManager::STOP_MUSIC() { +void SoundManager::stopMusic() { if (Music._active) Music._isPlaying = false; } -void SoundManager::DEL_MUSIC() { +void SoundManager::delMusic() { if (Music._active) { for (int i = 0; i < 50; ++i) { DEL_MSAMPLE(i); @@ -468,8 +467,8 @@ void SoundManager::checkVoices() { hasActiveVoice |= Voice[i]._status != 0; } - if (!hasActiveVoice && SOUND_FLAG) { - SOUND_FLAG = false; + if (!hasActiveVoice && _soundFl) { + _soundFl = false; SOUND_NUM = 0; } } @@ -603,7 +602,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { SDL_LVOICE(catPos, catLen); oldMusicVol = MUSICVOL; - if (!MUSICOFF && MUSICVOL > 2) + if (!_musicOff && MUSICVOL > 2) MUSICVOL = (signed int)((long double)MUSICVOL - (long double)MUSICVOL / 100.0 * 45.0); PLAY_VOICE_SDL(); @@ -642,9 +641,9 @@ void SoundManager::DEL_SAMPLE(int soundIndex) { SOUND[soundIndex]._active = false; } -void SoundManager::PLAY_SOUND(const Common::String &file) { - if (!SOUNDOFF) { - if (SOUND_FLAG) +void SoundManager::playSound(const Common::String &file) { + if (!_soundOffFl) { + if (_soundFl) DEL_NWAV(SOUND_NUM); LOAD_NWAV(file, 1); PLAY_NWAV(1); @@ -652,7 +651,7 @@ void SoundManager::PLAY_SOUND(const Common::String &file) { } void SoundManager::PLAY_SOUND2(const Common::String &file) { - if (!SOUNDOFF) { + if (!_soundOffFl) { LOAD_NWAV(file, 1); PLAY_NWAV(1); } @@ -677,8 +676,8 @@ void SoundManager::loadSample(int wavIndex, const Common::String &file) { } void SoundManager::PLAY_SAMPLE(int wavIndex, int voiceMode) { - if (!SOUNDOFF && SOUND[wavIndex]._active) { - if (SOUND_FLAG) + if (!_soundOffFl && SOUND[wavIndex]._active) { + if (_soundFl) DEL_NWAV(SOUND_NUM); if (voiceMode == 5) { if (VOICE_STAT(1) == 1) @@ -704,8 +703,8 @@ void SoundManager::PLAY_SAMPLE(int wavIndex, int voiceMode) { } void SoundManager::PLAY_SAMPLE2(int idx) { - if (!SOUNDOFF && SOUND[idx]._active) { - if (SOUND_FLAG) + if (!_soundOffFl && SOUND[idx]._active) { + if (_soundFl) DEL_NWAV(SOUND_NUM); if (VOICE_STAT(1) == 1) STOP_VOICE(1); @@ -717,7 +716,7 @@ void SoundManager::LOAD_WAV(const Common::String &file, int wavIndex) { LOAD_NWAV(file, wavIndex); } -void SoundManager::PLAY_WAV(int wavIndex) { +void SoundManager::playWav(int wavIndex) { PLAY_NWAV(wavIndex); } @@ -808,8 +807,8 @@ void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { } void SoundManager::PLAY_NWAV(int wavIndex) { - if (!SOUND_FLAG && !SOUNDOFF) { - SOUND_FLAG = true; + if (!_soundFl && !_soundOffFl) { + _soundFl = true; SOUND_NUM = wavIndex; PLAY_SAMPLE_SDL(1, wavIndex); } @@ -821,7 +820,7 @@ void SoundManager::DEL_NWAV(int wavIndex) { STOP_VOICE(1); SOUND_NUM = 0; - SOUND_FLAG = false; + _soundFl = false; } } @@ -851,8 +850,8 @@ void SoundManager::syncSoundSettings() { muteAll = ConfMan.getBool("mute"); // Update the mute settings - MUSICOFF = muteAll || (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute")); - SOUNDOFF = muteAll || (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute")); + _musicOff = muteAll || (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute")); + _soundOffFl = muteAll || (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute")); _voiceOffFl = muteAll || (ConfMan.hasKey("speech_mute") && ConfMan.getBool("speech_mute")); // Update the volume levels @@ -875,9 +874,9 @@ void SoundManager::syncSoundSettings() { } void SoundManager::updateScummVMSoundSettings() { - ConfMan.setBool("mute", MUSICOFF && SOUNDOFF && _voiceOffFl); - ConfMan.setBool("music_mute", MUSICOFF); - ConfMan.setBool("sfx_mute", SOUNDOFF); + ConfMan.setBool("mute", _musicOff && _soundOffFl && _voiceOffFl); + ConfMan.setBool("music_mute", _musicOff); + ConfMan.setBool("sfx_mute", _soundOffFl); ConfMan.setBool("speech_mute", _voiceOffFl); ConfMan.setInt("music_volume", MUSICVOL * 255 / 16); -- cgit v1.2.3 From 2b665c67cb85feec4e273162a38275f86d26f08e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Dec 2012 23:53:45 +0100 Subject: HOPKINS: Add MOD file support --- engines/hopkins/sound.cpp | 131 +++++++++++++++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 42 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 66de0356ac..87a588509f 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -28,6 +28,8 @@ #include "hopkins/sound.h" #include "hopkins/globals.h" #include "hopkins/hopkins.h" +#include "audio/audiostream.h" +#include "audio/mods/protracker.h" namespace Audio { @@ -75,9 +77,6 @@ SoundManager::SoundManager() { SOUNDVOL = 0; VOICEVOL = 0; MUSICVOL = 0; - OLD_SOUNDVOL = 0; - OLD_MUSICVOL = 0; - OLD_VOICEVOL = 0; _soundOffFl = true; _musicOff = true; _voiceOffFl = true; @@ -102,6 +101,7 @@ SoundManager::SoundManager() { SoundManager::~SoundManager() { stopMusic(); delMusic(); + _vm->_mixer->stopHandle(_modHandle); MOD_FLAG = false; } @@ -227,7 +227,10 @@ void SoundManager::WSOUND(int soundNumber) { switch (soundNumber) { case 1: - PLAY_MOD("appar"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("appart"); + else + PLAY_MOD("appar"); break; case 2: PLAY_MOD("ville"); @@ -236,31 +239,52 @@ void SoundManager::WSOUND(int soundNumber) { PLAY_MOD("Rock"); break; case 4: - PLAY_MOD("polic"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("police"); + else + PLAY_MOD("polic"); break; case 5: PLAY_MOD("deep"); break; case 6: - PLAY_MOD("purga"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("purgat"); + else + PLAY_MOD("purga"); break; case 7: - PLAY_MOD("rivie"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("riviere"); + else + PLAY_MOD("rivie"); break; case 8: - PLAY_MOD("SUSPE"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("SUSPENS"); + else + PLAY_MOD("SUSPE"); break; case 9: PLAY_MOD("labo"); break; case 10: - PLAY_MOD("cadav"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("cadavre"); + else + PLAY_MOD("cadav"); break; case 11: - PLAY_MOD("caban"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("cabane"); + else + PLAY_MOD("caban"); break; case 12: - PLAY_MOD("purg2"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("purgat2"); + else + PLAY_MOD("purg2"); break; case 13: PLAY_MOD("foret"); @@ -272,19 +296,28 @@ void SoundManager::WSOUND(int soundNumber) { PLAY_MOD("ile2"); break; case 16: - PLAY_MOD("hopki"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("hopkins"); + else + PLAY_MOD("hopki"); break; case 17: PLAY_MOD("peur"); break; case 18: - PLAY_MOD("peur"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("URAVOLGA"); + else + PLAY_MOD("peur"); break; case 19: PLAY_MOD("BASE"); break; case 20: - PLAY_MOD("cada2"); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + PLAY_MOD("cadavre2"); + else + PLAY_MOD("cada2"); break; case 21: PLAY_MOD("usine"); @@ -362,37 +395,48 @@ void SoundManager::loadMusic(const Common::String &file) { delMusic(); Common::File f; - Common::String filename = Common::String::format("%s.TWA", file.c_str()); - - if (!f.open(filename)) - error("Error opening file %s", filename.c_str()); + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) { + Common::String filename = Common::String::format("%s.MOD", file.c_str()); - char s[8]; - int destIndex = 0; - int mwavIndex; + if (!f.open(filename)) + error("Error opening file %s", filename.c_str()); - bool breakFlag = false; - do { - f.read(&s[0], 3); + Audio::AudioStream *modStream = Audio::makeProtrackerStream(&f); + _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_modHandle, modStream); - if (s[0] == 'x') { - // End of list reached - Music._mwavIndexes[destIndex] = -1; - breakFlag = true; - } else { - // Convert two digits to a number - s[2] = '\0'; - mwavIndex = atol(&s[0]); - - filename = Common::String::format("%s_%s.%s", file.c_str(), &s[0], - (_vm->getPlatform() == Common::kPlatformWindows) ? "APC" : "WAV"); - LOAD_MSAMPLE(mwavIndex, filename); - - assert(destIndex < MUSIC_WAVE_COUNT); - Music._mwavIndexes[destIndex++] = mwavIndex; - } - } while (!breakFlag); - f.close(); + } else { + Common::String filename = Common::String::format("%s.TWA", file.c_str()); + + if (!f.open(filename)) + error("Error opening file %s", filename.c_str()); + + char s[8]; + int destIndex = 0; + int mwavIndex; + + bool breakFlag = false; + do { + f.read(&s[0], 3); + + if (s[0] == 'x') { + // End of list reached + Music._mwavIndexes[destIndex] = -1; + breakFlag = true; + } else { + // Convert two digits to a number + s[2] = '\0'; + mwavIndex = atol(&s[0]); + + filename = Common::String::format("%s_%s.%s", file.c_str(), &s[0], + (_vm->getPlatform() == Common::kPlatformWindows) ? "APC" : "WAV"); + LOAD_MSAMPLE(mwavIndex, filename); + + assert(destIndex < MUSIC_WAVE_COUNT); + Music._mwavIndexes[destIndex++] = mwavIndex; + } + } while (!breakFlag); + f.close(); + } Music._active = true; Music._isPlaying = false; @@ -428,6 +472,9 @@ void SoundManager::checkSounds() { } void SoundManager::checkMusic() { + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + return; + if (Music._active && Music._isPlaying) { int mwavIndex = Music._mwavIndexes[Music._currentIndex]; if (mwavIndex == -1) -- cgit v1.2.3 From 59e85997b3debece5e920d7612fe33ccc9931934 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 26 Dec 2012 00:31:42 +0100 Subject: HOPKINS: Load correct voice ressource file in BeOS and OS/2 versions --- engines/hopkins/sound.cpp | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 87a588509f..e742b50be9 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -117,7 +117,7 @@ void SoundManager::WSOUND_INIT() { void SoundManager::VERIF_SOUND() { if (!_soundOffFl && _soundFl) { if (!VOICE_STAT(1)) { - STOP_VOICE(1); + stopVoice(1); DEL_NWAV(SOUND_NUM); } } @@ -359,9 +359,9 @@ void SoundManager::WSOUND(int soundNumber) { } void SoundManager::WSOUND_OFF() { - STOP_VOICE(0); - STOP_VOICE(1); - STOP_VOICE(2); + stopVoice(0); + stopVoice(1); + stopVoice(2); if (_vm->_soundManager._soundFl) DEL_NWAV(SOUND_NUM); @@ -472,6 +472,7 @@ void SoundManager::checkSounds() { } void SoundManager::checkMusic() { + // OS2 and BeOS versions use MOD files. if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) return; @@ -616,7 +617,10 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { filename = Common::String::format("%s%d", prefix.c_str(), fileNumber); if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { - if (_vm->_globals._language == LANG_FR) + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "ENG_VOI.RES"); + // Win95 and Linux versions uses another set of names + else if (_vm->_globals._language == LANG_FR) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); else if (_vm->_globals._language == LANG_EN) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); @@ -626,7 +630,10 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { - if (_vm->_globals._language == LANG_FR) + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "ENG_VOI.RES"); + // Win95 and Linux versions uses another set of names + else if (_vm->_globals._language == LANG_FR) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); else if (_vm->_globals._language == LANG_EN) _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); @@ -669,7 +676,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { } while (!_vm->shouldQuit() && !breakFlag); - STOP_VOICE(2); + stopVoice(2); DEL_SAMPLE_SDL(20); MUSICVOL = oldMusicVol; _vm->_eventsManager._escKeyFl = false; @@ -679,11 +686,11 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { void SoundManager::DEL_SAMPLE(int soundIndex) { if (VOICE_STAT(1) == 1) - STOP_VOICE(1); + stopVoice(1); if (VOICE_STAT(2) == 2) - STOP_VOICE(2); + stopVoice(2); if (VOICE_STAT(3) == 3) - STOP_VOICE(3); + stopVoice(3); DEL_SAMPLE_SDL(soundIndex); SOUND[soundIndex]._active = false; } @@ -728,22 +735,22 @@ void SoundManager::PLAY_SAMPLE(int wavIndex, int voiceMode) { DEL_NWAV(SOUND_NUM); if (voiceMode == 5) { if (VOICE_STAT(1) == 1) - STOP_VOICE(1); + stopVoice(1); PLAY_SAMPLE_SDL(1, wavIndex); } if (voiceMode == 6) { if (VOICE_STAT(2) == 1) - STOP_VOICE(1); + stopVoice(1); PLAY_SAMPLE_SDL(2, wavIndex); } if (voiceMode == 7) { if (VOICE_STAT(3) == 1) - STOP_VOICE(1); + stopVoice(1); PLAY_SAMPLE_SDL(3, wavIndex); } if (voiceMode == 8) { if (VOICE_STAT(1) == 1) - STOP_VOICE(1); + stopVoice(1); PLAY_SAMPLE_SDL(1, wavIndex); } } @@ -754,7 +761,7 @@ void SoundManager::PLAY_SAMPLE2(int idx) { if (_soundFl) DEL_NWAV(SOUND_NUM); if (VOICE_STAT(1) == 1) - STOP_VOICE(1); + stopVoice(1); PLAY_SAMPLE_SDL(1, idx); } } @@ -771,13 +778,13 @@ int SoundManager::VOICE_STAT(int voiceIndex) { if (Voice[voiceIndex]._status) { int wavIndex = Voice[voiceIndex]._wavIndex; if (Swav[wavIndex]._audioStream != NULL && Swav[wavIndex]._audioStream->endOfStream()) - STOP_VOICE(voiceIndex); + stopVoice(voiceIndex); } return Voice[voiceIndex]._status; } -void SoundManager::STOP_VOICE(int voiceIndex) { +void SoundManager::stopVoice(int voiceIndex) { if (Voice[voiceIndex]._status) { Voice[voiceIndex]._status = 0; int wavIndex = Voice[voiceIndex]._wavIndex; @@ -864,7 +871,7 @@ void SoundManager::PLAY_NWAV(int wavIndex) { void SoundManager::DEL_NWAV(int wavIndex) { if (DEL_SAMPLE_SDL(wavIndex)) { if (VOICE_STAT(1) == 1) - STOP_VOICE(1); + stopVoice(1); SOUND_NUM = 0; _soundFl = false; -- cgit v1.2.3 From 1efe969b66392db757818d7cee13e7e47e67338f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 26 Dec 2012 07:55:56 +0100 Subject: HOPKINS: Fix menu in BeOS and OS2 versions --- engines/hopkins/sound.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e742b50be9..3672e29880 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -221,6 +221,11 @@ void SoundManager::playAnim_SOUND(int soundNumber) { } void SoundManager::WSOUND(int soundNumber) { + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) { + if (soundNumber > 27) + return; + } + if (old_music != soundNumber || !MOD_FLAG) { if (MOD_FLAG) WSOUND_OFF(); -- cgit v1.2.3 From 9a88c748fecddcf4d10856b7a58f6ec0ac4303df Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 27 Dec 2012 18:41:20 +0100 Subject: HOPKINS: Stop music properly when using the MOD player --- engines/hopkins/sound.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 3672e29880..b35a3d801d 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -456,6 +456,9 @@ void SoundManager::playMusic() { void SoundManager::stopMusic() { if (Music._active) Music._isPlaying = false; + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + _vm->_mixer->stopHandle(_modHandle); + } void SoundManager::delMusic() { -- cgit v1.2.3 From c07beb64455b3d30300176a99aed7140c0a090e0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 27 Dec 2012 19:08:10 +0100 Subject: HOPKINS: Some refactoring in showComputer --- engines/hopkins/sound.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index b35a3d801d..f09c89252a 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -74,11 +74,11 @@ namespace Hopkins { SoundManager::SoundManager() { SPECIAL_SOUND = 0; - SOUNDVOL = 0; - VOICEVOL = 0; - MUSICVOL = 0; + _soundVolume = 0; + _voiceVolume = 0; + _musicVolume = 0; _soundOffFl = true; - _musicOff = true; + _musicOffFl = true; _voiceOffFl = true; _textOffFl = false; _soundFl = false; @@ -381,7 +381,7 @@ void SoundManager::WSOUND_OFF() { } void SoundManager::PLAY_MOD(const Common::String &file) { - if (_musicOff) + if (_musicOffFl) return; _vm->_fileManager.constructFilename(_vm->_globals.HOPMUSIC, file); if (MOD_FLAG) { @@ -507,7 +507,7 @@ void SoundManager::checkMusic() { mwavIndex = Music._mwavIndexes[Music._currentIndex]; } - int volume = MUSICVOL * 255 / 16; + int volume = _musicVolume * 255 / 16; Mwav[mwavIndex]._audioStream->rewind(); _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Mwav[mwavIndex]._soundHandle, @@ -663,9 +663,9 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { } SDL_LVOICE(catPos, catLen); - oldMusicVol = MUSICVOL; - if (!_musicOff && MUSICVOL > 2) - MUSICVOL = (signed int)((long double)MUSICVOL - (long double)MUSICVOL / 100.0 * 45.0); + oldMusicVol = _musicVolume; + if (!_musicOffFl && _musicVolume > 2) + _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); PLAY_VOICE_SDL(); @@ -686,7 +686,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { stopVoice(2); DEL_SAMPLE_SDL(20); - MUSICVOL = oldMusicVol; + _musicVolume = oldMusicVol; _vm->_eventsManager._escKeyFl = false; VBL_MERDE = 0; return true; @@ -898,7 +898,7 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { Voice[voiceIndex].field14 = 4; Voice[voiceIndex]._wavIndex = wavIndex; - int volume = (voiceIndex == 2) ? VOICEVOL * 255 / 16 : SOUNDVOL * 255 / 16; + int volume = (voiceIndex == 2) ? _voiceVolume * 255 / 16 : _soundVolume * 255 / 16; // Start the voice playing Swav[wavIndex]._audioStream->rewind(); @@ -912,38 +912,38 @@ void SoundManager::syncSoundSettings() { muteAll = ConfMan.getBool("mute"); // Update the mute settings - _musicOff = muteAll || (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute")); + _musicOffFl = muteAll || (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute")); _soundOffFl = muteAll || (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute")); _voiceOffFl = muteAll || (ConfMan.hasKey("speech_mute") && ConfMan.getBool("speech_mute")); // Update the volume levels - MUSICVOL = MIN(255, ConfMan.getInt("music_volume")) * 16 / 255; - SOUNDVOL = MIN(255, ConfMan.getInt("sfx_volume")) * 16 / 255; - VOICEVOL = MIN(255, ConfMan.getInt("speech_volume")) * 16 / 255; + _musicVolume = MIN(255, ConfMan.getInt("music_volume")) * 16 / 255; + _soundVolume = MIN(255, ConfMan.getInt("sfx_volume")) * 16 / 255; + _voiceVolume = MIN(255, ConfMan.getInt("speech_volume")) * 16 / 255; // Update any active sounds for (int idx = 0; idx < SWAV_COUNT; ++idx) { if (Swav[idx]._active) { - int volume = (idx == 20) ? (VOICEVOL * 255 / 16) : (SOUNDVOL * 255 / 16); + int volume = (idx == 20) ? (_voiceVolume * 255 / 16) : (_soundVolume * 255 / 16); _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); } } for (int idx = 0; idx < MWAV_COUNT; ++idx) { if (Mwav[idx]._active) { - _vm->_mixer->setChannelVolume(Mwav[idx]._soundHandle, MUSICVOL * 255 / 16); + _vm->_mixer->setChannelVolume(Mwav[idx]._soundHandle, _musicVolume * 255 / 16); } } } void SoundManager::updateScummVMSoundSettings() { - ConfMan.setBool("mute", _musicOff && _soundOffFl && _voiceOffFl); - ConfMan.setBool("music_mute", _musicOff); + ConfMan.setBool("mute", _musicOffFl && _soundOffFl && _voiceOffFl); + ConfMan.setBool("music_mute", _musicOffFl); ConfMan.setBool("sfx_mute", _soundOffFl); ConfMan.setBool("speech_mute", _voiceOffFl); - ConfMan.setInt("music_volume", MUSICVOL * 255 / 16); - ConfMan.setInt("sfx_volume", SOUNDVOL * 255 / 16); - ConfMan.setInt("speech_volume", VOICEVOL * 255 / 16); + ConfMan.setInt("music_volume", _musicVolume * 255 / 16); + ConfMan.setInt("sfx_volume", _soundVolume * 255 / 16); + ConfMan.setInt("speech_volume", _voiceVolume * 255 / 16); ConfMan.flushToDisk(); } -- cgit v1.2.3 From c9343637902ed94f0a511ff9fa0d1bffe346d5e3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 28 Dec 2012 08:26:27 +0100 Subject: HOPKINS: Some more renaming and refactoring --- engines/hopkins/sound.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index f09c89252a..eda7ea0b88 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -390,7 +390,7 @@ void SoundManager::PLAY_MOD(const Common::String &file) { MOD_FLAG = false; } - loadMusic(_vm->_globals.NFICHIER); + loadMusic(_vm->_globals._curFilename); playMusic(); MOD_FLAG = true; } @@ -652,9 +652,9 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { catLen = _vm->_globals._catalogSize; } else { _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".WAV"); - if (!f.exists(_vm->_globals.NFICHIER)) { + if (!f.exists(_vm->_globals._curFilename)) { _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".APC"); - if (!f.exists(_vm->_globals.NFICHIER)) + if (!f.exists(_vm->_globals._curFilename)) return false; } @@ -733,7 +733,7 @@ void SoundManager::MODSetMusicVolume(int volume) { void SoundManager::loadSample(int wavIndex, const Common::String &file) { _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); - LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 0); + LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals._curFilename, 0); SOUND[wavIndex]._active = true; } @@ -807,8 +807,8 @@ void SoundManager::stopVoice(int voiceIndex) { } void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) { - if (!SDL_LoadVoice(_vm->_globals.NFICHIER, filePosition, entryLength, Swav[20])) - error("Couldn't load the sample %s", _vm->_globals.NFICHIER.c_str()); + if (!SDL_LoadVoice(_vm->_globals._curFilename, filePosition, entryLength, Swav[20])) + error("Couldn't load the sample %s", _vm->_globals._curFilename.c_str()); Swav[20]._active = true; } @@ -865,7 +865,7 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); - LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 1); + LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals._curFilename, 1); } void SoundManager::PLAY_NWAV(int wavIndex) { -- cgit v1.2.3 From f59f7dafc3f6a5bc9210acf87a9355fadba6510a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 31 Dec 2012 00:18:08 +0100 Subject: HOPKINS: Refactoring in FontManager and LinesManager --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index eda7ea0b88..90aa78127a 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -167,7 +167,7 @@ void SoundManager::LOAD_ANM_SOUND() { } void SoundManager::playAnim_SOUND(int soundNumber) { - if (!_vm->_globals.CENSURE && SPECIAL_SOUND == 2) { + if (!_vm->_globals._censorshipFl && SPECIAL_SOUND == 2) { switch (soundNumber) { case 20: PLAY_SAMPLE2(5); -- cgit v1.2.3 From 13063aeb3f93daddaa2a0664b79eb400c851ea8c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 1 Jan 2013 23:10:21 +0100 Subject: HOPKINS: Refactoring in ComputerManager --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 90aa78127a..e1a917318d 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -737,7 +737,7 @@ void SoundManager::loadSample(int wavIndex, const Common::String &file) { SOUND[wavIndex]._active = true; } -void SoundManager::PLAY_SAMPLE(int wavIndex, int voiceMode) { +void SoundManager::playSample(int wavIndex, int voiceMode) { if (!_soundOffFl && SOUND[wavIndex]._active) { if (_soundFl) DEL_NWAV(SOUND_NUM); -- cgit v1.2.3 From 6ff4c4c79b9908ee7b7c1e4e5b86197c13987f16 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 3 Jan 2013 16:29:35 +0100 Subject: HOPKINS: Commit by Eriktorbjorn : New way of playing music --- engines/hopkins/sound.cpp | 221 ++++++++++++++++++++++------------------------ 1 file changed, 107 insertions(+), 114 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e1a917318d..65619bee69 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -66,6 +66,106 @@ Audio::RewindableAudioStream *makeAPCStream(Common::SeekableReadStream *stream, return new APC_ADPCMStream(stream, disposeAfterUse, rate, stereo ? 2 : 1); } +class TwaAudioStream : public AudioStream { +public: + TwaAudioStream(Common::String name, Common::SeekableReadStream *stream) { + _name = name; + _cueSheet.clear(); + _cueStream = NULL; + _cue = 0; + + for (;;) { + char buf[3]; + stream->read(buf, 3); + + if (buf[0] == 'x' || stream->eos()) + break; + + _cueSheet.push_back(atol(buf)); + } + + for (_cue = 0; _cue < _cueSheet.size(); _cue++) { + if (loadCue(_cue)) + break; + } + } + + ~TwaAudioStream() { + delete _cueStream; + _cueStream = NULL; + } + + virtual bool isStereo() const { + return _cueStream ? _cueStream->isStereo() : true; + } + + virtual int getRate() const { + return _cueStream ? _cueStream->getRate() : 22050; + } + + virtual bool endOfData() const { + return _cueStream == NULL; + } + + virtual int readBuffer(int16 *buffer, const int numSamples) { + if (!_cueStream) + return 0; + + int16 *buf = buffer; + int samplesLeft = numSamples; + + while (samplesLeft) { + if (_cueStream) { + int readSamples = _cueStream->readBuffer(buf, samplesLeft); + buf += readSamples; + samplesLeft -= readSamples; + } + + if (samplesLeft > 0) { + if (++_cue >= _cueSheet.size()) { + _cue = 0; + } + loadCue(_cue); + } + } + + return numSamples; + } + +protected: + bool loadCue(int nr) { + delete _cueStream; + _cueStream = NULL; + + Common::String filename = Common::String::format("%s_%02d", _name.c_str(), _cueSheet[nr]); + Common::File *file = new Common::File(); + + if (file->open(filename + ".APC")) { + _cueStream = Audio::makeAPCStream(file, DisposeAfterUse::NO); + return true; + } + + if (file->open(filename + ".WAV")) { + _cueStream = Audio::makeWAVStream(file, DisposeAfterUse::NO); + return true; + } + + warning("TwaAudioStream::loadCue: Missing cue %d (%s)", nr, filename.c_str()); + delete file; + return false; + } + +private: + Common::String _name; + Common::Array _cueSheet; + Audio::AudioStream *_cueStream; + uint _cue; +}; + +Audio::AudioStream *makeTwaStream(Common::String name, Common::SeekableReadStream *stream) { + return new TwaAudioStream(name, stream); +} + } /*------------------------------------------------------------------------*/ @@ -91,8 +191,6 @@ SoundManager::SoundManager() { Common::fill((byte *)&Voice[i], (byte *)&Voice[i] + sizeof(VoiceItem), 0); for (int i = 0; i < SWAV_COUNT; ++i) Common::fill((byte *)&Swav[i], (byte *)&Swav[i] + sizeof(SwavItem), 0); - for (int i = 0; i < MWAV_COUNT; ++i) - Common::fill((byte *)&Mwav[i], (byte *)&Mwav[i] + sizeof(MwavItem), 0); for (int i = 0; i < SOUND_COUNT; ++i) Common::fill((byte *)&SOUND[i], (byte *)&SOUND[i] + sizeof(SoundItem), 0); Common::fill((byte *)&Music, (byte *)&Music + sizeof(MusicItem), 0); @@ -101,7 +199,7 @@ SoundManager::SoundManager() { SoundManager::~SoundManager() { stopMusic(); delMusic(); - _vm->_mixer->stopHandle(_modHandle); + _vm->_mixer->stopHandle(_musicHandle); MOD_FLAG = false; } @@ -407,7 +505,7 @@ void SoundManager::loadMusic(const Common::String &file) { error("Error opening file %s", filename.c_str()); Audio::AudioStream *modStream = Audio::makeProtrackerStream(&f); - _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_modHandle, modStream); + _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, modStream); } else { Common::String filename = Common::String::format("%s.TWA", file.c_str()); @@ -415,106 +513,29 @@ void SoundManager::loadMusic(const Common::String &file) { if (!f.open(filename)) error("Error opening file %s", filename.c_str()); - char s[8]; - int destIndex = 0; - int mwavIndex; - - bool breakFlag = false; - do { - f.read(&s[0], 3); - - if (s[0] == 'x') { - // End of list reached - Music._mwavIndexes[destIndex] = -1; - breakFlag = true; - } else { - // Convert two digits to a number - s[2] = '\0'; - mwavIndex = atol(&s[0]); - - filename = Common::String::format("%s_%s.%s", file.c_str(), &s[0], - (_vm->getPlatform() == Common::kPlatformWindows) ? "APC" : "WAV"); - LOAD_MSAMPLE(mwavIndex, filename); - - assert(destIndex < MUSIC_WAVE_COUNT); - Music._mwavIndexes[destIndex++] = mwavIndex; - } - } while (!breakFlag); + Audio::AudioStream *twaStream = Audio::makeTwaStream(file.c_str(), &f); + _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, twaStream); f.close(); } Music._active = true; - Music._isPlaying = false; - Music._currentIndex = -1; } void SoundManager::playMusic() { - if (Music._active) - Music._isPlaying = true; } void SoundManager::stopMusic() { - if (Music._active) - Music._isPlaying = false; - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_mixer->stopHandle(_modHandle); - + _vm->_mixer->stopHandle(_musicHandle); } void SoundManager::delMusic() { - if (Music._active) { - for (int i = 0; i < 50; ++i) { - DEL_MSAMPLE(i); - } - } - Music._active = false; - Music._isPlaying = false; - Music._string = " "; - Music._currentIndex = -1; } void SoundManager::checkSounds() { - checkMusic(); checkVoices(); } -void SoundManager::checkMusic() { - // OS2 and BeOS versions use MOD files. - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - return; - - if (Music._active && Music._isPlaying) { - int mwavIndex = Music._mwavIndexes[Music._currentIndex]; - if (mwavIndex == -1) - return; - - if (Music._currentIndex >= 0 && Music._currentIndex < MWAV_COUNT) { - if (mwavIndex != -1 && !Mwav[mwavIndex]._audioStream->endOfStream()) - // Currently playing wav has not finished, so exit - return; - - _vm->_mixer->stopHandle(Mwav[mwavIndex]._soundHandle); - } - - // Time to move to the next index - if (++Music._currentIndex >= MWAV_COUNT) - return; - - mwavIndex = Music._mwavIndexes[Music._currentIndex]; - if (mwavIndex == -1) { - Music._currentIndex = 0; - mwavIndex = Music._mwavIndexes[Music._currentIndex]; - } - - int volume = _musicVolume * 255 / 16; - - Mwav[mwavIndex]._audioStream->rewind(); - _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Mwav[mwavIndex]._soundHandle, - Mwav[mwavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); - } -} - void SoundManager::checkVoices() { // Check the status of each voice. bool hasActiveVoice = false; @@ -529,32 +550,6 @@ void SoundManager::checkVoices() { } } -void SoundManager::LOAD_MSAMPLE(int mwavIndex, const Common::String &file) { - if (!Mwav[mwavIndex]._active) { - Common::File f; - if (!f.open(file)) { - // Fallback from WAV to APC... - if (!f.open(setExtension(file, ".APC"))) - error("Could not open %s for reading", file.c_str()); - } - - Mwav[mwavIndex]._audioStream = makeSoundStream(f.readStream(f.size())); - Mwav[mwavIndex]._active = true; - - f.close(); - } -} - -void SoundManager::DEL_MSAMPLE(int mwavIndex) { - if (Mwav[mwavIndex]._active) { - Mwav[mwavIndex]._active = false; - _vm->_mixer->stopHandle(Mwav[mwavIndex]._soundHandle); - - delete Mwav[mwavIndex]._audioStream; - Mwav[mwavIndex]._audioStream = NULL; - } -} - bool SoundManager::mixVoice(int voiceId, int voiceMode) { int fileNumber; int oldMusicVol; @@ -928,10 +923,8 @@ void SoundManager::syncSoundSettings() { _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); } } - for (int idx = 0; idx < MWAV_COUNT; ++idx) { - if (Mwav[idx]._active) { - _vm->_mixer->setChannelVolume(Mwav[idx]._soundHandle, _musicVolume * 255 / 16); - } + if (_vm->_mixer->isSoundHandleActive(_musicHandle)) { + _vm->_mixer->setChannelVolume(_musicHandle, _musicVolume * 255 / 16); } } -- cgit v1.2.3 From 907d705c1e725e5df0a7a4b378d0c237f1df2961 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 5 Jan 2013 12:12:40 +0100 Subject: HOPKINS: (on Behalf of Eriktorbjorn) dispose music after use in order to avoid a memory leak --- engines/hopkins/sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 65619bee69..1925bac1b3 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -141,12 +141,12 @@ protected: Common::File *file = new Common::File(); if (file->open(filename + ".APC")) { - _cueStream = Audio::makeAPCStream(file, DisposeAfterUse::NO); + _cueStream = Audio::makeAPCStream(file, DisposeAfterUse::YES); return true; } if (file->open(filename + ".WAV")) { - _cueStream = Audio::makeWAVStream(file, DisposeAfterUse::NO); + _cueStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); return true; } -- cgit v1.2.3 From cdad3b605d3b112a16e91ab312b1dd93f5bc8f03 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 7 Jan 2013 13:49:41 +0200 Subject: HOPKINS: Simplify SoundManager::WSOUND() --- engines/hopkins/sound.cpp | 159 +++++++++------------------------------------- 1 file changed, 29 insertions(+), 130 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 1925bac1b3..a35fae5285 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -318,6 +318,16 @@ void SoundManager::playAnim_SOUND(int soundNumber) { } } +static const char *modSounds[] = { + "appart", "ville", "Rock", "police", "deep" + "purgat", "riviere", "SUSPENS", "labo", "cadavre", + "cabane", "purgat2", "foret", "ile", "ile2", + "hopkins", "peur", "URAVOLGA", "BASE", "cadavre2", + "usine", "chien", "coeur", "stand", "ocean", + "base3", "gloop", "cant", "feel", "lost", + "tobac" +}; + void SoundManager::WSOUND(int soundNumber) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) { if (soundNumber > 27) @@ -328,135 +338,7 @@ void SoundManager::WSOUND(int soundNumber) { if (MOD_FLAG) WSOUND_OFF(); - switch (soundNumber) { - case 1: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("appart"); - else - PLAY_MOD("appar"); - break; - case 2: - PLAY_MOD("ville"); - break; - case 3: - PLAY_MOD("Rock"); - break; - case 4: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("police"); - else - PLAY_MOD("polic"); - break; - case 5: - PLAY_MOD("deep"); - break; - case 6: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("purgat"); - else - PLAY_MOD("purga"); - break; - case 7: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("riviere"); - else - PLAY_MOD("rivie"); - break; - case 8: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("SUSPENS"); - else - PLAY_MOD("SUSPE"); - break; - case 9: - PLAY_MOD("labo"); - break; - case 10: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("cadavre"); - else - PLAY_MOD("cadav"); - break; - case 11: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("cabane"); - else - PLAY_MOD("caban"); - break; - case 12: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("purgat2"); - else - PLAY_MOD("purg2"); - break; - case 13: - PLAY_MOD("foret"); - break; - case 14: - PLAY_MOD("ile"); - break; - case 15: - PLAY_MOD("ile2"); - break; - case 16: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("hopkins"); - else - PLAY_MOD("hopki"); - break; - case 17: - PLAY_MOD("peur"); - break; - case 18: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("URAVOLGA"); - else - PLAY_MOD("peur"); - break; - case 19: - PLAY_MOD("BASE"); - break; - case 20: - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - PLAY_MOD("cadavre2"); - else - PLAY_MOD("cada2"); - break; - case 21: - PLAY_MOD("usine"); - break; - case 22: - PLAY_MOD("chien"); - break; - case 23: - PLAY_MOD("coeur"); - break; - case 24: - PLAY_MOD("stand"); - break; - case 25: - PLAY_MOD("ocean"); - break; - case 26: - PLAY_MOD("base3"); - break; - case 27: - PLAY_MOD("gloop"); - break; - case 28: - PLAY_MOD("cant"); - break; - case 29: - PLAY_MOD("feel"); - break; - case 30: - PLAY_MOD("lost"); - break; - case 31: - PLAY_MOD("tobac"); - break; - } - + PLAY_MOD(modSounds[soundNumber - 1]); old_music = soundNumber; } } @@ -481,7 +363,24 @@ void SoundManager::WSOUND_OFF() { void SoundManager::PLAY_MOD(const Common::String &file) { if (_musicOffFl) return; - _vm->_fileManager.constructFilename(_vm->_globals.HOPMUSIC, file); + Common::String modFile = file; + + // HACK + if (modFile == "URAVOLGA" && (_vm->getPlatform() == Common::kPlatformWindows || _vm->getPlatform() == Common::kPlatformLinux)) + modFile = "peur"; + + // The Windows/Linux version chops off the music file names to 5 characters + if (modFile.size() > 5 && (_vm->getPlatform() == Common::kPlatformWindows || _vm->getPlatform() == Common::kPlatformLinux)) { + if (!modFile.hasSuffix("2")) { + while (modFile.size() > 5) + modFile.deleteLastChar(); + } else { + while (modFile.size() > 4) + modFile.deleteLastChar(); + modFile += "2"; + } + } + _vm->_fileManager.constructFilename(_vm->_globals.HOPMUSIC, modFile); if (MOD_FLAG) { stopMusic(); delMusic(); -- cgit v1.2.3 From be83708ef5b65db4ea3893b61d189f30c92685b6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 7 Jan 2013 13:58:54 +0200 Subject: HOPKINS: Fix typo --- engines/hopkins/sound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index a35fae5285..cf06046bbe 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -614,15 +614,15 @@ void SoundManager::PLAY_SOUND2(const Common::String &file) { } void SoundManager::MODSetSampleVolume() { - // No implementatoin needed + // No implementation needed } void SoundManager::MODSetVoiceVolume() { - // No implementatoin needed + // No implementation needed } void SoundManager::MODSetMusicVolume(int volume) { - // No implementatoin needed + // No implementation needed } void SoundManager::loadSample(int wavIndex, const Common::String &file) { -- cgit v1.2.3 From bd865d9741878b56a86c1389e66dfdee24ba1e39 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 7 Jan 2013 16:17:27 +0200 Subject: HOPKINS: Remove static game directory configuration options Also, remove the unused VGA folder. This is the first step to remove constructFilename() and associated functions. --- engines/hopkins/sound.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index cf06046bbe..a55ef4d442 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -380,7 +380,7 @@ void SoundManager::PLAY_MOD(const Common::String &file) { modFile += "2"; } } - _vm->_fileManager.constructFilename(_vm->_globals.HOPMUSIC, modFile); + _vm->_fileManager.constructFilename("MUSIC", modFile); if (MOD_FLAG) { stopMusic(); delMusic(); @@ -520,34 +520,34 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "ENG_VOI.RES"); + _vm->_fileManager.constructFilename("VOICE", "ENG_VOI.RES"); // Win95 and Linux versions uses another set of names else if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); + _vm->_fileManager.constructFilename("VOICE", "RES_VFR.RES"); else if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); + _vm->_fileManager.constructFilename("VOICE", "RES_VAN.RES"); else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); + _vm->_fileManager.constructFilename("VOICE", "RES_VES.RES"); catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "ENG_VOI.RES"); + _vm->_fileManager.constructFilename("VOICE", "ENG_VOI.RES"); // Win95 and Linux versions uses another set of names else if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); + _vm->_fileManager.constructFilename("VOICE", "RES_VFR.RES"); else if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); + _vm->_fileManager.constructFilename("VOICE", "RES_VAN.RES"); else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); + _vm->_fileManager.constructFilename("VOICE", "RES_VES.RES"); catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else { - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".WAV"); + _vm->_fileManager.constructFilename("VOICE", filename + ".WAV"); if (!f.exists(_vm->_globals._curFilename)) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".APC"); + _vm->_fileManager.constructFilename("VOICE", filename + ".APC"); if (!f.exists(_vm->_globals._curFilename)) return false; } @@ -626,7 +626,7 @@ void SoundManager::MODSetMusicVolume(int volume) { } void SoundManager::loadSample(int wavIndex, const Common::String &file) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); + _vm->_fileManager.constructFilename("SOUND", file); LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals._curFilename, 0); SOUND[wavIndex]._active = true; } @@ -758,7 +758,7 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename } void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); + _vm->_fileManager.constructFilename("SOUND", file); LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals._curFilename, 1); } -- cgit v1.2.3 From f1dafa025c6aab93b8cf6b4707c075be3336c3e4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 7 Jan 2013 17:01:24 +0200 Subject: HOPKINS: Fix regression (typo) --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index a55ef4d442..1628268eca 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -319,7 +319,7 @@ void SoundManager::playAnim_SOUND(int soundNumber) { } static const char *modSounds[] = { - "appart", "ville", "Rock", "police", "deep" + "appart", "ville", "Rock", "police", "deep", "purgat", "riviere", "SUSPENS", "labo", "cadavre", "cabane", "purgat2", "foret", "ile", "ile2", "hopkins", "peur", "URAVOLGA", "BASE", "cadavre2", -- cgit v1.2.3 From 495ecaafbcf1620901d270a65394ca312f2b5a37 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Jan 2013 23:56:39 +0100 Subject: HOPKINS: Remove global filename and constructFilename --- engines/hopkins/sound.cpp | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 1628268eca..9fb45fa9fe 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -380,14 +380,13 @@ void SoundManager::PLAY_MOD(const Common::String &file) { modFile += "2"; } } - _vm->_fileManager.constructFilename("MUSIC", modFile); if (MOD_FLAG) { stopMusic(); delMusic(); MOD_FLAG = false; } - loadMusic(_vm->_globals._curFilename); + loadMusic(modFile); playMusic(); MOD_FLAG = true; } @@ -520,43 +519,43 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_fileManager.constructFilename("VOICE", "ENG_VOI.RES"); + filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names else if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename("VOICE", "RES_VFR.RES"); + filename = "RES_VFR.RES"; else if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename("VOICE", "RES_VAN.RES"); + filename = "RES_VAN.RES"; else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename("VOICE", "RES_VES.RES"); + filename = "RES_VES.RES"; catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_fileManager.constructFilename("VOICE", "ENG_VOI.RES"); + filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names else if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename("VOICE", "RES_VFR.RES"); + filename = "RES_VFR.RES"; else if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename("VOICE", "RES_VAN.RES"); + filename = "RES_VAN.RES"; else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename("VOICE", "RES_VES.RES"); + filename = "RES_VES.RES"; catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else { - _vm->_fileManager.constructFilename("VOICE", filename + ".WAV"); - if (!f.exists(_vm->_globals._curFilename)) { - _vm->_fileManager.constructFilename("VOICE", filename + ".APC"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists(filename + ".WAV")) { + if (!f.exists(filename + ".APC")) return false; - } + filename = filename + ".APC"; + } else + filename = filename + ".WAV"; catPos = 0; catLen = 0; } - SDL_LVOICE(catPos, catLen); + SDL_LVOICE(filename, catPos, catLen); oldMusicVol = _musicVolume; if (!_musicOffFl && _musicVolume > 2) _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); @@ -626,8 +625,7 @@ void SoundManager::MODSetMusicVolume(int volume) { } void SoundManager::loadSample(int wavIndex, const Common::String &file) { - _vm->_fileManager.constructFilename("SOUND", file); - LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals._curFilename, 0); + LOAD_SAMPLE2_SDL(wavIndex, file, 0); SOUND[wavIndex]._active = true; } @@ -700,9 +698,9 @@ void SoundManager::stopVoice(int voiceIndex) { Voice[voiceIndex].field14 = 0; } -void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) { - if (!SDL_LoadVoice(_vm->_globals._curFilename, filePosition, entryLength, Swav[20])) - error("Couldn't load the sample %s", _vm->_globals._curFilename.c_str()); +void SoundManager::SDL_LVOICE(Common::String filename, size_t filePosition, size_t entryLength) { + if (!SDL_LoadVoice(filename, filePosition, entryLength, Swav[20])) + error("Couldn't load the sample %s", filename.c_str()); Swav[20]._active = true; } @@ -758,8 +756,7 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename } void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { - _vm->_fileManager.constructFilename("SOUND", file); - LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals._curFilename, 1); + LOAD_SAMPLE2_SDL(wavIndex, file, 1); } void SoundManager::PLAY_NWAV(int wavIndex) { -- cgit v1.2.3 From a743857b87bd6e7cec47c231943d3e8cef254ebf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Jan 2013 11:01:26 +0100 Subject: HOPKINS: (Courtesy of Eriktorbjorn) slight optimisation of the sound code --- engines/hopkins/sound.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 9fb45fa9fe..4da7bdac15 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -73,6 +73,7 @@ public: _cueSheet.clear(); _cueStream = NULL; _cue = 0; + _loadedCue = -1; for (;;) { char buf[3]; @@ -134,8 +135,14 @@ public: protected: bool loadCue(int nr) { + if (_loadedCue == _cueSheet[nr]) { + _cueStream->rewind(); + return true; + } + delete _cueStream; _cueStream = NULL; + _loadedCue = _cueSheet[nr]; Common::String filename = Common::String::format("%s_%02d", _name.c_str(), _cueSheet[nr]); Common::File *file = new Common::File(); @@ -151,6 +158,7 @@ protected: } warning("TwaAudioStream::loadCue: Missing cue %d (%s)", nr, filename.c_str()); + _loadedCue = -1; delete file; return false; } @@ -158,8 +166,9 @@ protected: private: Common::String _name; Common::Array _cueSheet; - Audio::AudioStream *_cueStream; + Audio::RewindableAudioStream *_cueStream; uint _cue; + int _loadedCue; }; Audio::AudioStream *makeTwaStream(Common::String name, Common::SeekableReadStream *stream) { -- cgit v1.2.3 From 4fd422692b554d4c49e2f00662f36f24bb9f1b24 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 18 Jan 2013 18:52:19 +0100 Subject: HOPKINS: Some renaming and refactoring --- engines/hopkins/sound.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 4da7bdac15..9f0212c9aa 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -569,7 +569,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { if (!_musicOffFl && _musicVolume > 2) _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); - PLAY_VOICE_SDL(); + playVoice(); // Loop for playing voice breakFlag = 0; @@ -698,13 +698,11 @@ void SoundManager::stopVoice(int voiceIndex) { Voice[voiceIndex]._status = 0; int wavIndex = Voice[voiceIndex]._wavIndex; if (Swav[wavIndex]._active) { - if (Swav[wavIndex].freeSample) + if (Swav[wavIndex]._freeSampleFl) DEL_SAMPLE_SDL(wavIndex); } } - Voice[voiceIndex].fieldC = 0; Voice[voiceIndex]._status = 0; - Voice[voiceIndex].field14 = 0; } void SoundManager::SDL_LVOICE(Common::String filename, size_t filePosition, size_t entryLength) { @@ -714,13 +712,13 @@ void SoundManager::SDL_LVOICE(Common::String filename, size_t filePosition, size Swav[20]._active = true; } -void SoundManager::PLAY_VOICE_SDL() { +void SoundManager::playVoice() { if (!Swav[20]._active) error("Bad handle"); if (!Voice[2]._status) { int wavIndex = Voice[2]._wavIndex; - if (Swav[wavIndex]._active && Swav[wavIndex].freeSample) + if (Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) DEL_SAMPLE_SDL(wavIndex); } @@ -761,7 +759,7 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename SDL_LoadVoice(filename, 0, 0, Swav[wavIndex]); Swav[wavIndex]._active = true; - Swav[wavIndex].freeSample = freeSample; + Swav[wavIndex]._freeSampleFl = freeSample; } void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { @@ -790,12 +788,10 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { if (!Swav[wavIndex]._active) warning("Bad handle"); - if (Voice[voiceIndex]._status == 1 && Swav[wavIndex]._active && Swav[wavIndex].freeSample) + if (Voice[voiceIndex]._status == 1 && Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) DEL_SAMPLE_SDL(wavIndex); - Voice[voiceIndex].fieldC = 0; Voice[voiceIndex]._status = 1; - Voice[voiceIndex].field14 = 4; Voice[voiceIndex]._wavIndex = wavIndex; int volume = (voiceIndex == 2) ? _voiceVolume * 255 / 16 : _soundVolume * 255 / 16; -- cgit v1.2.3 From 0d92a7e5a3a9dd8303e01f17c9206e645c10b4de Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 18 Jan 2013 21:09:41 +0100 Subject: HOPKINS: Add support for RAW speechs used by the OS/2 version --- engines/hopkins/sound.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 9f0212c9aa..d9a6ed7730 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -30,6 +30,7 @@ #include "hopkins/hopkins.h" #include "audio/audiostream.h" #include "audio/mods/protracker.h" +#include "audio/decoders/raw.h" namespace Audio { @@ -157,6 +158,11 @@ protected: return true; } + if (file->open(filename + ".RAW")) { + _cueStream = Audio::makeRawStream(file, 22050, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES); + return true; + } + warning("TwaAudioStream::loadCue: Missing cue %d (%s)", nr, filename.c_str()); _loadedCue = -1; delete file; @@ -550,6 +556,19 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { else if (_vm->_globals._language == LANG_SP) filename = "RES_VES.RES"; + catPos = _vm->_globals._catalogPos; + catLen = _vm->_globals._catalogSize; + } else if (!_vm->_fileManager.searchCat(filename + ".RAW", 9)) { + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + filename = "ENG_VOI.RES"; + // Win95 and Linux versions uses another set of names + else if (_vm->_globals._language == LANG_FR) + filename = "RES_VFR.RES"; + else if (_vm->_globals._language == LANG_EN) + filename = "RES_VAN.RES"; + else if (_vm->_globals._language == LANG_SP) + filename = "RES_VES.RES"; + catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else { @@ -845,8 +864,10 @@ void SoundManager::updateScummVMSoundSettings() { Audio::RewindableAudioStream *SoundManager::makeSoundStream(Common::SeekableReadStream *stream) { if (_vm->getPlatform() == Common::kPlatformWindows) return Audio::makeAPCStream(stream, DisposeAfterUse::YES); - else + else if (_vm->getPlatform() == Common::kPlatformLinux) return Audio::makeWAVStream(stream, DisposeAfterUse::YES); + else + return Audio::makeRawStream(stream, 22050, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES); } // Blatant rip from gob engine. Hi DrMcCoy! -- cgit v1.2.3 From ca2f04b70fb4a4df83e19d67b8cd61e8943e1d71 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 18 Jan 2013 22:23:58 +0100 Subject: HOPKINS: The first speech after a video was skipped if the video was skipped before. This fixes it. --- engines/hopkins/sound.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index d9a6ed7730..2104f5648c 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -590,6 +590,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { playVoice(); + _vm->_eventsManager._escKeyFl = false; + // Loop for playing voice breakFlag = 0; do { -- cgit v1.2.3 From 523aa825634784d9c25f16ccca118030565a8344 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 00:56:19 +0100 Subject: HOPKINS: Some renaming --- engines/hopkins/sound.cpp | 219 ++++++++++++++++++++-------------------------- 1 file changed, 94 insertions(+), 125 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 2104f5648c..24001cbb6f 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -188,7 +188,7 @@ Audio::AudioStream *makeTwaStream(Common::String name, Common::SeekableReadStrea namespace Hopkins { SoundManager::SoundManager() { - SPECIAL_SOUND = 0; + _specialSoundNum = 0; _soundVolume = 0; _voiceVolume = 0; _musicVolume = 0; @@ -198,9 +198,9 @@ SoundManager::SoundManager() { _textOffFl = false; _soundFl = false; VBL_MERDE = false; - SOUND_NUM = 0; - old_music = 0; - MOD_FLAG = false; + _currentSoundIndex = 0; + _oldSoundNumber = 0; + _modPlayingFl = false; for (int i = 0; i < VOICE_COUNT; ++i) Common::fill((byte *)&Voice[i], (byte *)&Voice[i] + sizeof(VoiceItem), 0); @@ -215,29 +215,29 @@ SoundManager::~SoundManager() { stopMusic(); delMusic(); _vm->_mixer->stopHandle(_musicHandle); - MOD_FLAG = false; + _modPlayingFl = false; } void SoundManager::setParent(HopkinsEngine *vm) { _vm = vm; - SPECIAL_SOUND = 0; + _specialSoundNum = 0; } void SoundManager::WSOUND_INIT() { warning("TODO: WSOUND_INIT"); } -void SoundManager::VERIF_SOUND() { +void SoundManager::checkSoundEnd() { if (!_soundOffFl && _soundFl) { - if (!VOICE_STAT(1)) { + if (!checkVoiceStatus(1)) { stopVoice(1); - DEL_NWAV(SOUND_NUM); + DEL_NWAV(_currentSoundIndex); } } } -void SoundManager::LOAD_ANM_SOUND() { - switch (SPECIAL_SOUND) { +void SoundManager::loadAnimSound() { + switch (_specialSoundNum) { case 2: loadSample(5, "mitra1.wav"); loadSample(1, "tir2.wav"); @@ -246,41 +246,41 @@ void SoundManager::LOAD_ANM_SOUND() { loadSample(4, "sound4.WAV"); break; case 5: - LOAD_WAV("CRIE.WAV", 1); + loadWav("CRIE.WAV", 1); break; case 14: - LOAD_WAV("SOUND14.WAV", 1); + loadWav("SOUND14.WAV", 1); break; case 16: - LOAD_WAV("SOUND16.WAV", 1); + loadWav("SOUND16.WAV", 1); break; case 198: - LOAD_WAV("SOUND3.WAV", 1); + loadWav("SOUND3.WAV", 1); break; case 199: - LOAD_WAV("SOUND22.WAV", 1); + loadWav("SOUND22.WAV", 1); break; case 200: mixVoice(682, 1); break; case 208: - LOAD_WAV("SOUND77.WAV", 1); + loadWav("SOUND77.WAV", 1); break; case 210: - LOAD_WAV("SOUND78.WAV", 1); + loadWav("SOUND78.WAV", 1); break; case 211: - LOAD_WAV("SOUND78.WAV", 1); + loadWav("SOUND78.WAV", 1); break; case 229: - LOAD_WAV("SOUND80.WAV", 1); - LOAD_WAV("SOUND82.WAV", 2); + loadWav("SOUND80.WAV", 1); + loadWav("SOUND82.WAV", 2); break; } } -void SoundManager::playAnim_SOUND(int soundNumber) { - if (!_vm->_globals._censorshipFl && SPECIAL_SOUND == 2) { +void SoundManager::playAnimSound(int soundNumber) { + if (!_vm->_globals._censorshipFl && _specialSoundNum == 2) { switch (soundNumber) { case 20: PLAY_SAMPLE2(5); @@ -300,32 +300,32 @@ void SoundManager::playAnim_SOUND(int soundNumber) { PLAY_SAMPLE2(4); break; } - } else if (SPECIAL_SOUND == 1 && soundNumber == 17) + } else if (_specialSoundNum == 1 && soundNumber == 17) playSound("SOUND42.WAV"); - else if (SPECIAL_SOUND == 5 && soundNumber == 19) + else if (_specialSoundNum == 5 && soundNumber == 19) playWav(1); - else if (SPECIAL_SOUND == 14 && soundNumber == 625) + else if (_specialSoundNum == 14 && soundNumber == 625) playWav(1); - else if (SPECIAL_SOUND == 16 && soundNumber == 25) + else if (_specialSoundNum == 16 && soundNumber == 25) playWav(1); - else if (SPECIAL_SOUND == 17) { + else if (_specialSoundNum == 17) { if (soundNumber == 6) PLAY_SAMPLE2(1); else if (soundNumber == 14) PLAY_SAMPLE2(2); else if (soundNumber == 67) PLAY_SAMPLE2(3); - } else if (SPECIAL_SOUND == 198 && soundNumber == 15) + } else if (_specialSoundNum == 198 && soundNumber == 15) playWav(1); - else if (SPECIAL_SOUND == 199 && soundNumber == 72) + else if (_specialSoundNum == 199 && soundNumber == 72) playWav(1); - else if (SPECIAL_SOUND == 208 && soundNumber == 40) + else if (_specialSoundNum == 208 && soundNumber == 40) playWav(1); - else if (SPECIAL_SOUND == 210 && soundNumber == 2) + else if (_specialSoundNum == 210 && soundNumber == 2) playWav(1); - else if (SPECIAL_SOUND == 211 && soundNumber == 22) + else if (_specialSoundNum == 211 && soundNumber == 22) playWav(1); - else if (SPECIAL_SOUND == 229) { + else if (_specialSoundNum == 229) { if (soundNumber == 15) playWav(1); else if (soundNumber == 91) @@ -349,12 +349,12 @@ void SoundManager::WSOUND(int soundNumber) { return; } - if (old_music != soundNumber || !MOD_FLAG) { - if (MOD_FLAG) + if (_oldSoundNumber != soundNumber || !_modPlayingFl) { + if (_modPlayingFl) WSOUND_OFF(); - PLAY_MOD(modSounds[soundNumber - 1]); - old_music = soundNumber; + playMod(modSounds[soundNumber - 1]); + _oldSoundNumber = soundNumber; } } @@ -363,19 +363,19 @@ void SoundManager::WSOUND_OFF() { stopVoice(1); stopVoice(2); if (_vm->_soundManager._soundFl) - DEL_NWAV(SOUND_NUM); + DEL_NWAV(_currentSoundIndex); for (int i = 1; i <= 48; ++i) DEL_SAMPLE_SDL(i); - if (MOD_FLAG) { + if (_modPlayingFl) { stopMusic(); delMusic(); - MOD_FLAG = false; + _modPlayingFl = false; } } -void SoundManager::PLAY_MOD(const Common::String &file) { +void SoundManager::playMod(const Common::String &file) { if (_musicOffFl) return; Common::String modFile = file; @@ -395,15 +395,15 @@ void SoundManager::PLAY_MOD(const Common::String &file) { modFile += "2"; } } - if (MOD_FLAG) { + if (_modPlayingFl) { stopMusic(); delMusic(); - MOD_FLAG = false; + _modPlayingFl = false; } loadMusic(modFile); playMusic(); - MOD_FLAG = true; + _modPlayingFl = true; } void SoundManager::loadMusic(const Common::String &file) { @@ -446,20 +446,20 @@ void SoundManager::delMusic() { } void SoundManager::checkSounds() { - checkVoices(); + checkVoiceActivity(); } -void SoundManager::checkVoices() { +void SoundManager::checkVoiceActivity() { // Check the status of each voice. bool hasActiveVoice = false; for (int i = 0; i < VOICE_COUNT; ++i) { - VOICE_STAT(i); - hasActiveVoice |= Voice[i]._status != 0; + checkVoiceStatus(i); + hasActiveVoice |= Voice[i]._status; } if (!hasActiveVoice && _soundFl) { _soundFl = false; - SOUND_NUM = 0; + _currentSoundIndex = 0; } } @@ -476,59 +476,31 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { if (_voiceOffFl) return false; - if ((unsigned int)(voiceMode - 1) <= 1 - && (voiceId == 4 - || voiceId == 16 - || voiceId == 121 - || voiceId == 142 - || voiceId == 182 - || voiceId == 191 - || voiceId == 212 - || voiceId == 225 - || voiceId == 239 - || voiceId == 245 - || voiceId == 297 - || voiceId == 308 - || voiceId == 333 - || voiceId == 348 - || voiceId == 352 - || voiceId == 358 - || voiceId == 364 - || voiceId == 371 - || voiceId == 394 - || voiceId == 414 - || voiceId == 429 - || voiceId == 442 - || voiceId == 446 - || voiceId == 461 - || voiceId == 468 - || voiceId == 476 - || voiceId == 484 - || voiceId == 491 - || voiceId == 497 - || voiceId == 501 - || voiceId == 511 - || voiceId == 520 - || voiceId == 536 - || voiceId == 554 - || voiceId == 566 - || voiceId == 573 - || voiceId == 632 - || voiceId == 645)) + if ((voiceMode == 1 || voiceMode == 2) + && ( voiceId == 4 || voiceId == 16 || voiceId == 121 + || voiceId == 142 || voiceId == 182 || voiceId == 191 + || voiceId == 212 || voiceId == 225 || voiceId == 239 + || voiceId == 245 || voiceId == 297 || voiceId == 308 + || voiceId == 333 || voiceId == 348 || voiceId == 352 + || voiceId == 358 || voiceId == 364 || voiceId == 371 + || voiceId == 394 || voiceId == 414 || voiceId == 429 + || voiceId == 442 || voiceId == 446 || voiceId == 461 + || voiceId == 468 || voiceId == 476 || voiceId == 484 + || voiceId == 491 || voiceId == 497 || voiceId == 501 + || voiceId == 511 || voiceId == 520 || voiceId == 536 + || voiceId == 554 || voiceId == 566 || voiceId == 573 + || voiceId == 632 || voiceId == 645)) fileNumber = 684; - if ((unsigned int)(voiceMode - 1) <= 1) { + if (voiceMode == 1 || voiceMode == 2) prefix = "DF"; - } - if (voiceMode == 3) { + else if (voiceMode == 3) prefix = "IF"; - } - if (voiceMode == 4) { + else if (voiceMode == 4) prefix = "TF"; - } - if (voiceMode == 5) { + else if (voiceMode == 5) prefix = "OF"; - } + filename = Common::String::format("%s%d", prefix.c_str(), fileNumber); @@ -595,14 +567,14 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { // Loop for playing voice breakFlag = 0; do { - if (SPECIAL_SOUND != 4 && !VBL_MERDE) + if (_specialSoundNum != 4 && !VBL_MERDE) _vm->_eventsManager.VBL(); if (_vm->_eventsManager.getMouseButton()) break; _vm->_eventsManager.refreshEvents(); if (_vm->_eventsManager._escKeyFl) break; - if (!VOICE_STAT(2)) + if (!checkVoiceStatus(2)) breakFlag = true; } while (!_vm->shouldQuit() && !breakFlag); @@ -616,11 +588,11 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { } void SoundManager::DEL_SAMPLE(int soundIndex) { - if (VOICE_STAT(1) == 1) + if (checkVoiceStatus(1)) stopVoice(1); - if (VOICE_STAT(2) == 2) + if (checkVoiceStatus(2)) stopVoice(2); - if (VOICE_STAT(3) == 3) + if (checkVoiceStatus(3)) stopVoice(3); DEL_SAMPLE_SDL(soundIndex); SOUND[soundIndex]._active = false; @@ -629,7 +601,7 @@ void SoundManager::DEL_SAMPLE(int soundIndex) { void SoundManager::playSound(const Common::String &file) { if (!_soundOffFl) { if (_soundFl) - DEL_NWAV(SOUND_NUM); + DEL_NWAV(_currentSoundIndex); LOAD_NWAV(file, 1); PLAY_NWAV(1); } @@ -662,24 +634,21 @@ void SoundManager::loadSample(int wavIndex, const Common::String &file) { void SoundManager::playSample(int wavIndex, int voiceMode) { if (!_soundOffFl && SOUND[wavIndex]._active) { if (_soundFl) - DEL_NWAV(SOUND_NUM); + DEL_NWAV(_currentSoundIndex); if (voiceMode == 5) { - if (VOICE_STAT(1) == 1) + if (checkVoiceStatus(1)) stopVoice(1); PLAY_SAMPLE_SDL(1, wavIndex); - } - if (voiceMode == 6) { - if (VOICE_STAT(2) == 1) + } else if (voiceMode == 6) { + if (checkVoiceStatus(2)) stopVoice(1); PLAY_SAMPLE_SDL(2, wavIndex); - } - if (voiceMode == 7) { - if (VOICE_STAT(3) == 1) + } else if (voiceMode == 7) { + if (checkVoiceStatus(3)) stopVoice(1); PLAY_SAMPLE_SDL(3, wavIndex); - } - if (voiceMode == 8) { - if (VOICE_STAT(1) == 1) + } else if (voiceMode == 8) { + if (checkVoiceStatus(1)) stopVoice(1); PLAY_SAMPLE_SDL(1, wavIndex); } @@ -689,14 +658,14 @@ void SoundManager::playSample(int wavIndex, int voiceMode) { void SoundManager::PLAY_SAMPLE2(int idx) { if (!_soundOffFl && SOUND[idx]._active) { if (_soundFl) - DEL_NWAV(SOUND_NUM); - if (VOICE_STAT(1) == 1) + DEL_NWAV(_currentSoundIndex); + if (checkVoiceStatus(1)) stopVoice(1); PLAY_SAMPLE_SDL(1, idx); } } -void SoundManager::LOAD_WAV(const Common::String &file, int wavIndex) { +void SoundManager::loadWav(const Common::String &file, int wavIndex) { LOAD_NWAV(file, wavIndex); } @@ -704,7 +673,7 @@ void SoundManager::playWav(int wavIndex) { PLAY_NWAV(wavIndex); } -int SoundManager::VOICE_STAT(int voiceIndex) { +bool SoundManager::checkVoiceStatus(int voiceIndex) { if (Voice[voiceIndex]._status) { int wavIndex = Voice[voiceIndex]._wavIndex; if (Swav[wavIndex]._audioStream != NULL && Swav[wavIndex]._audioStream->endOfStream()) @@ -716,14 +685,14 @@ int SoundManager::VOICE_STAT(int voiceIndex) { void SoundManager::stopVoice(int voiceIndex) { if (Voice[voiceIndex]._status) { - Voice[voiceIndex]._status = 0; + Voice[voiceIndex]._status = false; int wavIndex = Voice[voiceIndex]._wavIndex; if (Swav[wavIndex]._active) { if (Swav[wavIndex]._freeSampleFl) DEL_SAMPLE_SDL(wavIndex); } } - Voice[voiceIndex]._status = 0; + Voice[voiceIndex]._status = false; } void SoundManager::SDL_LVOICE(Common::String filename, size_t filePosition, size_t entryLength) { @@ -790,17 +759,17 @@ void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { void SoundManager::PLAY_NWAV(int wavIndex) { if (!_soundFl && !_soundOffFl) { _soundFl = true; - SOUND_NUM = wavIndex; + _currentSoundIndex = wavIndex; PLAY_SAMPLE_SDL(1, wavIndex); } } void SoundManager::DEL_NWAV(int wavIndex) { if (DEL_SAMPLE_SDL(wavIndex)) { - if (VOICE_STAT(1) == 1) + if (checkVoiceStatus(1)) stopVoice(1); - SOUND_NUM = 0; + _currentSoundIndex = 0; _soundFl = false; } } @@ -809,10 +778,10 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { if (!Swav[wavIndex]._active) warning("Bad handle"); - if (Voice[voiceIndex]._status == 1 && Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) + if (Voice[voiceIndex]._status && Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) DEL_SAMPLE_SDL(wavIndex); - Voice[voiceIndex]._status = 1; + Voice[voiceIndex]._status = true; Voice[voiceIndex]._wavIndex = wavIndex; int volume = (voiceIndex == 2) ? _voiceVolume * 255 / 16 : _soundVolume * 255 / 16; -- cgit v1.2.3 From d88e5ad22f96e6e667182967b50de820f7823e2b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 01:01:09 +0100 Subject: HOPKINS: Remove a couple of useless functions --- engines/hopkins/sound.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 24001cbb6f..e1100cb04a 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -231,7 +231,7 @@ void SoundManager::checkSoundEnd() { if (!_soundOffFl && _soundFl) { if (!checkVoiceStatus(1)) { stopVoice(1); - DEL_NWAV(_currentSoundIndex); + delWav(_currentSoundIndex); } } } @@ -363,7 +363,7 @@ void SoundManager::WSOUND_OFF() { stopVoice(1); stopVoice(2); if (_vm->_soundManager._soundFl) - DEL_NWAV(_currentSoundIndex); + delWav(_currentSoundIndex); for (int i = 1; i <= 48; ++i) DEL_SAMPLE_SDL(i); @@ -601,16 +601,16 @@ void SoundManager::DEL_SAMPLE(int soundIndex) { void SoundManager::playSound(const Common::String &file) { if (!_soundOffFl) { if (_soundFl) - DEL_NWAV(_currentSoundIndex); - LOAD_NWAV(file, 1); - PLAY_NWAV(1); + delWav(_currentSoundIndex); + loadWav(file, 1); + playWav(1); } } void SoundManager::PLAY_SOUND2(const Common::String &file) { if (!_soundOffFl) { - LOAD_NWAV(file, 1); - PLAY_NWAV(1); + loadWav(file, 1); + playWav(1); } } @@ -634,7 +634,7 @@ void SoundManager::loadSample(int wavIndex, const Common::String &file) { void SoundManager::playSample(int wavIndex, int voiceMode) { if (!_soundOffFl && SOUND[wavIndex]._active) { if (_soundFl) - DEL_NWAV(_currentSoundIndex); + delWav(_currentSoundIndex); if (voiceMode == 5) { if (checkVoiceStatus(1)) stopVoice(1); @@ -658,21 +658,13 @@ void SoundManager::playSample(int wavIndex, int voiceMode) { void SoundManager::PLAY_SAMPLE2(int idx) { if (!_soundOffFl && SOUND[idx]._active) { if (_soundFl) - DEL_NWAV(_currentSoundIndex); + delWav(_currentSoundIndex); if (checkVoiceStatus(1)) stopVoice(1); PLAY_SAMPLE_SDL(1, idx); } } -void SoundManager::loadWav(const Common::String &file, int wavIndex) { - LOAD_NWAV(file, wavIndex); -} - -void SoundManager::playWav(int wavIndex) { - PLAY_NWAV(wavIndex); -} - bool SoundManager::checkVoiceStatus(int voiceIndex) { if (Voice[voiceIndex]._status) { int wavIndex = Voice[voiceIndex]._wavIndex; @@ -752,11 +744,11 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename Swav[wavIndex]._freeSampleFl = freeSample; } -void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { +void SoundManager::loadWav(const Common::String &file, int wavIndex) { LOAD_SAMPLE2_SDL(wavIndex, file, 1); } -void SoundManager::PLAY_NWAV(int wavIndex) { +void SoundManager::playWav(int wavIndex) { if (!_soundFl && !_soundOffFl) { _soundFl = true; _currentSoundIndex = wavIndex; @@ -764,7 +756,7 @@ void SoundManager::PLAY_NWAV(int wavIndex) { } } -void SoundManager::DEL_NWAV(int wavIndex) { +void SoundManager::delWav(int wavIndex) { if (DEL_SAMPLE_SDL(wavIndex)) { if (checkVoiceStatus(1)) stopVoice(1); -- cgit v1.2.3 From 17d57a367edc70f2cc2a48efa308179bbdd12ce1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 01:04:52 +0100 Subject: HOPKINS: Remove WSOUND_INIT --- engines/hopkins/sound.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e1100cb04a..3894e7f67a 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -223,10 +223,6 @@ void SoundManager::setParent(HopkinsEngine *vm) { _specialSoundNum = 0; } -void SoundManager::WSOUND_INIT() { - warning("TODO: WSOUND_INIT"); -} - void SoundManager::checkSoundEnd() { if (!_soundOffFl && _soundFl) { if (!checkVoiceStatus(1)) { -- cgit v1.2.3 From 4c44e797d8b1b84b29294d09fc6f43b5e33dd6f0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 13:44:14 +0100 Subject: HOPKINS: Fix speech in intro for BeOS and OS/2 versions. Thanks Eriktorbjorn for the help --- engines/hopkins/sound.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 3894e7f67a..f80081be00 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -497,8 +497,17 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { else if (voiceMode == 5) prefix = "OF"; + // BeOS and OS/2 versions are using a slightly different speech order during intro + // This map those values to the oens used by the Win95 and Linux versions + int mappedFileNumber = fileNumber; + if (voiceMode == 3 && (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS)) { + if (fileNumber == 4) + mappedFileNumber = 0; + else if (fileNumber > 4) + mappedFileNumber = fileNumber - 1; + } - filename = Common::String::format("%s%d", prefix.c_str(), fileNumber); + filename = Common::String::format("%s%d", prefix.c_str(), mappedFileNumber); if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) -- cgit v1.2.3 From 568e64541774715f56a974cc74d5060067283cc0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 17:47:35 +0100 Subject: HOPKINS: Refactor playIntro --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index f80081be00..94e846e802 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -498,7 +498,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { prefix = "OF"; // BeOS and OS/2 versions are using a slightly different speech order during intro - // This map those values to the oens used by the Win95 and Linux versions + // This map those values to the ones used by the Win95 and Linux versions int mappedFileNumber = fileNumber; if (voiceMode == 3 && (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS)) { if (fileNumber == 4) -- cgit v1.2.3 From d92f85f0e1f3fb2ea29cf5fd8827ae75ac2d0f96 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 19:12:45 +0100 Subject: HOPKINS: Some more renaming and refactoring --- engines/hopkins/sound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 94e846e802..28b5080b33 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -197,7 +197,7 @@ SoundManager::SoundManager() { _voiceOffFl = true; _textOffFl = false; _soundFl = false; - VBL_MERDE = false; + skipRefreshFl = false; _currentSoundIndex = 0; _oldSoundNumber = 0; _modPlayingFl = false; @@ -572,7 +572,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { // Loop for playing voice breakFlag = 0; do { - if (_specialSoundNum != 4 && !VBL_MERDE) + if (_specialSoundNum != 4 && !skipRefreshFl) _vm->_eventsManager.VBL(); if (_vm->_eventsManager.getMouseButton()) break; @@ -588,7 +588,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { DEL_SAMPLE_SDL(20); _musicVolume = oldMusicVol; _vm->_eventsManager._escKeyFl = false; - VBL_MERDE = 0; + skipRefreshFl = false; return true; } -- cgit v1.2.3 From 0e0337c30e3b32ae9ab487be8b20ba6a1043c6ef Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 22 Jan 2013 21:24:31 +0100 Subject: HOPKINS: Some renaming. Implement proper music volume during speech --- engines/hopkins/sound.cpp | 70 +++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 27 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 28b5080b33..47b2e6827e 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -203,12 +203,12 @@ SoundManager::SoundManager() { _modPlayingFl = false; for (int i = 0; i < VOICE_COUNT; ++i) - Common::fill((byte *)&Voice[i], (byte *)&Voice[i] + sizeof(VoiceItem), 0); + Common::fill((byte *)&_voice[i], (byte *)&_voice[i] + sizeof(VoiceItem), 0); for (int i = 0; i < SWAV_COUNT; ++i) Common::fill((byte *)&Swav[i], (byte *)&Swav[i] + sizeof(SwavItem), 0); for (int i = 0; i < SOUND_COUNT; ++i) - Common::fill((byte *)&SOUND[i], (byte *)&SOUND[i] + sizeof(SoundItem), 0); - Common::fill((byte *)&Music, (byte *)&Music + sizeof(MusicItem), 0); + Common::fill((byte *)&_sound[i], (byte *)&_sound[i] + sizeof(SoundItem), 0); + Common::fill((byte *)&_music, (byte *)&_music + sizeof(MusicItem), 0); } SoundManager::~SoundManager() { @@ -403,7 +403,7 @@ void SoundManager::playMod(const Common::String &file) { } void SoundManager::loadMusic(const Common::String &file) { - if (Music._active) + if (_music._active) delMusic(); Common::File f; @@ -427,7 +427,7 @@ void SoundManager::loadMusic(const Common::String &file) { f.close(); } - Music._active = true; + _music._active = true; } void SoundManager::playMusic() { @@ -438,7 +438,7 @@ void SoundManager::stopMusic() { } void SoundManager::delMusic() { - Music._active = false; + _music._active = false; } void SoundManager::checkSounds() { @@ -450,7 +450,7 @@ void SoundManager::checkVoiceActivity() { bool hasActiveVoice = false; for (int i = 0; i < VOICE_COUNT; ++i) { checkVoiceStatus(i); - hasActiveVoice |= Voice[i]._status; + hasActiveVoice |= _voice[i]._status; } if (!hasActiveVoice && _soundFl) { @@ -562,8 +562,10 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { SDL_LVOICE(filename, catPos, catLen); oldMusicVol = _musicVolume; - if (!_musicOffFl && _musicVolume > 2) + if (!_musicOffFl && _musicVolume > 2) { _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); + _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume); + } playVoice(); @@ -587,6 +589,9 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { stopVoice(2); DEL_SAMPLE_SDL(20); _musicVolume = oldMusicVol; + if (!_musicOffFl && _musicVolume > 2) { + _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume); + } _vm->_eventsManager._escKeyFl = false; skipRefreshFl = false; return true; @@ -600,7 +605,7 @@ void SoundManager::DEL_SAMPLE(int soundIndex) { if (checkVoiceStatus(3)) stopVoice(3); DEL_SAMPLE_SDL(soundIndex); - SOUND[soundIndex]._active = false; + _sound[soundIndex]._active = false; } void SoundManager::playSound(const Common::String &file) { @@ -620,24 +625,35 @@ void SoundManager::PLAY_SOUND2(const Common::String &file) { } void SoundManager::MODSetSampleVolume() { - // No implementation needed + for (int idx = 0; idx < SWAV_COUNT; ++idx) { + if (Swav[idx]._active) { + int volume = (idx == 20) ? (_voiceVolume * 255 / 16) : (_soundVolume * 255 / 16); + _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); + } + } } void SoundManager::MODSetVoiceVolume() { - // No implementation needed + for (int idx = 0; idx < SWAV_COUNT; ++idx) { + if (Swav[idx]._active) { + int volume = (idx == 20) ? (_voiceVolume * 255 / 16) : (_soundVolume * 255 / 16); + _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); + } + } } void SoundManager::MODSetMusicVolume(int volume) { - // No implementation needed + if (_vm->_mixer->isSoundHandleActive(_musicHandle)) + _vm->_mixer->setChannelVolume(_musicHandle, volume * 255 / 16); } void SoundManager::loadSample(int wavIndex, const Common::String &file) { LOAD_SAMPLE2_SDL(wavIndex, file, 0); - SOUND[wavIndex]._active = true; + _sound[wavIndex]._active = true; } void SoundManager::playSample(int wavIndex, int voiceMode) { - if (!_soundOffFl && SOUND[wavIndex]._active) { + if (!_soundOffFl && _sound[wavIndex]._active) { if (_soundFl) delWav(_currentSoundIndex); if (voiceMode == 5) { @@ -661,7 +677,7 @@ void SoundManager::playSample(int wavIndex, int voiceMode) { } void SoundManager::PLAY_SAMPLE2(int idx) { - if (!_soundOffFl && SOUND[idx]._active) { + if (!_soundOffFl && _sound[idx]._active) { if (_soundFl) delWav(_currentSoundIndex); if (checkVoiceStatus(1)) @@ -671,25 +687,25 @@ void SoundManager::PLAY_SAMPLE2(int idx) { } bool SoundManager::checkVoiceStatus(int voiceIndex) { - if (Voice[voiceIndex]._status) { - int wavIndex = Voice[voiceIndex]._wavIndex; + if (_voice[voiceIndex]._status) { + int wavIndex = _voice[voiceIndex]._wavIndex; if (Swav[wavIndex]._audioStream != NULL && Swav[wavIndex]._audioStream->endOfStream()) stopVoice(voiceIndex); } - return Voice[voiceIndex]._status; + return _voice[voiceIndex]._status; } void SoundManager::stopVoice(int voiceIndex) { - if (Voice[voiceIndex]._status) { - Voice[voiceIndex]._status = false; - int wavIndex = Voice[voiceIndex]._wavIndex; + if (_voice[voiceIndex]._status) { + _voice[voiceIndex]._status = false; + int wavIndex = _voice[voiceIndex]._wavIndex; if (Swav[wavIndex]._active) { if (Swav[wavIndex]._freeSampleFl) DEL_SAMPLE_SDL(wavIndex); } } - Voice[voiceIndex]._status = false; + _voice[voiceIndex]._status = false; } void SoundManager::SDL_LVOICE(Common::String filename, size_t filePosition, size_t entryLength) { @@ -703,8 +719,8 @@ void SoundManager::playVoice() { if (!Swav[20]._active) error("Bad handle"); - if (!Voice[2]._status) { - int wavIndex = Voice[2]._wavIndex; + if (!_voice[2]._status) { + int wavIndex = _voice[2]._wavIndex; if (Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) DEL_SAMPLE_SDL(wavIndex); } @@ -775,11 +791,11 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { if (!Swav[wavIndex]._active) warning("Bad handle"); - if (Voice[voiceIndex]._status && Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) + if (_voice[voiceIndex]._status && Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) DEL_SAMPLE_SDL(wavIndex); - Voice[voiceIndex]._status = true; - Voice[voiceIndex]._wavIndex = wavIndex; + _voice[voiceIndex]._status = true; + _voice[voiceIndex]._wavIndex = wavIndex; int volume = (voiceIndex == 2) ? _voiceVolume * 255 / 16 : _soundVolume * 255 / 16; -- cgit v1.2.3 From 82ecfd537f8cb52701cc05e39457d00ce71ecb59 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 23 Jan 2013 01:38:34 +0100 Subject: HOPKINS: Some renaming and refactoring in globals, TalkManager and FontsManager --- engines/hopkins/sound.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 47b2e6827e..3ef1618d8b 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -561,6 +561,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { } SDL_LVOICE(filename, catPos, catLen); + + // Reduce music volume during speech oldMusicVol = _musicVolume; if (!_musicOffFl && _musicVolume > 2) { _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); @@ -588,6 +590,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { stopVoice(2); DEL_SAMPLE_SDL(20); + + // Speech is over, set the music volume back to normal _musicVolume = oldMusicVol; if (!_musicOffFl && _musicVolume > 2) { _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume); -- cgit v1.2.3 From 56ca87b3a573c64e8c82d9c6fa8427ddb5458ba5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 23 Jan 2013 01:42:31 +0100 Subject: HOPKINS: Modify misc setVolume functions so they are a bit less precise --- engines/hopkins/sound.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 3ef1618d8b..d24c3e10b2 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -630,19 +630,17 @@ void SoundManager::PLAY_SOUND2(const Common::String &file) { void SoundManager::MODSetSampleVolume() { for (int idx = 0; idx < SWAV_COUNT; ++idx) { - if (Swav[idx]._active) { - int volume = (idx == 20) ? (_voiceVolume * 255 / 16) : (_soundVolume * 255 / 16); + if (idx != 20 && Swav[idx]._active) { + int volume = _soundVolume * 255 / 16; _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); } } } void SoundManager::MODSetVoiceVolume() { - for (int idx = 0; idx < SWAV_COUNT; ++idx) { - if (Swav[idx]._active) { - int volume = (idx == 20) ? (_voiceVolume * 255 / 16) : (_soundVolume * 255 / 16); - _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); - } + if (Swav[20]._active) { + int volume = _voiceVolume * 255 / 16; + _vm->_mixer->setChannelVolume(Swav[20]._soundHandle, volume); } } -- cgit v1.2.3 From a50c05f7d0b98a1777f7b97af54bb2c842de0318 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 27 Jan 2013 18:18:04 +0100 Subject: HOPKINS: Work around broken cadavre.mod in OS/2 and BeOS versions A large part of cadavre.mod is broken. No new notes play, and only the old background sounds remain. It's possible, perhaps even probable, that the original MOD player didn't have this problem, but all standalone players I've tried do, so I'm assuming it's the file that's broken. We work around it by changing the length of the song after it's been loaded to only include the good parts. --- engines/hopkins/sound.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index d24c3e10b2..46bdb1e841 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -29,6 +29,7 @@ #include "hopkins/globals.h" #include "hopkins/hopkins.h" #include "audio/audiostream.h" +#include "audio/mods/module.h" #include "audio/mods/protracker.h" #include "audio/decoders/raw.h" @@ -413,7 +414,18 @@ void SoundManager::loadMusic(const Common::String &file) { if (!f.open(filename)) error("Error opening file %s", filename.c_str()); - Audio::AudioStream *modStream = Audio::makeProtrackerStream(&f); + Modules::Module *module; + Audio::AudioStream *modStream = Audio::makeProtrackerStream(&f, 0, 44100, true, &module); + + // WORKAROUND: This song is played at the empty lot where the + // bank robbers have left the helicopter. The MOD file appears + // to be slightly broken. Almost half of it is just the same + // noise repeating. We fix this by only playing the working + // part of it. The result is pretty close to the Windows music. + if (file.equalsIgnoreCase("cadavre")) { + module->songlen = 3; + } + _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, modStream); } else { -- cgit v1.2.3 From c0ad052c727650464419318a760e08bb7d152072 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 28 Jan 2013 07:45:46 +0100 Subject: HOPKINS: Add a fallback for the sound played in the option menu, for the BeOS and OS/2 versions --- engines/hopkins/sound.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 46bdb1e841..96c7df2329 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -625,12 +625,23 @@ void SoundManager::DEL_SAMPLE(int soundIndex) { } void SoundManager::playSound(const Common::String &file) { - if (!_soundOffFl) { - if (_soundFl) - delWav(_currentSoundIndex); - loadWav(file, 1); - playWav(1); - } + if (_soundOffFl) + return; + + // Fallback for the menu option. + // The BeOS and OS/2 versions don't play sound at this point. + // sound20 sounds very close to bruit2 from the linux and Win95 versions. + Common::File f; + Common::String filename; + if (file == "bruit2.wav" && !f.exists(file)) + filename = "sound20.wav"; + else + filename = file; + + if (_soundFl) + delWav(_currentSoundIndex); + loadWav(filename, 1); + playWav(1); } void SoundManager::PLAY_SOUND2(const Common::String &file) { -- cgit v1.2.3 From 49afc87b883c89c01a8638e158a5a533279ef073 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 3 Feb 2013 18:33:20 +0100 Subject: HOPKINS: Attempt to fix crash when skipping movie Before starting an "Swav" sound, check that its sound handle isn't already used. If it is, stop it. When skipping a movie, it still (incorrectly?) goes through the motions of playing the remaining frames, including starting any movie sounds on the way. This would cause us to lose the handle to the sound that was currently playing in the "Swav" slot, and I *think* that's what ended up confusing things. I'm still not entirely sure exactly what was happening. --- engines/hopkins/sound.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 96c7df2329..7b59f1ee62 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -824,6 +824,12 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { int volume = (voiceIndex == 2) ? _voiceVolume * 255 / 16 : _soundVolume * 255 / 16; + // If the handle is still in use, stop it. Otherwise we'll lose the + // handle to that sound. This can currently happen (but probably + // shouldn't) when skipping a movie. + if (_vm->_mixer->isSoundHandleActive(Swav[wavIndex]._soundHandle)) + _vm->_mixer->stopHandle(Swav[wavIndex]._soundHandle); + // Start the voice playing Swav[wavIndex]._audioStream->rewind(); _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Swav[wavIndex]._soundHandle, -- cgit v1.2.3 From 6ce3e2187b6a2395b96b9f9a55c5c40d6b887333 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 8 Feb 2013 07:29:40 +0100 Subject: HOPKINS: Improve private/public scope in SoundManager and ScriptManager --- engines/hopkins/sound.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 7b59f1ee62..e30e670b27 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -198,7 +198,7 @@ SoundManager::SoundManager() { _voiceOffFl = true; _textOffFl = false; _soundFl = false; - skipRefreshFl = false; + _skipRefreshFl = false; _currentSoundIndex = 0; _oldSoundNumber = 0; _modPlayingFl = false; @@ -457,6 +457,9 @@ void SoundManager::checkSounds() { checkVoiceActivity(); } +/** + * Checks voices to see if they're finished + */ void SoundManager::checkVoiceActivity() { // Check the status of each voice. bool hasActiveVoice = false; @@ -588,7 +591,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { // Loop for playing voice breakFlag = 0; do { - if (_specialSoundNum != 4 && !skipRefreshFl) + if (_specialSoundNum != 4 && !_skipRefreshFl) _vm->_eventsManager.VBL(); if (_vm->_eventsManager.getMouseButton()) break; @@ -609,7 +612,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume); } _vm->_eventsManager._escKeyFl = false; - skipRefreshFl = false; + _skipRefreshFl = false; return true; } @@ -876,6 +879,9 @@ void SoundManager::updateScummVMSoundSettings() { ConfMan.flushToDisk(); } +/** + * Creates an audio stream based on a passed raw stream + */ Audio::RewindableAudioStream *SoundManager::makeSoundStream(Common::SeekableReadStream *stream) { if (_vm->getPlatform() == Common::kPlatformWindows) return Audio::makeAPCStream(stream, DisposeAfterUse::YES); -- cgit v1.2.3 From bda951c5e2785cba6289123327c0cda9ab3f82a7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Feb 2013 21:34:08 +0100 Subject: HOPKINS: Fix 2 comments of LordHoto --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e30e670b27..1e9d02a3ae 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -330,7 +330,7 @@ void SoundManager::playAnimSound(int soundNumber) { } } -static const char *modSounds[] = { +static const char *const modSounds[] = { "appart", "ville", "Rock", "police", "deep", "purgat", "riviere", "SUSPENS", "labo", "cadavre", "cabane", "purgat2", "foret", "ile", "ile2", -- cgit v1.2.3 From 84e290eade13bfdff1e866d058af447893bee321 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Feb 2013 22:20:24 +0100 Subject: HOPKINS: Reorder includes --- engines/hopkins/sound.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 1e9d02a3ae..87943872d4 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -20,14 +20,16 @@ * */ +#include "hopkins/sound.h" + +#include "hopkins/globals.h" +#include "hopkins/hopkins.h" + #include "audio/decoders/adpcm_intern.h" #include "common/system.h" #include "common/config-manager.h" #include "common/file.h" #include "common/textconsole.h" -#include "hopkins/sound.h" -#include "hopkins/globals.h" -#include "hopkins/hopkins.h" #include "audio/audiostream.h" #include "audio/mods/module.h" #include "audio/mods/protracker.h" -- cgit v1.2.3 From 355422455cc8e99fd5faab5811d45a18231d3e41 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Feb 2013 00:06:45 +0100 Subject: HOPKINS: Some more similar cleanup --- engines/hopkins/sound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 87943872d4..5d0442aaa5 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -361,7 +361,7 @@ void SoundManager::WSOUND_OFF() { stopVoice(0); stopVoice(1); stopVoice(2); - if (_vm->_soundManager._soundFl) + if (_soundFl) delWav(_currentSoundIndex); for (int i = 1; i <= 48; ++i) @@ -583,7 +583,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { oldMusicVol = _musicVolume; if (!_musicOffFl && _musicVolume > 2) { _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); - _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume); + MODSetMusicVolume(_musicVolume); } playVoice(); @@ -611,7 +611,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { // Speech is over, set the music volume back to normal _musicVolume = oldMusicVol; if (!_musicOffFl && _musicVolume > 2) { - _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume); + MODSetMusicVolume(_musicVolume); } _vm->_eventsManager._escKeyFl = false; _skipRefreshFl = false; -- cgit v1.2.3 From 5bbdbc0fadf250d14e6b289172c5359cd1179896 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Feb 2013 14:34:43 +0100 Subject: HOPKINS: Misc renaming, some sound refactoring --- engines/hopkins/sound.cpp | 90 +++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 46 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 5d0442aaa5..5957cde960 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -282,25 +282,25 @@ void SoundManager::playAnimSound(int soundNumber) { if (!_vm->_globals._censorshipFl && _specialSoundNum == 2) { switch (soundNumber) { case 20: - PLAY_SAMPLE2(5); + playSample(5); break; case 57: case 63: case 69: - PLAY_SAMPLE2(1); + playSample(1); break; case 75: - PLAY_SAMPLE2(2); + playSample(2); break; case 109: - PLAY_SAMPLE2(3); + playSample(3); break; case 122: - PLAY_SAMPLE2(4); + playSample(4); break; } } else if (_specialSoundNum == 1 && soundNumber == 17) - playSound("SOUND42.WAV"); + playSoundFile("SOUND42.WAV"); else if (_specialSoundNum == 5 && soundNumber == 19) playWav(1); else if (_specialSoundNum == 14 && soundNumber == 625) @@ -309,11 +309,11 @@ void SoundManager::playAnimSound(int soundNumber) { playWav(1); else if (_specialSoundNum == 17) { if (soundNumber == 6) - PLAY_SAMPLE2(1); + playSample(1); else if (soundNumber == 14) - PLAY_SAMPLE2(2); + playSample(2); else if (soundNumber == 67) - PLAY_SAMPLE2(3); + playSample(3); } else if (_specialSoundNum == 198 && soundNumber == 15) playWav(1); else if (_specialSoundNum == 199 && soundNumber == 72) @@ -342,7 +342,7 @@ static const char *const modSounds[] = { "tobac" }; -void SoundManager::WSOUND(int soundNumber) { +void SoundManager::playSound(int soundNumber) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) { if (soundNumber > 27) return; @@ -350,14 +350,14 @@ void SoundManager::WSOUND(int soundNumber) { if (_oldSoundNumber != soundNumber || !_modPlayingFl) { if (_modPlayingFl) - WSOUND_OFF(); + stopSound(); playMod(modSounds[soundNumber - 1]); _oldSoundNumber = soundNumber; } } -void SoundManager::WSOUND_OFF() { +void SoundManager::stopSound() { stopVoice(0); stopVoice(1); stopVoice(2); @@ -618,7 +618,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { return true; } -void SoundManager::DEL_SAMPLE(int soundIndex) { +void SoundManager::removeSample(int soundIndex) { if (checkVoiceStatus(1)) stopVoice(1); if (checkVoiceStatus(2)) @@ -629,7 +629,7 @@ void SoundManager::DEL_SAMPLE(int soundIndex) { _sound[soundIndex]._active = false; } -void SoundManager::playSound(const Common::String &file) { +void SoundManager::playSoundFile(const Common::String &file) { if (_soundOffFl) return; @@ -649,11 +649,12 @@ void SoundManager::playSound(const Common::String &file) { playWav(1); } -void SoundManager::PLAY_SOUND2(const Common::String &file) { - if (!_soundOffFl) { - loadWav(file, 1); - playWav(1); - } +void SoundManager::directPlayWav(const Common::String &file) { + if (_soundOffFl) + return; + + loadWav(file, 1); + playWav(1); } void SoundManager::MODSetSampleVolume() { @@ -683,36 +684,33 @@ void SoundManager::loadSample(int wavIndex, const Common::String &file) { } void SoundManager::playSample(int wavIndex, int voiceMode) { - if (!_soundOffFl && _sound[wavIndex]._active) { - if (_soundFl) - delWav(_currentSoundIndex); - if (voiceMode == 5) { - if (checkVoiceStatus(1)) - stopVoice(1); - PLAY_SAMPLE_SDL(1, wavIndex); - } else if (voiceMode == 6) { - if (checkVoiceStatus(2)) - stopVoice(1); - PLAY_SAMPLE_SDL(2, wavIndex); - } else if (voiceMode == 7) { - if (checkVoiceStatus(3)) - stopVoice(1); - PLAY_SAMPLE_SDL(3, wavIndex); - } else if (voiceMode == 8) { - if (checkVoiceStatus(1)) - stopVoice(1); - PLAY_SAMPLE_SDL(1, wavIndex); - } - } -} + if (_soundOffFl || !_sound[wavIndex]._active) + return; -void SoundManager::PLAY_SAMPLE2(int idx) { - if (!_soundOffFl && _sound[idx]._active) { - if (_soundFl) - delWav(_currentSoundIndex); + if (_soundFl) + delWav(_currentSoundIndex); + + switch (voiceMode) { + case 5: + case 8: + // Case added to identify the former PLAY_SAMPLE2 calls + case 9: if (checkVoiceStatus(1)) stopVoice(1); - PLAY_SAMPLE_SDL(1, idx); + PLAY_SAMPLE_SDL(1, wavIndex); + break; + case 6: + if (checkVoiceStatus(2)) + stopVoice(1); + PLAY_SAMPLE_SDL(2, wavIndex); + break; + case 7: + if (checkVoiceStatus(3)) + stopVoice(1); + PLAY_SAMPLE_SDL(3, wavIndex); + break; + default: + break; } } -- cgit v1.2.3 From a208f51db79ce642b4ca5936488e2cf33f398f73 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Feb 2013 15:08:12 +0100 Subject: HOPKINS: More renaming in SoundManager --- engines/hopkins/sound.cpp | 123 ++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 64 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 5957cde960..a2054eed18 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -208,7 +208,7 @@ SoundManager::SoundManager() { for (int i = 0; i < VOICE_COUNT; ++i) Common::fill((byte *)&_voice[i], (byte *)&_voice[i] + sizeof(VoiceItem), 0); for (int i = 0; i < SWAV_COUNT; ++i) - Common::fill((byte *)&Swav[i], (byte *)&Swav[i] + sizeof(SwavItem), 0); + Common::fill((byte *)&_sWav[i], (byte *)&_sWav[i] + sizeof(SwavItem), 0); for (int i = 0; i < SOUND_COUNT; ++i) Common::fill((byte *)&_sound[i], (byte *)&_sound[i] + sizeof(SoundItem), 0); Common::fill((byte *)&_music, (byte *)&_music + sizeof(MusicItem), 0); @@ -365,7 +365,7 @@ void SoundManager::stopSound() { delWav(_currentSoundIndex); for (int i = 1; i <= 48; ++i) - DEL_SAMPLE_SDL(i); + removeWavSample(i); if (_modPlayingFl) { stopMusic(); @@ -577,13 +577,16 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { catLen = 0; } - SDL_LVOICE(filename, catPos, catLen); + if (!loadVoice(filename, catPos, catLen, _sWav[20])) + error("Couldn't load sample: %s", filename.c_str()); + + _sWav[20]._active = true; // Reduce music volume during speech oldMusicVol = _musicVolume; if (!_musicOffFl && _musicVolume > 2) { _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); - MODSetMusicVolume(_musicVolume); + setMODMusicVolume(_musicVolume); } playVoice(); @@ -606,12 +609,12 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { stopVoice(2); - DEL_SAMPLE_SDL(20); + removeWavSample(20); // Speech is over, set the music volume back to normal _musicVolume = oldMusicVol; if (!_musicOffFl && _musicVolume > 2) { - MODSetMusicVolume(_musicVolume); + setMODMusicVolume(_musicVolume); } _vm->_eventsManager._escKeyFl = false; _skipRefreshFl = false; @@ -625,7 +628,7 @@ void SoundManager::removeSample(int soundIndex) { stopVoice(2); if (checkVoiceStatus(3)) stopVoice(3); - DEL_SAMPLE_SDL(soundIndex); + removeWavSample(soundIndex); _sound[soundIndex]._active = false; } @@ -657,29 +660,29 @@ void SoundManager::directPlayWav(const Common::String &file) { playWav(1); } -void SoundManager::MODSetSampleVolume() { +void SoundManager::setMODSampleVolume() { for (int idx = 0; idx < SWAV_COUNT; ++idx) { - if (idx != 20 && Swav[idx]._active) { + if (idx != 20 && _sWav[idx]._active) { int volume = _soundVolume * 255 / 16; - _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); + _vm->_mixer->setChannelVolume(_sWav[idx]._soundHandle, volume); } } } -void SoundManager::MODSetVoiceVolume() { - if (Swav[20]._active) { +void SoundManager::setMODVoiceVolume() { + if (_sWav[20]._active) { int volume = _voiceVolume * 255 / 16; - _vm->_mixer->setChannelVolume(Swav[20]._soundHandle, volume); + _vm->_mixer->setChannelVolume(_sWav[20]._soundHandle, volume); } } -void SoundManager::MODSetMusicVolume(int volume) { +void SoundManager::setMODMusicVolume(int volume) { if (_vm->_mixer->isSoundHandleActive(_musicHandle)) _vm->_mixer->setChannelVolume(_musicHandle, volume * 255 / 16); } void SoundManager::loadSample(int wavIndex, const Common::String &file) { - LOAD_SAMPLE2_SDL(wavIndex, file, 0); + loadWavSample(wavIndex, file, false); _sound[wavIndex]._active = true; } @@ -697,17 +700,17 @@ void SoundManager::playSample(int wavIndex, int voiceMode) { case 9: if (checkVoiceStatus(1)) stopVoice(1); - PLAY_SAMPLE_SDL(1, wavIndex); + playWavSample(1, wavIndex); break; case 6: if (checkVoiceStatus(2)) stopVoice(1); - PLAY_SAMPLE_SDL(2, wavIndex); + playWavSample(2, wavIndex); break; case 7: if (checkVoiceStatus(3)) stopVoice(1); - PLAY_SAMPLE_SDL(3, wavIndex); + playWavSample(3, wavIndex); break; default: break; @@ -717,7 +720,7 @@ void SoundManager::playSample(int wavIndex, int voiceMode) { bool SoundManager::checkVoiceStatus(int voiceIndex) { if (_voice[voiceIndex]._status) { int wavIndex = _voice[voiceIndex]._wavIndex; - if (Swav[wavIndex]._audioStream != NULL && Swav[wavIndex]._audioStream->endOfStream()) + if (_sWav[wavIndex]._audioStream != NULL && _sWav[wavIndex]._audioStream->endOfStream()) stopVoice(voiceIndex); } @@ -728,48 +731,40 @@ void SoundManager::stopVoice(int voiceIndex) { if (_voice[voiceIndex]._status) { _voice[voiceIndex]._status = false; int wavIndex = _voice[voiceIndex]._wavIndex; - if (Swav[wavIndex]._active) { - if (Swav[wavIndex]._freeSampleFl) - DEL_SAMPLE_SDL(wavIndex); + if (_sWav[wavIndex]._active) { + if (_sWav[wavIndex]._freeSampleFl) + removeWavSample(wavIndex); } } _voice[voiceIndex]._status = false; } -void SoundManager::SDL_LVOICE(Common::String filename, size_t filePosition, size_t entryLength) { - if (!SDL_LoadVoice(filename, filePosition, entryLength, Swav[20])) - error("Couldn't load the sample %s", filename.c_str()); - - Swav[20]._active = true; -} - void SoundManager::playVoice() { - if (!Swav[20]._active) + if (!_sWav[20]._active) error("Bad handle"); if (!_voice[2]._status) { int wavIndex = _voice[2]._wavIndex; - if (Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) - DEL_SAMPLE_SDL(wavIndex); + if (_sWav[wavIndex]._active && _sWav[wavIndex]._freeSampleFl) + removeWavSample(wavIndex); } - PLAY_SAMPLE_SDL(2, 20); + playWavSample(2, 20); } -bool SoundManager::DEL_SAMPLE_SDL(int wavIndex) { - if (Swav[wavIndex]._active) { - _vm->_mixer->stopHandle(Swav[wavIndex]._soundHandle); - delete Swav[wavIndex]._audioStream; - Swav[wavIndex]._audioStream = NULL; - Swav[wavIndex]._active = false; - - return true; - } else { +bool SoundManager::removeWavSample(int wavIndex) { + if (!_sWav[wavIndex]._active) return false; - } + + _vm->_mixer->stopHandle(_sWav[wavIndex]._soundHandle); + delete _sWav[wavIndex]._audioStream; + _sWav[wavIndex]._audioStream = NULL; + _sWav[wavIndex]._active = false; + + return true; } -bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffset, size_t entryLength, SwavItem &item) { +bool SoundManager::loadVoice(const Common::String &filename, size_t fileOffset, size_t entryLength, SwavItem &item) { Common::File f; if (!f.open(filename)) { // Fallback from WAV to APC... @@ -784,29 +779,29 @@ bool SoundManager::SDL_LoadVoice(const Common::String &filename, size_t fileOffs return true; } -void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename, bool freeSample) { - if (Swav[wavIndex]._active) - DEL_SAMPLE_SDL(wavIndex); +void SoundManager::loadWavSample(int wavIndex, const Common::String &filename, bool freeSample) { + if (_sWav[wavIndex]._active) + removeWavSample(wavIndex); - SDL_LoadVoice(filename, 0, 0, Swav[wavIndex]); - Swav[wavIndex]._active = true; - Swav[wavIndex]._freeSampleFl = freeSample; + loadVoice(filename, 0, 0, _sWav[wavIndex]); + _sWav[wavIndex]._active = true; + _sWav[wavIndex]._freeSampleFl = freeSample; } void SoundManager::loadWav(const Common::String &file, int wavIndex) { - LOAD_SAMPLE2_SDL(wavIndex, file, 1); + loadWavSample(wavIndex, file, true); } void SoundManager::playWav(int wavIndex) { if (!_soundFl && !_soundOffFl) { _soundFl = true; _currentSoundIndex = wavIndex; - PLAY_SAMPLE_SDL(1, wavIndex); + playWavSample(1, wavIndex); } } void SoundManager::delWav(int wavIndex) { - if (DEL_SAMPLE_SDL(wavIndex)) { + if (removeWavSample(wavIndex)) { if (checkVoiceStatus(1)) stopVoice(1); @@ -815,12 +810,12 @@ void SoundManager::delWav(int wavIndex) { } } -void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { - if (!Swav[wavIndex]._active) +void SoundManager::playWavSample(int voiceIndex, int wavIndex) { + if (!_sWav[wavIndex]._active) warning("Bad handle"); - if (_voice[voiceIndex]._status && Swav[wavIndex]._active && Swav[wavIndex]._freeSampleFl) - DEL_SAMPLE_SDL(wavIndex); + if (_voice[voiceIndex]._status && _sWav[wavIndex]._active && _sWav[wavIndex]._freeSampleFl) + removeWavSample(wavIndex); _voice[voiceIndex]._status = true; _voice[voiceIndex]._wavIndex = wavIndex; @@ -830,13 +825,13 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { // If the handle is still in use, stop it. Otherwise we'll lose the // handle to that sound. This can currently happen (but probably // shouldn't) when skipping a movie. - if (_vm->_mixer->isSoundHandleActive(Swav[wavIndex]._soundHandle)) - _vm->_mixer->stopHandle(Swav[wavIndex]._soundHandle); + if (_vm->_mixer->isSoundHandleActive(_sWav[wavIndex]._soundHandle)) + _vm->_mixer->stopHandle(_sWav[wavIndex]._soundHandle); // Start the voice playing - Swav[wavIndex]._audioStream->rewind(); - _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &Swav[wavIndex]._soundHandle, - Swav[wavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); + _sWav[wavIndex]._audioStream->rewind(); + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sWav[wavIndex]._soundHandle, + _sWav[wavIndex]._audioStream, -1, volume, 0, DisposeAfterUse::NO); } void SoundManager::syncSoundSettings() { @@ -856,9 +851,9 @@ void SoundManager::syncSoundSettings() { // Update any active sounds for (int idx = 0; idx < SWAV_COUNT; ++idx) { - if (Swav[idx]._active) { + if (_sWav[idx]._active) { int volume = (idx == 20) ? (_voiceVolume * 255 / 16) : (_soundVolume * 255 / 16); - _vm->_mixer->setChannelVolume(Swav[idx]._soundHandle, volume); + _vm->_mixer->setChannelVolume(_sWav[idx]._soundHandle, volume); } } if (_vm->_mixer->isSoundHandleActive(_musicHandle)) { -- cgit v1.2.3 From 5297f6370749dfaff9b6b80ea9f10b855cd1b58f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 22 Feb 2013 19:23:21 +0100 Subject: HOPKINS: Fix the crash related to the missing speech file in the Win95 English demo --- engines/hopkins/sound.cpp | 48 +++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index a2054eed18..b6322b49c0 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -476,7 +476,7 @@ void SoundManager::checkVoiceActivity() { } } -bool SoundManager::mixVoice(int voiceId, int voiceMode) { +bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { int fileNumber; int oldMusicVol; bool breakFlag; @@ -577,24 +577,25 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { catLen = 0; } - if (!loadVoice(filename, catPos, catLen, _sWav[20])) - error("Couldn't load sample: %s", filename.c_str()); - - _sWav[20]._active = true; - - // Reduce music volume during speech oldMusicVol = _musicVolume; - if (!_musicOffFl && _musicVolume > 2) { - _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); - setMODMusicVolume(_musicVolume); - } + if (!loadVoice(filename, catPos, catLen, _sWav[20])) { + warning("Couldn't load sample: %s", filename.c_str()); + _sWav[20]._active = false; + } else { + _sWav[20]._active = true; + // Reduce music volume during speech + if (!_musicOffFl && _musicVolume > 2) { + _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); + setMODMusicVolume(_musicVolume); + } + } playVoice(); _vm->_eventsManager._escKeyFl = false; // Loop for playing voice - breakFlag = 0; + breakFlag = false; do { if (_specialSoundNum != 4 && !_skipRefreshFl) _vm->_eventsManager.VBL(); @@ -603,8 +604,10 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { _vm->_eventsManager.refreshEvents(); if (_vm->_eventsManager._escKeyFl) break; - if (!checkVoiceStatus(2)) + if (!checkVoiceStatus(2) && _sWav[20]._active) breakFlag = true; + if (!_sWav[20]._active && !dispTxtFl) + break; } while (!_vm->shouldQuit() && !breakFlag); @@ -741,7 +744,7 @@ void SoundManager::stopVoice(int voiceIndex) { void SoundManager::playVoice() { if (!_sWav[20]._active) - error("Bad handle"); + return; if (!_voice[2]._status) { int wavIndex = _voice[2]._wavIndex; @@ -767,9 +770,11 @@ bool SoundManager::removeWavSample(int wavIndex) { bool SoundManager::loadVoice(const Common::String &filename, size_t fileOffset, size_t entryLength, SwavItem &item) { Common::File f; if (!f.open(filename)) { - // Fallback from WAV to APC... - if (!f.open(setExtension(filename, ".APC"))) - error("Could not open %s for reading", filename.c_str()); + // Fallback to APC... + if (!f.open(setExtension(filename, ".APC"))) { + warning("Could not open %s for reading", filename.c_str()); + return false; + } } f.seek(fileOffset); @@ -783,9 +788,12 @@ void SoundManager::loadWavSample(int wavIndex, const Common::String &filename, b if (_sWav[wavIndex]._active) removeWavSample(wavIndex); - loadVoice(filename, 0, 0, _sWav[wavIndex]); - _sWav[wavIndex]._active = true; - _sWav[wavIndex]._freeSampleFl = freeSample; + if (loadVoice(filename, 0, 0, _sWav[wavIndex])) { + _sWav[wavIndex]._active = true; + _sWav[wavIndex]._freeSampleFl = freeSample; + } else{ + _sWav[wavIndex]._active = false; + } } void SoundManager::loadWav(const Common::String &file, int wavIndex) { -- cgit v1.2.3 From 9a535ac9f610e8209654fd1f3fdda244f47abe79 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 22 Feb 2013 23:51:29 +0100 Subject: HOPKINS: Remove verbose error messages when the English demo skips the speech loading --- engines/hopkins/sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index b6322b49c0..4df2a2d7d8 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -579,7 +579,6 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { oldMusicVol = _musicVolume; if (!loadVoice(filename, catPos, catLen, _sWav[20])) { - warning("Couldn't load sample: %s", filename.c_str()); _sWav[20]._active = false; } else { _sWav[20]._active = true; @@ -772,7 +771,8 @@ bool SoundManager::loadVoice(const Common::String &filename, size_t fileOffset, if (!f.open(filename)) { // Fallback to APC... if (!f.open(setExtension(filename, ".APC"))) { - warning("Could not open %s for reading", filename.c_str()); + if (!_vm->getIsDemo()) + error("Could not open %s for reading", filename.c_str()); return false; } } -- cgit v1.2.3 From 3787e69e7bca8e207a9e7e2b462027376ad268e4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Feb 2013 10:23:44 +0100 Subject: HOPKINS: Add comments concerning the Win95 UK demo fix --- engines/hopkins/sound.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 4df2a2d7d8..0ea33cd218 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -579,6 +579,10 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { oldMusicVol = _musicVolume; if (!loadVoice(filename, catPos, catLen, _sWav[20])) { + // This case only concerns the English Win95 demo + // If it's not possible to load the voice, we force the active flag + // to false in order to make sure the missing buffer won't be played + // accidentally later _sWav[20]._active = false; } else { _sWav[20]._active = true; @@ -603,8 +607,12 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { _vm->_eventsManager.refreshEvents(); if (_vm->_eventsManager._escKeyFl) break; + // We only check the voice status if the file has been loaded properly + // This avoids skipping completely the talk animations in the Win95 UK Demo if (!checkVoiceStatus(2) && _sWav[20]._active) breakFlag = true; + // This is specific to the Win95 UK Demo again: if nothing is displayed, + // don't wait for a click event. if (!_sWav[20]._active && !dispTxtFl) break; } while (!_vm->shouldQuit() && !breakFlag); @@ -771,6 +779,8 @@ bool SoundManager::loadVoice(const Common::String &filename, size_t fileOffset, if (!f.open(filename)) { // Fallback to APC... if (!f.open(setExtension(filename, ".APC"))) { + // The English demo doesn't include the speech file. + // This avoids it to crash when discussing with other characters if (!_vm->getIsDemo()) error("Could not open %s for reading", filename.c_str()); return false; -- cgit v1.2.3 From b22bb6d46348a3ee6e115ceb6e84674dd763da6a Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 25 Feb 2013 10:27:01 -0500 Subject: HOPKINS: Remove long double usage --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 0ea33cd218..43bceb06f5 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -589,7 +589,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { // Reduce music volume during speech if (!_musicOffFl && _musicVolume > 2) { - _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); + _musicVolume -= _musicVolume * 9 / 20; setMODMusicVolume(_musicVolume); } } -- cgit v1.2.3 From c9b1dd37c5abceda2d9a6415d474c0b980c1f5cf Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 25 Feb 2013 10:32:12 -0500 Subject: HOPKINS: Don't have the TWA/APC code in the Audio namespace --- engines/hopkins/sound.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 43bceb06f5..de8b1115db 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -35,7 +35,7 @@ #include "audio/mods/protracker.h" #include "audio/decoders/raw.h" -namespace Audio { +namespace Hopkins { class APC_ADPCMStream : public Audio::DVI_ADPCMStream { public: @@ -70,7 +70,7 @@ Audio::RewindableAudioStream *makeAPCStream(Common::SeekableReadStream *stream, return new APC_ADPCMStream(stream, disposeAfterUse, rate, stereo ? 2 : 1); } -class TwaAudioStream : public AudioStream { +class TwaAudioStream : public Audio::AudioStream { public: TwaAudioStream(Common::String name, Common::SeekableReadStream *stream) { _name = name; @@ -152,7 +152,7 @@ protected: Common::File *file = new Common::File(); if (file->open(filename + ".APC")) { - _cueStream = Audio::makeAPCStream(file, DisposeAfterUse::YES); + _cueStream = makeAPCStream(file, DisposeAfterUse::YES); return true; } @@ -184,12 +184,6 @@ Audio::AudioStream *makeTwaStream(Common::String name, Common::SeekableReadStrea return new TwaAudioStream(name, stream); } -} - -/*------------------------------------------------------------------------*/ - -namespace Hopkins { - SoundManager::SoundManager() { _specialSoundNum = 0; _soundVolume = 0; @@ -436,7 +430,7 @@ void SoundManager::loadMusic(const Common::String &file) { if (!f.open(filename)) error("Error opening file %s", filename.c_str()); - Audio::AudioStream *twaStream = Audio::makeTwaStream(file.c_str(), &f); + Audio::AudioStream *twaStream = makeTwaStream(file.c_str(), &f); _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, twaStream); f.close(); } @@ -897,7 +891,7 @@ void SoundManager::updateScummVMSoundSettings() { */ Audio::RewindableAudioStream *SoundManager::makeSoundStream(Common::SeekableReadStream *stream) { if (_vm->getPlatform() == Common::kPlatformWindows) - return Audio::makeAPCStream(stream, DisposeAfterUse::YES); + return makeAPCStream(stream, DisposeAfterUse::YES); else if (_vm->getPlatform() == Common::kPlatformLinux) return Audio::makeWAVStream(stream, DisposeAfterUse::YES); else -- cgit v1.2.3 From 58eefc0833a540213298f75e87222b12831dd1f7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Feb 2013 00:15:54 +0100 Subject: HOPKINS: Get rid of magic values in FilesManager --- engines/hopkins/sound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index de8b1115db..55c1155008 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -520,7 +520,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { filename = Common::String::format("%s%d", prefix.c_str(), mappedFileNumber); - if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { + if (!_vm->_fileManager.searchCat(filename + ".WAV", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names @@ -533,7 +533,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; - } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { + } else if (!_vm->_fileManager.searchCat(filename + ".APC", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names @@ -546,7 +546,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; - } else if (!_vm->_fileManager.searchCat(filename + ".RAW", 9)) { + } else if (!_vm->_fileManager.searchCat(filename + ".RAW", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names -- cgit v1.2.3 From 23badc97357162bfe8de06afc679b459c70d2f27 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 4 Mar 2013 07:46:15 +0100 Subject: HOPKINS: Some renaming --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 55c1155008..62504dadfd 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -595,7 +595,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { breakFlag = false; do { if (_specialSoundNum != 4 && !_skipRefreshFl) - _vm->_eventsManager.VBL(); + _vm->_eventsManager.refreshScreenAndEvents(); if (_vm->_eventsManager.getMouseButton()) break; _vm->_eventsManager.refreshEvents(); -- cgit v1.2.3 From db6d7e256bd1a1654002005fec3524ddcd300c75 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Mar 2013 20:40:55 +0100 Subject: HOPKINS: Remove setParent() from EventsManager and Debugger --- engines/hopkins/sound.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 62504dadfd..c7025ec260 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -589,17 +589,17 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { } playVoice(); - _vm->_eventsManager._escKeyFl = false; + _vm->_eventsManager->_escKeyFl = false; // Loop for playing voice breakFlag = false; do { if (_specialSoundNum != 4 && !_skipRefreshFl) - _vm->_eventsManager.refreshScreenAndEvents(); - if (_vm->_eventsManager.getMouseButton()) + _vm->_eventsManager->refreshScreenAndEvents(); + if (_vm->_eventsManager->getMouseButton()) break; - _vm->_eventsManager.refreshEvents(); - if (_vm->_eventsManager._escKeyFl) + _vm->_eventsManager->refreshEvents(); + if (_vm->_eventsManager->_escKeyFl) break; // We only check the voice status if the file has been loaded properly // This avoids skipping completely the talk animations in the Win95 UK Demo @@ -620,7 +620,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { if (!_musicOffFl && _musicVolume > 2) { setMODMusicVolume(_musicVolume); } - _vm->_eventsManager._escKeyFl = false; + _vm->_eventsManager->_escKeyFl = false; _skipRefreshFl = false; return true; } -- cgit v1.2.3 From f2d4151dd7db6eb0bffc4874825b15e22f61a36f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Mar 2013 21:57:28 +0100 Subject: HOPKINS: Remove setParent() from FileManager --- engines/hopkins/sound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index c7025ec260..d7a6c81a51 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -520,7 +520,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { filename = Common::String::format("%s%d", prefix.c_str(), mappedFileNumber); - if (!_vm->_fileManager.searchCat(filename + ".WAV", RES_VOI)) { + if (!_vm->_fileManager->searchCat(filename + ".WAV", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names @@ -533,7 +533,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; - } else if (!_vm->_fileManager.searchCat(filename + ".APC", RES_VOI)) { + } else if (!_vm->_fileManager->searchCat(filename + ".APC", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names @@ -546,7 +546,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; - } else if (!_vm->_fileManager.searchCat(filename + ".RAW", RES_VOI)) { + } else if (!_vm->_fileManager->searchCat(filename + ".RAW", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names -- cgit v1.2.3 From 852e65bd02bc1278386d79ca68f81e3d15e9fa43 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Mar 2013 07:27:42 +0100 Subject: HOPKINS: Remove setParent() from Globals --- engines/hopkins/sound.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index d7a6c81a51..600ecba0b1 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -273,7 +273,7 @@ void SoundManager::loadAnimSound() { } void SoundManager::playAnimSound(int soundNumber) { - if (!_vm->_globals._censorshipFl && _specialSoundNum == 2) { + if (!_vm->_globals->_censorshipFl && _specialSoundNum == 2) { switch (soundNumber) { case 20: playSample(5); @@ -524,41 +524,41 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names - else if (_vm->_globals._language == LANG_FR) + else if (_vm->_globals->_language == LANG_FR) filename = "RES_VFR.RES"; - else if (_vm->_globals._language == LANG_EN) + else if (_vm->_globals->_language == LANG_EN) filename = "RES_VAN.RES"; - else if (_vm->_globals._language == LANG_SP) + else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_globals._catalogPos; - catLen = _vm->_globals._catalogSize; + catPos = _vm->_globals->_catalogPos; + catLen = _vm->_globals->_catalogSize; } else if (!_vm->_fileManager->searchCat(filename + ".APC", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names - else if (_vm->_globals._language == LANG_FR) + else if (_vm->_globals->_language == LANG_FR) filename = "RES_VFR.RES"; - else if (_vm->_globals._language == LANG_EN) + else if (_vm->_globals->_language == LANG_EN) filename = "RES_VAN.RES"; - else if (_vm->_globals._language == LANG_SP) + else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_globals._catalogPos; - catLen = _vm->_globals._catalogSize; + catPos = _vm->_globals->_catalogPos; + catLen = _vm->_globals->_catalogSize; } else if (!_vm->_fileManager->searchCat(filename + ".RAW", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names - else if (_vm->_globals._language == LANG_FR) + else if (_vm->_globals->_language == LANG_FR) filename = "RES_VFR.RES"; - else if (_vm->_globals._language == LANG_EN) + else if (_vm->_globals->_language == LANG_EN) filename = "RES_VAN.RES"; - else if (_vm->_globals._language == LANG_SP) + else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_globals._catalogPos; - catLen = _vm->_globals._catalogSize; + catPos = _vm->_globals->_catalogPos; + catLen = _vm->_globals->_catalogSize; } else { if (!f.exists(filename + ".WAV")) { if (!f.exists(filename + ".APC")) -- cgit v1.2.3 From 73b01f20af4100d10b459c2589e3188cec7deb1f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Mar 2013 08:10:28 +0100 Subject: HOPKINS: Remove setParent() from TalkManager --- engines/hopkins/sound.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 600ecba0b1..b64430fae2 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -184,7 +184,9 @@ Audio::AudioStream *makeTwaStream(Common::String name, Common::SeekableReadStrea return new TwaAudioStream(name, stream); } -SoundManager::SoundManager() { +SoundManager::SoundManager(HopkinsEngine *vm) { + _vm = vm; + _specialSoundNum = 0; _soundVolume = 0; _voiceVolume = 0; @@ -215,11 +217,6 @@ SoundManager::~SoundManager() { _modPlayingFl = false; } -void SoundManager::setParent(HopkinsEngine *vm) { - _vm = vm; - _specialSoundNum = 0; -} - void SoundManager::checkSoundEnd() { if (!_soundOffFl && _soundFl) { if (!checkVoiceStatus(1)) { -- cgit v1.2.3 From 510eb83aaccd4460887881bd373e403a4d0917cf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 21 Mar 2013 07:19:10 +0100 Subject: HOPKINS: Simplify a couple of tests in SoundManager --- engines/hopkins/sound.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index b64430fae2..1605b0350e 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -732,10 +732,8 @@ void SoundManager::stopVoice(int voiceIndex) { if (_voice[voiceIndex]._status) { _voice[voiceIndex]._status = false; int wavIndex = _voice[voiceIndex]._wavIndex; - if (_sWav[wavIndex]._active) { - if (_sWav[wavIndex]._freeSampleFl) - removeWavSample(wavIndex); - } + if (_sWav[wavIndex]._active && _sWav[wavIndex]._freeSampleFl) + removeWavSample(wavIndex); } _voice[voiceIndex]._status = false; } @@ -802,21 +800,23 @@ void SoundManager::loadWav(const Common::String &file, int wavIndex) { } void SoundManager::playWav(int wavIndex) { - if (!_soundFl && !_soundOffFl) { - _soundFl = true; - _currentSoundIndex = wavIndex; - playWavSample(1, wavIndex); - } + if (_soundFl || _soundOffFl) + return; + + _soundFl = true; + _currentSoundIndex = wavIndex; + playWavSample(1, wavIndex); } void SoundManager::delWav(int wavIndex) { - if (removeWavSample(wavIndex)) { - if (checkVoiceStatus(1)) - stopVoice(1); + if (!removeWavSample(wavIndex)) + return; - _currentSoundIndex = 0; - _soundFl = false; - } + if (checkVoiceStatus(1)) + stopVoice(1); + + _currentSoundIndex = 0; + _soundFl = false; } void SoundManager::playWavSample(int voiceIndex, int wavIndex) { -- cgit v1.2.3 From ac338c3517d85156e83884164d378c3bf76851e5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Mar 2013 22:56:06 +0100 Subject: HOPKINS: Some more refactoring in Globals --- engines/hopkins/sound.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 1605b0350e..246e611642 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -528,8 +528,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_globals->_catalogPos; - catLen = _vm->_globals->_catalogSize; + catPos = _vm->_fileManager->_catalogPos; + catLen = _vm->_fileManager->_catalogSize; } else if (!_vm->_fileManager->searchCat(filename + ".APC", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; @@ -541,8 +541,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_globals->_catalogPos; - catLen = _vm->_globals->_catalogSize; + catPos = _vm->_fileManager->_catalogPos; + catLen = _vm->_fileManager->_catalogSize; } else if (!_vm->_fileManager->searchCat(filename + ".RAW", RES_VOI)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; @@ -554,8 +554,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_globals->_catalogPos; - catLen = _vm->_globals->_catalogSize; + catPos = _vm->_fileManager->_catalogPos; + catLen = _vm->_fileManager->_catalogSize; } else { if (!f.exists(filename + ".WAV")) { if (!f.exists(filename + ".APC")) -- cgit v1.2.3 From 4b21ec23d0e445d8364bcab5732318734f4c27cc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Apr 2013 23:57:38 +0200 Subject: HOPKINS: Refactor searchCat to remove the use of g_PTRNUL, add a parameter to clarify the result of the function --- engines/hopkins/sound.cpp | 81 +++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 37 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 246e611642..e192516707 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -517,33 +517,9 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { filename = Common::String::format("%s%d", prefix.c_str(), mappedFileNumber); - if (!_vm->_fileManager->searchCat(filename + ".WAV", RES_VOI)) { - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - filename = "ENG_VOI.RES"; - // Win95 and Linux versions uses another set of names - else if (_vm->_globals->_language == LANG_FR) - filename = "RES_VFR.RES"; - else if (_vm->_globals->_language == LANG_EN) - filename = "RES_VAN.RES"; - else if (_vm->_globals->_language == LANG_SP) - filename = "RES_VES.RES"; - - catPos = _vm->_fileManager->_catalogPos; - catLen = _vm->_fileManager->_catalogSize; - } else if (!_vm->_fileManager->searchCat(filename + ".APC", RES_VOI)) { - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - filename = "ENG_VOI.RES"; - // Win95 and Linux versions uses another set of names - else if (_vm->_globals->_language == LANG_FR) - filename = "RES_VFR.RES"; - else if (_vm->_globals->_language == LANG_EN) - filename = "RES_VAN.RES"; - else if (_vm->_globals->_language == LANG_SP) - filename = "RES_VES.RES"; - - catPos = _vm->_fileManager->_catalogPos; - catLen = _vm->_fileManager->_catalogSize; - } else if (!_vm->_fileManager->searchCat(filename + ".RAW", RES_VOI)) { + bool fileFoundFl = false; + _vm->_fileManager->searchCat(filename + ".WAV", RES_VOI, fileFoundFl); + if (fileFoundFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names @@ -557,17 +533,48 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { catPos = _vm->_fileManager->_catalogPos; catLen = _vm->_fileManager->_catalogSize; } else { - if (!f.exists(filename + ".WAV")) { - if (!f.exists(filename + ".APC")) - return false; - filename = filename + ".APC"; - } else - filename = filename + ".WAV"; - - catPos = 0; - catLen = 0; + _vm->_fileManager->searchCat(filename + ".APC", RES_VOI, fileFoundFl); + if (fileFoundFl) { + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + filename = "ENG_VOI.RES"; + // Win95 and Linux versions uses another set of names + else if (_vm->_globals->_language == LANG_FR) + filename = "RES_VFR.RES"; + else if (_vm->_globals->_language == LANG_EN) + filename = "RES_VAN.RES"; + else if (_vm->_globals->_language == LANG_SP) + filename = "RES_VES.RES"; + + catPos = _vm->_fileManager->_catalogPos; + catLen = _vm->_fileManager->_catalogSize; + } else { + _vm->_fileManager->searchCat(filename + ".RAW", RES_VOI, fileFoundFl); + if (fileFoundFl) { + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + filename = "ENG_VOI.RES"; + // Win95 and Linux versions uses another set of names + else if (_vm->_globals->_language == LANG_FR) + filename = "RES_VFR.RES"; + else if (_vm->_globals->_language == LANG_EN) + filename = "RES_VAN.RES"; + else if (_vm->_globals->_language == LANG_SP) + filename = "RES_VES.RES"; + + catPos = _vm->_fileManager->_catalogPos; + catLen = _vm->_fileManager->_catalogSize; + } else { + if (!f.exists(filename + ".WAV")) { + if (!f.exists(filename + ".APC")) + return false; + filename = filename + ".APC"; + } else + filename = filename + ".WAV"; + + catPos = 0; + catLen = 0; + } + } } - oldMusicVol = _musicVolume; if (!loadVoice(filename, catPos, catLen, _sWav[20])) { // This case only concerns the English Win95 demo -- cgit v1.2.3 From 2ee8b1e342eca39602b2e5fc8cbdb9f505d49bcb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 5 Apr 2013 01:43:10 +0200 Subject: HOPKINS: Misc cleanup --- engines/hopkins/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e192516707..909f563a3c 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -728,7 +728,7 @@ void SoundManager::playSample(int wavIndex, int voiceMode) { bool SoundManager::checkVoiceStatus(int voiceIndex) { if (_voice[voiceIndex]._status) { int wavIndex = _voice[voiceIndex]._wavIndex; - if (_sWav[wavIndex]._audioStream != NULL && _sWav[wavIndex]._audioStream->endOfStream()) + if (_sWav[wavIndex]._audioStream && _sWav[wavIndex]._audioStream->endOfStream()) stopVoice(voiceIndex); } -- cgit v1.2.3 From 89bf72ff5d608b86c6efc413baedff7618f4b44e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 5 Apr 2013 08:17:26 +0200 Subject: HOPKINS: JANITORIAL: Remove trailing spaces and tabs --- engines/hopkins/sound.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 909f563a3c..f30ca4a401 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -609,7 +609,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { // This avoids skipping completely the talk animations in the Win95 UK Demo if (!checkVoiceStatus(2) && _sWav[20]._active) breakFlag = true; - // This is specific to the Win95 UK Demo again: if nothing is displayed, + // This is specific to the Win95 UK Demo again: if nothing is displayed, // don't wait for a click event. if (!_sWav[20]._active && !dispTxtFl) break; @@ -700,12 +700,12 @@ void SoundManager::playSample(int wavIndex, int voiceMode) { if (_soundFl) delWav(_currentSoundIndex); - + switch (voiceMode) { case 5: case 8: // Case added to identify the former PLAY_SAMPLE2 calls - case 9: + case 9: if (checkVoiceStatus(1)) stopVoice(1); playWavSample(1, wavIndex); @@ -775,7 +775,7 @@ bool SoundManager::loadVoice(const Common::String &filename, size_t fileOffset, if (!f.open(filename)) { // Fallback to APC... if (!f.open(setExtension(filename, ".APC"))) { - // The English demo doesn't include the speech file. + // The English demo doesn't include the speech file. // This avoids it to crash when discussing with other characters if (!_vm->getIsDemo()) error("Could not open %s for reading", filename.c_str()); -- cgit v1.2.3 From 55938b39755f2bac9fa180aa3f646fa8041b059c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Apr 2013 10:27:06 +0200 Subject: HOPKINS: Make engine less verbose by reducing some object names --- engines/hopkins/sound.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/hopkins/sound.cpp') diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index f30ca4a401..d8dfba5246 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -518,7 +518,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { filename = Common::String::format("%s%d", prefix.c_str(), mappedFileNumber); bool fileFoundFl = false; - _vm->_fileManager->searchCat(filename + ".WAV", RES_VOI, fileFoundFl); + _vm->_fileIO->searchCat(filename + ".WAV", RES_VOI, fileFoundFl); if (fileFoundFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; @@ -530,10 +530,10 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_fileManager->_catalogPos; - catLen = _vm->_fileManager->_catalogSize; + catPos = _vm->_fileIO->_catalogPos; + catLen = _vm->_fileIO->_catalogSize; } else { - _vm->_fileManager->searchCat(filename + ".APC", RES_VOI, fileFoundFl); + _vm->_fileIO->searchCat(filename + ".APC", RES_VOI, fileFoundFl); if (fileFoundFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; @@ -545,10 +545,10 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_fileManager->_catalogPos; - catLen = _vm->_fileManager->_catalogSize; + catPos = _vm->_fileIO->_catalogPos; + catLen = _vm->_fileIO->_catalogSize; } else { - _vm->_fileManager->searchCat(filename + ".RAW", RES_VOI, fileFoundFl); + _vm->_fileIO->searchCat(filename + ".RAW", RES_VOI, fileFoundFl); if (fileFoundFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; @@ -560,8 +560,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { else if (_vm->_globals->_language == LANG_SP) filename = "RES_VES.RES"; - catPos = _vm->_fileManager->_catalogPos; - catLen = _vm->_fileManager->_catalogSize; + catPos = _vm->_fileIO->_catalogPos; + catLen = _vm->_fileIO->_catalogSize; } else { if (!f.exists(filename + ".WAV")) { if (!f.exists(filename + ".APC")) @@ -593,17 +593,17 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { } playVoice(); - _vm->_eventsManager->_escKeyFl = false; + _vm->_events->_escKeyFl = false; // Loop for playing voice breakFlag = false; do { if (_specialSoundNum != 4 && !_skipRefreshFl) - _vm->_eventsManager->refreshScreenAndEvents(); - if (_vm->_eventsManager->getMouseButton()) + _vm->_events->refreshScreenAndEvents(); + if (_vm->_events->getMouseButton()) break; - _vm->_eventsManager->refreshEvents(); - if (_vm->_eventsManager->_escKeyFl) + _vm->_events->refreshEvents(); + if (_vm->_events->_escKeyFl) break; // We only check the voice status if the file has been loaded properly // This avoids skipping completely the talk animations in the Win95 UK Demo @@ -624,7 +624,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { if (!_musicOffFl && _musicVolume > 2) { setMODMusicVolume(_musicVolume); } - _vm->_eventsManager->_escKeyFl = false; + _vm->_events->_escKeyFl = false; _skipRefreshFl = false; return true; } -- cgit v1.2.3