Skip to content

Commit

Permalink
KYRA: (EOB) - add basic distinction between music and sound effects
Browse files Browse the repository at this point in the history
(The original code of the DOS version does not distinguish here, but
we do it anyway so as to make more sense of the GMM volume settings)
  • Loading branch information
athrxx authored and unknown committed Jan 6, 2012
1 parent 6e45741 commit eaa5d50
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 55 deletions.
12 changes: 6 additions & 6 deletions engines/kyra/chargen.cpp
Expand Up @@ -171,7 +171,7 @@ bool CharacterGenerator::start(EoBCharacter *characters, uint8 ***faceShapes) {
checkForCompleteParty();
initButtonsFromList(0, 5);

_vm->sound()->playTrack(_vm->game() == GI_EOB1 ? 20 : 13);
_vm->snd_playSong(_vm->game() == GI_EOB1 ? 20 : 13);
_activeBox = 0;

for (bool loop = true; loop && (!_vm->shouldQuit());) {
Expand All @@ -186,7 +186,7 @@ bool CharacterGenerator::start(EoBCharacter *characters, uint8 ***faceShapes) {
_activeBox ^= 2;
} else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) {
// Unlike the original we allow returning to the main menu
_vm->sound()->haltTrack();
_vm->snd_stopSound();
return false;
}
_vm->_gui->updateBoxFrameHighLight(-1);
Expand Down Expand Up @@ -232,7 +232,7 @@ bool CharacterGenerator::start(EoBCharacter *characters, uint8 ***faceShapes) {
}

if (_vm->game() == GI_EOB2)
_vm->sound()->playTrack(15);
_vm->snd_fadeOut();

*faceShapes = _faceShapes;
return true;
Expand Down Expand Up @@ -372,7 +372,7 @@ void CharacterGenerator::toggleSpecialButton(int index, int bodyCustom, int page

void CharacterGenerator::processSpecialButton(int index) {
toggleSpecialButton(index, 1, 0);
_vm->sound()->playSoundEffect(76);
_vm->snd_playSoundEffect(76);
_vm->_system->delayMillis(80);
toggleSpecialButton(index, 0, 0);
}
Expand Down Expand Up @@ -598,13 +598,13 @@ int CharacterGenerator::alignmentMenu(int cClass) {
int CharacterGenerator::getInput(Button *buttonList) {
if (_vm->game() == GI_EOB1 && _vm->sound()->checkTrigger()) {
_vm->sound()->resetTrigger();
_vm->sound()->playTrack(20);
_vm->snd_playSong(20);
} else if (_vm->game() == GI_EOB2 && !_vm->sound()->isPlaying()) {
// WORKAROUND for EOB II: The original implements the same sound trigger check as in EOB I.
// However, Westwood seems to have forgotten to set the trigger at the end of the AdLib song,
// so that the music will not loop. We simply check whether the sound driver is still playing.
_vm->delay(3 * _vm->_tickLength);
_vm->sound()->playTrack(13);
_vm->snd_playSong(13);
}
return _vm->checkInput(buttonList, false, 0);
}
Expand Down
19 changes: 14 additions & 5 deletions engines/kyra/eobcommon.cpp
Expand Up @@ -1403,7 +1403,7 @@ void EoBCoreEngine::restoreAfterDialogueSequence() {
_screen->setScreenDim(7);

if (_flags.gameID == GI_EOB2)
_sound->playTrack(2);
snd_playSoundEffect(2);

_sceneUpdateRequired = true;
}
Expand Down Expand Up @@ -2377,15 +2377,24 @@ void EoBCoreEngine::explodeMonster(EoBMonsterInPlay *m) {
m->flags &= ~2;
}

void EoBCoreEngine::snd_playSoundEffect(int id, int volume) {
if ((id < 1) || (_flags.gameID == GI_EOB2 && id > 119) || shouldQuit())
void EoBCoreEngine::snd_playSong(int track) {
_sound->playTrack(track);
}

void EoBCoreEngine::snd_playSoundEffect(int track, int volume) {
if ((track < 1) || (_flags.gameID == GI_EOB2 && track > 119) || shouldQuit())
return;

_sound->playSoundEffect(id, volume);
_sound->playSoundEffect(track, volume);
}

void EoBCoreEngine::snd_stopSound() {
_sound->playSoundEffect(0);
_sound->haltTrack();
_sound->stopAllSoundEffects();
}

void EoBCoreEngine::snd_fadeOut() {
_sound->beginFadeOut();
}

} // End of namespace Kyra
Expand Down
2 changes: 2 additions & 0 deletions engines/kyra/eobcommon.h
Expand Up @@ -1127,8 +1127,10 @@ friend class TransferPartyWiz;
const uint8 *_numSpellsMage;

// sound
void snd_playSong(int id);
void snd_playSoundEffect(int id, int volume=0xFF);
void snd_stopSound();
void snd_fadeOut();

// keymap
static const char *const kKeymapName;
Expand Down
43 changes: 21 additions & 22 deletions engines/kyra/sequences_darkmoon.cpp
Expand Up @@ -177,7 +177,7 @@ void DarkMoonEngine::seq_playIntro() {
sq.delay(1);

if (!skipFlag() && !shouldQuit())
_sound->playTrack(12);
snd_playSong(12);

_screen->copyRegion(0, 0, 8, 8, 304, 128, 2, 0, Screen::CR_NO_P_CHECK);
sq.setPalette(9);
Expand Down Expand Up @@ -447,18 +447,17 @@ void DarkMoonEngine::seq_playIntro() {
sq.waitForSongNotifier(8, true);

if (skipFlag() || shouldQuit()) {
_sound->playTrack(15);
snd_fadeOut();
} else {
_screen->setScreenDim(17);
_screen->clearCurDim();
_sound->playTrack(14);
snd_playSoundEffect(14);
sq.fadePalette(10, 1);
_screen->setClearScreenDim(18);
sq.delay(6);
sq.fadePalette(9, 1);
_screen->clearCurPage();
}

sq.fadePalette(9, 10);
}

Expand All @@ -479,7 +478,7 @@ void DarkMoonEngine::seq_playFinale() {
sq.delay(18);

if (!skipFlag() && !shouldQuit())
_sound->playTrack(1);
snd_playSong(1);
sq.update(2);

sq.loadScene(1, 2);
Expand Down Expand Up @@ -603,7 +602,7 @@ void DarkMoonEngine::seq_playFinale() {
sq.waitForSongNotifier(3);

if (!skipFlag() && !shouldQuit())
_sound->playTrack(7);
snd_playSoundEffect(7);
sq.delay(8);

sq.runSequence(10);
Expand Down Expand Up @@ -635,7 +634,7 @@ void DarkMoonEngine::seq_playFinale() {
sq.waitForSongNotifier(4);

if (!skipFlag() && !shouldQuit())
_sound->playTrack(7);
snd_playSoundEffect(7);
sq.delay(8);

sq.runSequence(10);
Expand All @@ -660,7 +659,7 @@ void DarkMoonEngine::seq_playFinale() {
sq.delay(36);

if (!skipFlag() && !shouldQuit())
_sound->playTrack(11);
snd_playSoundEffect(11);

sq.delay(54);
sq.fadeText();
Expand All @@ -669,7 +668,7 @@ void DarkMoonEngine::seq_playFinale() {
sq.waitForSongNotifier(5);

if (!skipFlag() && !shouldQuit())
_sound->playTrack(6);
snd_playSoundEffect(6);

if (!skipFlag() && !shouldQuit())
_screen->crossFadeRegion(0, 0, 8, 8, 304, 128, 2, 0);
Expand All @@ -680,7 +679,7 @@ void DarkMoonEngine::seq_playFinale() {
sq.runSequence(19);
sq.runSequence(19, 36);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(12);
snd_playSoundEffect(12);
sq.fadeText();

sq.printText(17, 15); // Thank you
Expand All @@ -690,50 +689,50 @@ void DarkMoonEngine::seq_playFinale() {

sq.printText(18, 15); // You have earned my deepest respect
if (!skipFlag() && !shouldQuit())
_sound->playTrack(11);
snd_playSoundEffect(11);
sq.runSequence(20);
sq.runSequence(19);
sq.runSequence(19);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(11);
snd_playSoundEffect(11);
sq.delay(36);
sq.fadeText();

sq.printText(19, 15); // We will remember you always
sq.runSequence(19);
sq.runSequence(19, 18);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(11);
snd_playSoundEffect(11);
sq.runSequence(20, 18);
sq.fadeText();

sq.delay(28);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(12);
snd_playSoundEffect(12);
sq.delay(3);

sq.loadScene(5, 2);
if (skipFlag() || shouldQuit()) {
_screen->copyRegion(0, 0, 8, 8, 304, 128, 2, 0, Screen::CR_NO_P_CHECK);
} else {
_sound->playTrack(6);
snd_playSoundEffect(6);
_screen->crossFadeRegion(0, 0, 8, 8, 304, 128, 2, 0);
}

if (!skipFlag() && !shouldQuit())
_sound->playTrack(12);
snd_playSoundEffect(12);
sq.delay(5);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(11);
snd_playSoundEffect(11);
sq.delay(11);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(12);
snd_playSoundEffect(12);
sq.delay(7);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(11);
snd_playSoundEffect(11);
sq.delay(12);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(12);
snd_playSoundEffect(12);

removeInputTop();
resetSkipFlag(true);
Expand All @@ -747,7 +746,7 @@ void DarkMoonEngine::seq_playFinale() {

sq.delay(18);
if (!skipFlag() && !shouldQuit())
_sound->playTrack(1);
snd_playSong(1);

seq_playCredits(&sq, _creditsData, 18, 2, 6, 2);

Expand Down Expand Up @@ -1121,7 +1120,7 @@ void DarkmoonSequenceHelper::runSequence(int index, int del) {
case 6:
// play sound effect
if (s->obj != 0xff)
_vm->sound()->playSoundEffect(s->obj);
_vm->snd_playSoundEffect(s->obj);
break;

default:
Expand Down

0 comments on commit eaa5d50

Please sign in to comment.