Skip to content

Commit

Permalink
SHERLOCK: intro timing + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Kiewitz committed Jun 1, 2015
1 parent f07e31c commit 42d3d0f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 8 deletions.
36 changes: 35 additions & 1 deletion engines/sherlock/music.cpp
Expand Up @@ -356,5 +356,39 @@ void Music::freeSong() {
void Music::waitTimerRoland(uint time) {
// TODO
warning("TODO: Sound::waitTimerRoland");
}} // End of namespace Sherlock
}

bool Music::waitUntilTick(uint32 tick, uint32 maxTick, uint32 additionalDelay, uint32 noMusicDelay) {
uint32 currentTick = 0;

if (!_midiParser.isPlaying()) {
return _vm->_events->delay(noMusicDelay, true);
}
while (1) {
if (!_midiParser.isPlaying()) { // Music has stopped playing -> we are done
if (additionalDelay > 0) {
if (!_vm->_events->delay(additionalDelay, true))
return false;
}
return true;
}

currentTick = _midiParser.getTick();
//warning("waitUntilTick: %lx", currentTick);

if (currentTick <= maxTick) {
if (currentTick >= tick) {
if (additionalDelay > 0) {
if (!_vm->_events->delay(additionalDelay, true))
return false;
}
return true;
}
}
if (!_vm->_events->delay(10, true))
return false;
}
}

} // End of namespace Sherlock

2 changes: 2 additions & 0 deletions engines/sherlock/music.h
Expand Up @@ -98,6 +98,8 @@ class Music {
void stopMusic();

void waitTimerRoland(uint time);

bool waitUntilTick(uint32 tick, uint32 maxTick, uint32 additionalDelay, uint32 noMusicDelay);
};

} // End of namespace Sherlock
Expand Down
46 changes: 39 additions & 7 deletions engines/sherlock/scalpel/scalpel.cpp
Expand Up @@ -307,7 +307,9 @@ bool ScalpelEngine::showCityCutscene() {
// In the alley...
_screen->transBlitFrom(titleImages[3], Common::Point(72, 51));
_screen->fadeIn(palette, 3);
finished = _events->delay(2500, true);

// Wait until the track got looped and the first few notes were played
finished = _music->waitUntilTick(0x104, 0x500, 0, 2500);
}
}

Expand All @@ -323,11 +325,16 @@ bool ScalpelEngine::showAlleyCutscene() {
_animation->_gfxLibraryFilename = "TITLE.LIB";
_animation->_soundLibraryFilename = "TITLE.SND";

// Fade "In The Alley..." text to black
_screen->fadeToBlack(2);

bool finished = _animation->play("27PRO1", 1, 3, true, 2);
if (finished) {
_screen->getPalette(palette);
_screen->fadeToBlack(2);
finished = _events->delay(500);

// wait until second lower main note
finished = _music->waitUntilTick(0x64a, 0xFFFF, 0, 1000); // 652
}

if (finished) {
Expand All @@ -337,7 +344,17 @@ bool ScalpelEngine::showAlleyCutscene() {

if (finished) {
showLBV("scream.lbv");
finished = _events->delay(6000);

// wait until first "scream" in music happened
finished = _music->waitUntilTick(0xabe, 0xFFFF, 0, 6000);
}

if (finished) {
// quick fade out
_screen->fadeToBlack(1);

// wait until after third "scream" in music happened
finished = _music->waitUntilTick(0xb80, 0xFFFF, 0, 2000);
}

if (finished)
Expand All @@ -351,9 +368,13 @@ bool ScalpelEngine::showAlleyCutscene() {
if (finished) {
ImageFile titleImages("title3.vgs", true);
// "Early the following morning on Baker Street..."
_screen->_backBuffer1.transBlitFrom(titleImages[0], Common::Point(35, 51), false, 0);
_screen->fadeIn(palette, 3);
finished = _events->delay(1000);
_screen->transBlitFrom(titleImages[0], Common::Point(35, 51));

// fast fade-in
_screen->fadeIn(palette, 1);

// wait for music to end and wait an additional 2.5 seconds
finished = _music->waitUntilTick(0xFFFF, 0xFFFF, 2500, 3000);
}

_animation->_gfxLibraryFilename = "";
Expand All @@ -367,7 +388,18 @@ bool ScalpelEngine::showStreetCutscene() {

_music->playMusic("PROLOG3.MUS");

bool finished = _animation->play("14KICK", 1, 3, true, 2);
// wait a bit
bool finished = _events->delay(500);

if (finished) {
// fade out "Early the following morning..."
_screen->fadeToBlack(2);

// wait for music a bit
finished = _music->waitUntilTick(0xE4, 0xFFFF, 0, 1000);
}

finished = _animation->play("14KICK", 1, 3, true, 2);

if (finished)
finished = _animation->play("14NOTE", 1, 0, false, 2);
Expand Down

0 comments on commit 42d3d0f

Please sign in to comment.