diff options
| -rw-r--r-- | engines/hopkins/dialogs.cpp | 8 | ||||
| -rw-r--r-- | engines/hopkins/objects.cpp | 8 | ||||
| -rw-r--r-- | engines/hopkins/script.cpp | 65 | ||||
| -rw-r--r-- | engines/hopkins/sound.cpp | 70 | ||||
| -rw-r--r-- | engines/hopkins/sound.h | 6 | 
5 files changed, 86 insertions, 71 deletions
diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index e67301b25f..3bc7f41951 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -346,8 +346,8 @@ LABEL_7:  	_inventX = _vm->_graphicsManager._scrollOffset + 152;  	_inventY = 114; -	int v18 = _inventWidth = _vm->_objectsManager.getWidth(_vm->_dialogsManager._inventWin1, 0); -	int v17 = _inventHeight = _vm->_objectsManager.getHeight(_vm->_dialogsManager._inventWin1, 0); +	_inventWidth = _vm->_objectsManager.getWidth(_vm->_dialogsManager._inventWin1, 0); +	_inventHeight = _vm->_objectsManager.getHeight(_vm->_dialogsManager._inventWin1, 0);  	_vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, _vm->_dialogsManager._inventWin1, _inventX + 300, 414, 0, 0, 0, false);  	int v15 = 0; @@ -433,8 +433,8 @@ LABEL_7:  	_vm->_fontManager.hideText(9);  	if (_inventDisplayedFl) {  		_inventDisplayedFl = false; -		_vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, _inventX, 114, v18, v17, _vm->_graphicsManager._vesaBuffer, _inventX, 114); -		_vm->_graphicsManager.addVesaSegment(_inventX, 114, _inventX + v18, v18 + 114); +		_vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, _inventX, 114, _inventWidth, _inventHeight, _vm->_graphicsManager._vesaBuffer, _inventX, 114); +		_vm->_graphicsManager.addVesaSegment(_inventX, 114, _inventX + _inventWidth, _inventWidth + 114);  		_vm->_objectsManager.BOBTOUS = true;  	} diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 6d2403265d..44a446e9a6 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -740,11 +740,11 @@ void ObjectsManager::checkCache() {  				_vm->_globals.Cache[cacheIdx].fieldA = 1;  			}  		} else { -			int v5 = _vm->_globals.Cache[cacheIdx].field14 + _vm->_globals.Cache[cacheIdx]._height + _vm->_globals.Cache[cacheIdx]._y; -			if (v5 > 440) -				v5 = 500; +			int priority = _vm->_globals.Cache[cacheIdx].field14 + _vm->_globals.Cache[cacheIdx]._height + _vm->_globals.Cache[cacheIdx]._y; +			if (priority > 440) +				priority = 500; -			beforeSort(SORT_CACHE, cacheIdx, v5); +			beforeSort(SORT_CACHE, cacheIdx, priority);  			_vm->_globals.Cache[cacheIdx].fieldA = 1;  			_vm->_globals.Cache[cacheIdx].field10 = true;  		} diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index 7bca24714a..6bf6e5f4b0 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -47,9 +47,9 @@ int ScriptManager::handleOpcode(byte *dataP) {  		return 0;  	int opcodeType = 0; -	int v70 = 0; +	int vbobFrameIndex = 0;  	if (dataP[2] == 'T' && dataP[3] == 'X' && dataP[4] == 'T') { -		v70 = dataP[6]; +		vbobFrameIndex = dataP[6];  		int mesgId = (int16)READ_LE_UINT16(dataP + 13);  		opcodeType = 1;  		if (!TRAVAILOBJET) { @@ -137,8 +137,7 @@ int ScriptManager::handleOpcode(byte *dataP) {  			}  			if (!_vm->_soundManager._voiceOffFl)  				_vm->_soundManager.mixVoice(mesgId, 4); -		} -		if (TRAVAILOBJET) { +		} else { // if (TRAVAILOBJET)  			if (_vm->_globals._saveData->_data[svField356]) {  				_vm->_fontManager.initTextBuffers(9, 635, _vm->_globals.FICH_TEXTE, 55, 20, dataP[8], 35, 253);  				if (!_vm->_soundManager._textOffFl) @@ -164,17 +163,17 @@ int ScriptManager::handleOpcode(byte *dataP) {  		}  	} else if (dataP[2] == 'B' && dataP[3] == 'O' && dataP[4] == 'B') {  		if (!_vm->_objectsManager._disableFl) { -			int v72 = dataP[5]; -			v70 = dataP[6]; +			int vbobIdx = dataP[5]; +			vbobFrameIndex = dataP[6];  			int v4 = dataP[7]; -			int v68 = (int16)READ_LE_UINT16(dataP + 8); -			int v66 = (int16)READ_LE_UINT16(dataP + 10); -			if (v72 == 52) { -				_vm->_graphicsManager.fastDisplay(_vm->_globals.SPRITE_ECRAN, v68, (int16)READ_LE_UINT16(dataP + 10), v70); -			} else if (v72 == 51) { -				_vm->_objectsManager.BOB_VIVANT(v70); -			} else if (v72 != 50) { -				_vm->_objectsManager.VBOB(_vm->_globals.SPRITE_ECRAN, v72, v68, v66, v70); +			int vbobPosX = (int16)READ_LE_UINT16(dataP + 8); +			int vbobPosY = (int16)READ_LE_UINT16(dataP + 10); +			if (vbobIdx == 52) { +				_vm->_graphicsManager.fastDisplay(_vm->_globals.SPRITE_ECRAN, vbobPosX, (int16)READ_LE_UINT16(dataP + 10), vbobFrameIndex); +			} else if (vbobIdx == 51) { +				_vm->_objectsManager.BOB_VIVANT(vbobFrameIndex); +			} else if (vbobIdx != 50) { +				_vm->_objectsManager.VBOB(_vm->_globals.SPRITE_ECRAN, vbobIdx, vbobPosX, vbobPosY, vbobFrameIndex);  				if (v4)  					v4 /= _vm->_globals._speed;  				if (v4 > 1) { @@ -188,7 +187,7 @@ int ScriptManager::handleOpcode(byte *dataP) {  				}  			} else  				// TODO: Remove this: -				warning("Former AFFICHE_SPEED1: %d %d %d", v68, v66, v70); +				warning("Former AFFICHE_SPEED1: %d %d %d", vbobPosX, vbobPosY, vbobFrameIndex);  		}  		opcodeType = 1;  	} else if (dataP[2] == 'S' && dataP[3] == 'T' && dataP[4] == 'P') { @@ -255,7 +254,7 @@ int ScriptManager::handleOpcode(byte *dataP) {  			_vm->_globals._prevScreenId = _vm->_globals._screenId;  			_vm->_globals._saveData->_data[svField6] = _vm->_globals._screenId;  			_vm->_globals._screenId = _vm->_globals._saveData->_data[svField5] = dataP[5]; -			v70 = dataP[6]; +			vbobFrameIndex = dataP[6];  		}  		opcodeType = 1;  	} else if (dataP[2] == 'B' && dataP[3] == 'O' && dataP[4] == 'F') { @@ -265,7 +264,7 @@ int ScriptManager::handleOpcode(byte *dataP) {  	} else if (dataP[2] == 'P' && dataP[3] == 'E' && dataP[4] == 'R') {  		int specialOpcode = (int16)READ_LE_UINT16(dataP + 5);  		if (!_vm->_globals._saveData->_data[svField122] && !_vm->_globals._saveData->_data[svField356]) { -			v70 = 0; +			vbobFrameIndex = 0;  			switch (specialOpcode) {  			case 1: @@ -2048,13 +2047,13 @@ int ScriptManager::handleOpcode(byte *dataP) {  			char v47 = _vm->_globals._saveData->_data[svField341];  			if (v47) {  				if (v47 == 2) -					v70 = 5; -				if (v47 == 3) -					v70 = 4; -				if (v47 == 1) -					v70 = 6; +					vbobFrameIndex = 5; +				else if (v47 == 3) +					vbobFrameIndex = 4; +				else if (v47 == 1) +					vbobFrameIndex = 6;  				_vm->_soundManager.playSound("SOUND83.WAV"); -				_vm->_objectsManager.OPTI_ONE(v70, 26, 50, 0); +				_vm->_objectsManager.OPTI_ONE(vbobFrameIndex, 26, 50, 0);  				if (_vm->_globals._saveData->_data[svField341] == 1)  					_vm->_graphicsManager.fastDisplay(_vm->_globals.SPRITE_ECRAN, 27, 117, 0);  				if (_vm->_globals._saveData->_data[svField341] == 2) @@ -2078,13 +2077,13 @@ int ScriptManager::handleOpcode(byte *dataP) {  			char v48 = _vm->_globals._saveData->_data[svField341];  			if (v48) {  				if (v48 == 2) -					v70 = 5; +					vbobFrameIndex = 5;  				if (v48 == 3) -					v70 = 4; +					vbobFrameIndex = 4;  				if (v48 == 1) -					v70 = 6; +					vbobFrameIndex = 6;  				_vm->_soundManager.playSound("SOUND83.WAV"); -				_vm->_objectsManager.OPTI_ONE(v70, 26, 50, 0); +				_vm->_objectsManager.OPTI_ONE(vbobFrameIndex, 26, 50, 0);  				if (_vm->_globals._saveData->_data[svField341] == 1)  					_vm->_graphicsManager.fastDisplay(_vm->_globals.SPRITE_ECRAN, 27, 117, 0);  				if (_vm->_globals._saveData->_data[svField341] == 2) @@ -2108,13 +2107,13 @@ int ScriptManager::handleOpcode(byte *dataP) {  			char v49 = _vm->_globals._saveData->_data[svField341];  			if (v49) {  				if (v49 == 2) -					v70 = 5; -				if (v49 == 3) -					v70 = 4; -				if (v49 == 1) -					v70 = 6; +					vbobFrameIndex = 5; +				else if (v49 == 3) +					vbobFrameIndex = 4; +				else if (v49 == 1) +					vbobFrameIndex = 6;  				_vm->_soundManager.playSound("SOUND83.WAV"); -				_vm->_objectsManager.OPTI_ONE(v70, 26, 50, 0); +				_vm->_objectsManager.OPTI_ONE(vbobFrameIndex, 26, 50, 0);  				if (_vm->_globals._saveData->_data[svField341] == 1)  					_vm->_graphicsManager.fastDisplay(_vm->_globals.SPRITE_ECRAN, 27, 117, 0);  				if (_vm->_globals._saveData->_data[svField341] == 2) 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; diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h index 622e842d5d..081046d335 100644 --- a/engines/hopkins/sound.h +++ b/engines/hopkins/sound.h @@ -100,10 +100,10 @@ public:  	bool _modPlayingFl;  	int _oldSoundNumber; -	VoiceItem Voice[VOICE_COUNT]; +	VoiceItem _voice[VOICE_COUNT];  	SwavItem Swav[SWAV_COUNT]; -	SoundItem SOUND[SOUND_COUNT]; -	MusicItem Music; +	SoundItem _sound[SOUND_COUNT]; +	MusicItem _music;  public:  	SoundManager();  	~SoundManager();  | 
