aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2013-02-22 19:23:21 +0100
committerStrangerke2013-02-22 19:23:21 +0100
commit5297f6370749dfaff9b6b80ea9f10b855cd1b58f (patch)
tree68414532c8884dd18ee83f89041b0a9f9a72e874 /engines
parent29c664a6966cd333862f2d1d3cd09a182be7f985 (diff)
downloadscummvm-rg350-5297f6370749dfaff9b6b80ea9f10b855cd1b58f.tar.gz
scummvm-rg350-5297f6370749dfaff9b6b80ea9f10b855cd1b58f.tar.bz2
scummvm-rg350-5297f6370749dfaff9b6b80ea9f10b855cd1b58f.zip
HOPKINS: Fix the crash related to the missing speech file in the Win95 English demo
Diffstat (limited to 'engines')
-rw-r--r--engines/hopkins/lines.cpp1
-rw-r--r--engines/hopkins/objects.cpp7
-rw-r--r--engines/hopkins/script.cpp26
-rw-r--r--engines/hopkins/sound.cpp48
-rw-r--r--engines/hopkins/sound.h2
-rw-r--r--engines/hopkins/talk.cpp4
6 files changed, 55 insertions, 33 deletions
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 77b9d4b6cd..ebf48a7d21 100644
--- a/engines/hopkins/lines.cpp
+++ b/engines/hopkins/lines.cpp
@@ -153,6 +153,7 @@ int LinesManager::checkInventoryHotspots(int posX, int posY) {
*/
int LinesManager::checkInventoryHotspotsRow(int posX, int minZoneNum, bool lastRow) {
int result = minZoneNum;
+
if (posX >= _vm->_graphicsManager._scrollOffset + 158 && posX < _vm->_graphicsManager._scrollOffset + 208)
return result;
diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp
index 959d1e9046..b37dac2f6e 100644
--- a/engines/hopkins/objects.cpp
+++ b/engines/hopkins/objects.cpp
@@ -3218,13 +3218,14 @@ void ObjectsManager::SPECIAL_INI() {
_vm->_eventsManager.VBL();
VBOB(_vm->_globals.SPRITE_ECRAN, 5, 15, 28, 1);
_vm->_fontManager.hideText(9);
+ bool displayedTxtFl = false;
if (!_vm->_soundManager._textOffFl) {
_vm->_fontManager.initTextBuffers(9, 383, _vm->_globals._textFilename, 220, 72, 6, 36, 253);
- if (!_vm->_soundManager._textOffFl)
- _vm->_fontManager.showText(9);
+ _vm->_fontManager.showText(9);
+ displayedTxtFl = true;
}
if (!_vm->_soundManager._voiceOffFl)
- _vm->_soundManager.mixVoice(383, 4);
+ _vm->_soundManager.mixVoice(383, 4, displayedTxtFl);
_vm->_globals._saveData->_data[svField270] = 1;
_vm->_globals._saveData->_data[svField300] = 1;
_vm->_globals._saveData->_data[svField320] = 1;
diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp
index 691a9ec65f..c133b3e9d8 100644
--- a/engines/hopkins/script.cpp
+++ b/engines/hopkins/script.cpp
@@ -132,22 +132,27 @@ int ScriptManager::handleOpcode(byte *dataP) {
_vm->_eventsManager.VBL();
} while (_vm->_soundManager._soundFl);
}
+ bool displayedTxtFl = false;
if (!_vm->_soundManager._textOffFl) {
int textPosX = READ_LE_INT16(dataP + 9);
int textPosY = READ_LE_INT16(dataP + 11);
_vm->_fontManager.initTextBuffers(9, mesgId, _vm->_globals._textFilename, 2 * textPosX, 2 * textPosY + 40, 6, dataP[7], 253);
- if (!_vm->_soundManager._textOffFl)
- _vm->_fontManager.showText(9);
+ _vm->_fontManager.showText(9);
+ displayedTxtFl = true;
}
if (!_vm->_soundManager._voiceOffFl)
- _vm->_soundManager.mixVoice(mesgId, 4);
+ _vm->_soundManager.mixVoice(mesgId, 4, displayedTxtFl);
} else { // if (TRAVAILOBJET)
if (_vm->_globals._saveData->_data[svField356]) {
_vm->_fontManager.initTextBuffers(9, 635, _vm->_globals._textFilename, 55, 20, dataP[8], 35, 253);
- if (!_vm->_soundManager._textOffFl)
+ bool displayedTxtFl = false;
+ if (!_vm->_soundManager._textOffFl) {
_vm->_fontManager.showText(9);
+ displayedTxtFl = true;
+ }
+
if (!_vm->_soundManager._voiceOffFl)
- _vm->_soundManager.mixVoice(635, 4);
+ _vm->_soundManager.mixVoice(635, 4, displayedTxtFl);
} else {
int textPosX = READ_LE_INT16(dataP + 9);
if (_vm->_globals._language == LANG_FR && !_vm->_soundManager._textOffFl)
@@ -158,11 +163,14 @@ int ScriptManager::handleOpcode(byte *dataP) {
_vm->_fontManager.initTextBuffers(9, mesgId, "OBJETES.TXT", 2 * textPosX, 60, 6, dataP[7], 253);
}
- if (!_vm->_soundManager._textOffFl)
+ bool displayedTxtFl = false;
+ if (!_vm->_soundManager._textOffFl) {
_vm->_fontManager.showText(9);
+ displayedTxtFl = true;
+ }
if (!_vm->_soundManager._voiceOffFl)
- _vm->_soundManager.mixVoice(mesgId, 5);
+ _vm->_soundManager.mixVoice(mesgId, 5, displayedTxtFl);
}
}
break;
@@ -2163,12 +2171,14 @@ int ScriptManager::handleOpcode(byte *dataP) {
_vm->_objectsManager.stopBobAnimation(1);
_vm->_objectsManager.setBobAnimation(2);
_vm->_fontManager.hideText(9);
+ bool displayedTxtFl = false;
if (!_vm->_soundManager._textOffFl) {
_vm->_fontManager.initTextBuffers(9, 617, _vm->_globals._textFilename, 91, 41, 3, 30, 253);
_vm->_fontManager.showText(9);
+ displayedTxtFl = true;
}
if (!_vm->_soundManager._voiceOffFl)
- _vm->_soundManager.mixVoice(617, 4);
+ _vm->_soundManager.mixVoice(617, 4, displayedTxtFl);
for (int i = 0; i <= 29; i++) {
if (_vm->shouldQuit())
return -1; // Exiting game
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) {
diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h
index 9e89d10110..1a3060264a 100644
--- a/engines/hopkins/sound.h
+++ b/engines/hopkins/sound.h
@@ -123,7 +123,7 @@ public:
void updateScummVMSoundSettings();
void syncSoundSettings();
- bool mixVoice(int voiceId, int voiceMode);
+ bool mixVoice(int voiceId, int voiceMode, bool displTxtFl = false);
void setMODMusicVolume(int volume);
void setMODSampleVolume();
diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp
index d8e37924fe..d3c60a056e 100644
--- a/engines/hopkins/talk.cpp
+++ b/engines/hopkins/talk.cpp
@@ -380,11 +380,13 @@ int TalkManager::dialogAnswer(int idx, bool animatedFl) {
VISU_PARLE();
}
+ bool displayedTxtFl = false;
if (!_vm->_soundManager._textOffFl) {
_vm->_fontManager.initTextBuffers(9, mesgId, _answersFilename, mesgPosX, mesgPosY, 5, mesgLength, 252);
_vm->_fontManager.showText(9);
+ displayedTxtFl = true;
}
- if (!_vm->_soundManager.mixVoice(mesgId, 1)) {
+ if (!_vm->_soundManager.mixVoice(mesgId, 1, displayedTxtFl)) {
_vm->_eventsManager._curMouseButton = 0;
_vm->_eventsManager._mouseButton = 0;