Permalink
Browse files

SCI32: Add audio volume sync support for Hoyle5

  • Loading branch information...
bluegr committed Aug 30, 2018
1 parent e13d7c0 commit 18837ded6ef9318bc4473ccccd09f8f43157c3aa
@@ -574,6 +574,7 @@ bool GameFeatures::audioVolumeSyncUsesGlobals() const {
switch (g_sci->getGameId()) {
case GID_GK1:
case GID_GK2:
case GID_HOYLE5:
case GID_LSL6HIRES:
case GID_LSL7:
case GID_PHANTASMAGORIA:
@@ -112,23 +112,19 @@ bool GuestAdditions::shouldSyncAudioToScummVM() const {
} else if ((gameId == GID_GK1 || gameId == GID_SQ6) && (objName == "musicBar" ||
objName == "soundBar")) {
return true;
} else if (gameId == GID_PQ4 && (objName == "increaseVolume" ||
objName == "decreaseVolume")) {
} else if (gameId == GID_GK2 && objName == "soundSlider") {
return true;
} else if (gameId == GID_KQ7 && (objName == "volumeUp" ||
objName == "volumeDown")) {
return true;
} else if (gameId == GID_LSL6HIRES && (objName == "hiResMenu" ||
objName == "volumeDial")) {
return true;
} else if (gameId == GID_MOTHERGOOSEHIRES && objName == "MgButtonBar") {
return true;
} else if (gameId == GID_PQSWAT && (objName == "volumeDownButn" ||
objName == "volumeUpButn")) {
return true;
} else if (gameId == GID_SHIVERS && objName == "spVolume") {
} else if ((gameId == GID_LSL7 || gameId == GID_TORIN) && (objName == "oMusicScroll" ||
objName == "oSFXScroll" ||
objName == "oAudioScroll")) {
return true;
} else if (gameId == GID_GK2 && objName == "soundSlider") {
} else if (gameId == GID_MOTHERGOOSEHIRES && objName == "MgButtonBar") {
return true;
} else if (gameId == GID_PHANTASMAGORIA && (objName == "midiVolDown" ||
objName == "midiVolUp" ||
@@ -137,9 +133,13 @@ bool GuestAdditions::shouldSyncAudioToScummVM() const {
return true;
} else if (gameId == GID_PHANTASMAGORIA2 && objName == "foo2") {
return true;
} else if ((gameId == GID_LSL7 || gameId == GID_TORIN) && (objName == "oMusicScroll" ||
objName == "oSFXScroll" ||
objName == "oAudioScroll")) {
} else if (gameId == GID_PQ4 && (objName == "increaseVolume" ||
objName == "decreaseVolume")) {
return true;
} else if (gameId == GID_PQSWAT && (objName == "volumeDownButn" ||
objName == "volumeUpButn")) {
return true;
} else if (gameId == GID_SHIVERS && objName == "spVolume") {
return true;
#endif
}
@@ -163,6 +163,8 @@ void GuestAdditions::writeVarHook(const int type, const int index, const reg_t v
syncAudioVolumeGlobalsToScummVM(index, value);
} else if (g_sci->getGameId() == GID_GK1) {
syncGK1StartupVolumeFromScummVM(index, value);
} else if (g_sci->getGameId() == GID_HOYLE5 && index == kGlobalVarHoyle5MusicVolume) {
syncHoyle5VolumeFromScummVM((ConfMan.getInt("music_volume") + 1) * kHoyle5VolumeMax / Audio::Mixer::kMaxMixerVolume);
} else if (g_sci->getGameId() == GID_RAMA && !g_sci->isDemo() && index == kGlobalVarRamaMusicVolume) {
syncRamaVolumeFromScummVM((ConfMan.getInt("music_volume") + 1) * kRamaVolumeMax / Audio::Mixer::kMaxMixerVolume);
}
@@ -1004,6 +1006,13 @@ void GuestAdditions::syncAudioVolumeGlobalsFromScummVM() const {
break;
}

case GID_HOYLE5: {
const int16 musicVolume = (ConfMan.getInt("music_volume") + 1) * kHoyle5VolumeMax / Audio::Mixer::kMaxMixerVolume;
syncHoyle5VolumeFromScummVM(musicVolume);
syncHoyle5UI(musicVolume);
break;
}

case GID_LSL6HIRES: {
const int16 musicVolume = (ConfMan.getInt("music_volume") + 1) * kLSL6HiresUIVolumeMax / Audio::Mixer::kMaxMixerVolume;
syncLSL6HiresVolumeFromScummVM(musicVolume);
@@ -1136,6 +1145,11 @@ void GuestAdditions::syncGK2VolumeFromScummVM(const int16 musicVolume) const {
}
}

void GuestAdditions::syncHoyle5VolumeFromScummVM(const int16 musicVolume) const {
_state->variables[VAR_GLOBAL][kGlobalVarHoyle5MusicVolume] = make_reg(0, musicVolume);
g_sci->_soundCmd->setMasterVolume(ConfMan.getBool("mute") ? 0 : (musicVolume * MUSIC_MASTERVOLUME_MAX / kHoyle5VolumeMax));
}

void GuestAdditions::syncLSL6HiresVolumeFromScummVM(const int16 musicVolume) const {
_state->variables[VAR_GLOBAL][kGlobalVarLSL6HiresMusicVolume] = make_reg(0, musicVolume);
g_sci->_soundCmd->setMasterVolume(ConfMan.getBool("mute") ? 0 : (musicVolume * MUSIC_MASTERVOLUME_MAX / kLSL6HiresUIVolumeMax));
@@ -1195,6 +1209,15 @@ void GuestAdditions::syncAudioVolumeGlobalsToScummVM(const int index, const reg_
}
break;

case GID_HOYLE5:
if (index == kGlobalVarHoyle5MusicVolume) {
const int16 masterVolume = value.toSint16() * Audio::Mixer::kMaxMixerVolume / kHoyle5VolumeMax;
ConfMan.setInt("music_volume", masterVolume);
ConfMan.setInt("sfx_volume", masterVolume);
ConfMan.setInt("speech_volume", masterVolume);
}
break;

case GID_LSL6HIRES:
if (index == kGlobalVarLSL6HiresMusicVolume) {
const int16 musicVolume = value.toSint16() * Audio::Mixer::kMaxMixerVolume / kLSL6HiresUIVolumeMax;
@@ -1299,6 +1322,10 @@ void GuestAdditions::syncInGameUI(const int16 musicVolume, const int16 sfxVolume
syncQFG4UI(musicVolume);
break;

case GID_HOYLE5:
syncHoyle5UI(musicVolume);
break;

case GID_SHIVERS:
syncShivers1UI(sfxVolume);
break;
@@ -1344,6 +1371,22 @@ void GuestAdditions::syncGK2UI() const {
}
}

void GuestAdditions::syncHoyle5UI(const int16 musicVolume) const {
const reg_t sliderId = _segMan->findObjectByName("volumeSlider");
if (!sliderId.isNull()) {
const int16 yPosition = 167 - musicVolume * 145 / 10;
writeSelectorValue(_segMan, sliderId, SELECTOR(y), yPosition);

// There does not seem to be any good way to learn whether the
// volume slider is visible (and thus eligible for
// kUpdateScreenItem)
const reg_t planeId = readSelector(_segMan, sliderId, SELECTOR(plane));
if (g_sci->_gfxFrameout->getPlanes().findByObject(planeId) != nullptr) {
g_sci->_gfxFrameout->kernelUpdateScreenItem(sliderId);
}
}
}

void GuestAdditions::syncLSL6HiresUI(const int16 musicVolume) const {
const reg_t musicDialId = _segMan->findObjectByName("volumeDial");
if (!musicDialId.isNull()) {
@@ -45,6 +45,7 @@ enum {

kRamaVolumeMax = 16,
kLSL6HiresUIVolumeMax = 13,
kHoyle5VolumeMax = 8,
kLSL6HiresSubtitleFlag = 105
};
#endif
@@ -387,6 +388,7 @@ class GuestAdditions {
void syncGK1VolumeFromScummVM(const int16 musicVolume, const int16 dacVolume) const;

void syncGK2VolumeFromScummVM(const int16 musicVolume) const;
void syncHoyle5VolumeFromScummVM(const int16 musicVolume) const;
void syncLSL6HiresVolumeFromScummVM(const int16 musicVolume) const;
void syncPhant2VolumeFromScummVM(const int16 masterVolume) const;
void syncRamaVolumeFromScummVM(const int16 musicVolume) const;
@@ -416,6 +418,7 @@ class GuestAdditions {

void syncGK1UI() const;
void syncGK2UI() const;
void syncHoyle5UI(const int16 musicVolume) const;
void syncLSL6HiresUI(const int16 musicVolume) const;
void syncMGDXUI(const int16 musicVolume) const;
void syncPhant1UI(const int16 oldMusicVolume, const int16 musicVolume, reg_t &musicGlobal, const int16 oldDacVolume, const int16 dacVolume, reg_t &dacGlobal) const;
@@ -176,7 +176,8 @@ enum GlobalVar {
// a master volume that affects both music *and* sound effects
kGlobalVarPhant2MasterVolume = 236, // 0 to 127
kGlobalVarPhant2ControlPanel = 250,
kGlobalVarShivers1Score = 349
kGlobalVarShivers1Score = 349,
kGlobalVarHoyle5MusicVolume = 897
};

/** Number of kernel calls in between gcs; should be < 50000 */

0 comments on commit 18837de

Please sign in to comment.