aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2012-12-27 19:08:10 +0100
committerStrangerke2012-12-27 19:08:10 +0100
commitc07beb64455b3d30300176a99aed7140c0a090e0 (patch)
tree4ccf904b816aad0a1161ccf177f550968a12d765
parent7997011d2f93051b4d01efb3ff71f883fe242da9 (diff)
downloadscummvm-rg350-c07beb64455b3d30300176a99aed7140c0a090e0.tar.gz
scummvm-rg350-c07beb64455b3d30300176a99aed7140c0a090e0.tar.bz2
scummvm-rg350-c07beb64455b3d30300176a99aed7140c0a090e0.zip
HOPKINS: Some refactoring in showComputer
-rw-r--r--engines/hopkins/computer.cpp87
-rw-r--r--engines/hopkins/dialogs.cpp54
-rw-r--r--engines/hopkins/sound.cpp44
-rw-r--r--engines/hopkins/sound.h8
4 files changed, 83 insertions, 110 deletions
diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp
index 8809dc3145..668bd53c85 100644
--- a/engines/hopkins/computer.cpp
+++ b/engines/hopkins/computer.cpp
@@ -119,17 +119,10 @@ void ComputerManager::setTextPosition(int yp, int xp) {
* @param mode Which computer to display
*/
void ComputerManager::showComputer(ComputerEnum mode) {
- bool passwordMatch;
- char *v3;
- char s[12];
- const char *s2;
-
_vm->_eventsManager._escKeyFl = false;
- passwordMatch = false;
_vm->_graphicsManager.RESET_SEGMENT_VESA();
setVideoMode();
setTextColor(4);
-
setTextPosition(2, 4);
if (mode == COMPUTER_HOPKINS)
outText(Common::String(_menuText[0]._line));
@@ -147,48 +140,16 @@ void ComputerManager::showComputer(ComputerEnum mode) {
outText(Common::String(_menuText[4]._line));
setTextPosition(14, 35);
- memset(s, 0, 12);
TXT4(280, 224, 8);
- strcpy(s, _inputBuf);
- v3 = &s[0];
-
+ bool passwordMatch = false;
if (mode == COMPUTER_HOPKINS) {
- s2 = "HOPKINS";
- int v4 = 8;
- char v5 = 1;
- do {
- if (!v4)
- break;
- v5 = *v3++ == *s2++;
- --v4;
- } while (v5);
- if (v5)
+ if (!strcmp(_inputBuf, "HOPKINS"))
passwordMatch = true;
} else if (mode == COMPUTER_SAMANTHAS) {
- char *v6 = &s[0];
- s2 = "328MHZA";
- int v7 = 8;
- bool v8 = true;
- do {
- if (!v7)
- break;
- v8 = (*v6++ == *s2++);
- --v7;
- } while (v8);
- if (v8)
+ if (!strcmp(_inputBuf, "328MHZA"))
passwordMatch = true;
} else if (mode == COMPUTER_PUBLIC) {
- char *v9 = &s[0];
- s2 = "ALLFREE";
- int v10 = 8;
- bool v11 = true;
- do {
- if (!v10)
- break;
- v11 = (*v9++ == *s2++);
- --v10;
- } while (v11);
- if (v11)
+ if (!strcmp(_inputBuf, "ALLFREE"))
passwordMatch = true;
}
@@ -234,21 +195,21 @@ void ComputerManager::showComputer(ComputerEnum mode) {
}
bool numericFlag = false;
- char v12;
+ char keyPressed;
do {
- v12 = _vm->_eventsManager.waitKeyPress();
+ keyPressed = _vm->_eventsManager.waitKeyPress();
if (_vm->shouldQuit())
return;
- if ((uint16)(v12 - 48) <= 8u)
+ if ((keyPressed >= '0') && (keyPressed <= '9'))
numericFlag = true;
} while (!numericFlag);
// 0 - Quit
- if (v12 == '0')
+ if (keyPressed == '0')
break;
// 1 - Games
- if (v12 == '1') {
+ if (keyPressed == '1') {
displayGamesSubMenu();
} else if (mode == COMPUTER_HOPKINS) {
clearScreen();
@@ -256,31 +217,43 @@ void ComputerManager::showComputer(ComputerEnum mode) {
setTextPosition(2, 4);
outText(Common::String(_menuText[0]._line));
setTextColor(15);
- if (v12 == 50)
+ switch (keyPressed) {
+ case '2':
readText(1);
- if (v12 == 51)
+ break;
+ case '3':
readText(2);
- if (v12 == 52)
+ break;
+ case '4':
readText(3);
- if (v12 == 53)
+ break;
+ case '5':
readText(4);
+ break;
+ }
} else if (mode == COMPUTER_SAMANTHAS) {
clearScreen();
setTextColor(4);
setTextPosition(2, 4);
outText(Common::String(_menuText[1]._line));
setTextColor(15);
- if (v12 == 50)
+ switch (keyPressed) {
+ case '2':
readText(6);
- if (v12 == 51)
+ break;
+ case '3':
readText(7);
- if (v12 == 52)
+ break;
+ case '4':
readText(8);
- if (v12 == 53)
+ break;
+ case '5':
readText(9);
- if (v12 == 54) {
+ break;
+ case '6':
readText(10);
_vm->_globals._saveData->data[svField270] = 4;
+ break;
}
}
}
diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp
index 1f1a009e1b..1260f92b7d 100644
--- a/engines/hopkins/dialogs.cpp
+++ b/engines/hopkins/dialogs.cpp
@@ -75,50 +75,50 @@ void DialogsManager::showOptionsDialog() {
mousePos.x = _vm->_eventsManager.getMouseX();
mousePos.y = _vm->_eventsManager.getMouseY();
- if (!_vm->_soundManager._musicOff) {
+ if (!_vm->_soundManager._musicOffFl) {
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 138) {
// Change the music volume
- ++_vm->_soundManager.MUSICVOL;
+ ++_vm->_soundManager._musicVolume;
- if (_vm->_soundManager.MUSICVOL <= 12)
+ if (_vm->_soundManager._musicVolume <= 12)
_vm->_soundManager.playSound("bruit2.wav");
else
- _vm->_soundManager.MUSICVOL = 12;
- _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
+ _vm->_soundManager._musicVolume = 12;
+ _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume);
_vm->_soundManager.updateScummVMSoundSettings();
}
- if (!_vm->_soundManager._musicOff && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 138) {
- --_vm->_soundManager.MUSICVOL;
- if (_vm->_soundManager.MUSICVOL >= 0)
+ if (!_vm->_soundManager._musicOffFl && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 138) {
+ --_vm->_soundManager._musicVolume;
+ if (_vm->_soundManager._musicVolume >= 0)
_vm->_soundManager.playSound("bruit2.wav");
else
- _vm->_soundManager.MUSICVOL = 0;
+ _vm->_soundManager._musicVolume = 0;
- _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
+ _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume);
_vm->_soundManager.updateScummVMSoundSettings();
}
}
if (!_vm->_soundManager._soundOffFl) {
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 140 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 165) {
- ++_vm->_soundManager.SOUNDVOL;
- if (_vm->_soundManager.SOUNDVOL <= 16)
+ ++_vm->_soundManager._soundVolume;
+ if (_vm->_soundManager._soundVolume <= 16)
_vm->_soundManager.playSound("bruit2.wav");
else
- _vm->_soundManager.SOUNDVOL = 16;
+ _vm->_soundManager._soundVolume = 16;
_vm->_soundManager.MODSetSampleVolume();
_vm->_soundManager.updateScummVMSoundSettings();
}
if (!_vm->_soundManager._soundOffFl && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 140 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 165) {
- --_vm->_soundManager.SOUNDVOL;
- if (_vm->_soundManager.SOUNDVOL >= 0)
+ --_vm->_soundManager._soundVolume;
+ if (_vm->_soundManager._soundVolume >= 0)
_vm->_soundManager.playSound("bruit2.wav");
else
- _vm->_soundManager.SOUNDVOL = 0;
+ _vm->_soundManager._soundVolume = 0;
_vm->_soundManager.MODSetSampleVolume();
_vm->_soundManager.updateScummVMSoundSettings();
@@ -127,23 +127,23 @@ void DialogsManager::showOptionsDialog() {
if (!_vm->_soundManager._voiceOffFl) {
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 167 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 192) {
- ++_vm->_soundManager.VOICEVOL;
+ ++_vm->_soundManager._voiceVolume;
- if (_vm->_soundManager.VOICEVOL <= 16)
+ if (_vm->_soundManager._voiceVolume <= 16)
_vm->_soundManager.playSound("bruit2.wav");
else
- _vm->_soundManager.VOICEVOL = 16;
+ _vm->_soundManager._voiceVolume = 16;
_vm->_soundManager.MODSetVoiceVolume();
_vm->_soundManager.updateScummVMSoundSettings();
}
if (!_vm->_soundManager._voiceOffFl && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 167 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 192) {
- --_vm->_soundManager.VOICEVOL;
- if (_vm->_soundManager.VOICEVOL >= 0)
+ --_vm->_soundManager._voiceVolume;
+ if (_vm->_soundManager._voiceVolume >= 0)
_vm->_soundManager.playSound("bruit2.wav");
else
- _vm->_soundManager.VOICEVOL = 0;
+ _vm->_soundManager._voiceVolume = 0;
_vm->_soundManager.MODSetVoiceVolume();
_vm->_soundManager.updateScummVMSoundSettings();
@@ -162,11 +162,11 @@ void DialogsManager::showOptionsDialog() {
}
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431) {
if (mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 138) {
- if (_vm->_soundManager._musicOff) {
- _vm->_soundManager._musicOff = false;
- _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
+ if (_vm->_soundManager._musicOffFl) {
+ _vm->_soundManager._musicOffFl = false;
+ _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume);
} else {
- _vm->_soundManager._musicOff = true;
+ _vm->_soundManager._musicOffFl = true;
_vm->_soundManager.MODSetMusicVolume(0);
}
@@ -249,7 +249,7 @@ void DialogsManager::showOptionsDialog() {
_vm->_globals.opt_txt = !_vm->_soundManager._textOffFl ? 7 : 8;
_vm->_globals.opt_voice = !_vm->_soundManager._voiceOffFl ? 7 : 8;
_vm->_globals.opt_sound = !_vm->_soundManager._soundOffFl ? 7 : 8;
- _vm->_globals.opt_music = !_vm->_soundManager._musicOff ? 7 : 8;
+ _vm->_globals.opt_music = !_vm->_soundManager._musicOffFl ? 7 : 8;
if (_vm->_globals.SVGA == 1)
_vm->_globals.opt_anm = 10;
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();
}
diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h
index 2fa4670d48..4a02f915f7 100644
--- a/engines/hopkins/sound.h
+++ b/engines/hopkins/sound.h
@@ -114,11 +114,11 @@ private:
public:
Audio::SoundHandle _modHandle;
int SPECIAL_SOUND;
- int SOUNDVOL;
- int VOICEVOL;
- int MUSICVOL;
+ int _soundVolume;
+ int _voiceVolume;
+ int _musicVolume;
bool _soundOffFl;
- bool _musicOff;
+ bool _musicOffFl;
bool _voiceOffFl;
bool _textOffFl;
bool _soundFl;