[Scummvm-cvs-logs] CVS: scummvm/sword2 function.cpp,1.52,1.53
Torbj?rn Andersson
eriktorbjorn at users.sourceforge.net
Mon Jan 12 00:02:05 CET 2004
Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1:/tmp/cvs-serv15666
Modified Files:
function.cpp
Log Message:
Sync the credits so that the text scroll and music will last for about the
same amount of time. I don't think the original did this, but it turned out
to be pretty easy.
Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- function.cpp 11 Jan 2004 16:49:18 -0000 1.52
+++ function.cpp 12 Jan 2004 08:01:21 -0000 1.53
@@ -585,8 +585,7 @@
// Start the music and roll the credits
// The credits music (which can also be heard briefly in the "carib"
- // cutscene) is played once, and there is no attempt at synchronizing
- // it with the credits scroll.
+ // cutscene) is played once.
int32 pars[2];
@@ -606,7 +605,18 @@
int startLine = 0;
int scrollPos = 0;
- while (scrollPos < lineTop + CREDITS_FONT_HEIGHT && !_vm->_quit) {
+ bool abortCredits = false;
+
+ int scrollSteps = lineTop + CREDITS_FONT_HEIGHT;
+ uint32 musicStart = _vm->_system->get_msecs();
+
+ // Ideally the music should last just a tiny bit longer than the
+ // credits. Note that musicTimeRemaining() will return 0 if the music
+ // is muted, so we need a sensible fallback for that case.
+
+ uint32 musicLength = MAX(1000 * (_vm->_sound->musicTimeRemaining() - 3), 25 * scrollSteps);
+
+ while (scrollPos < scrollSteps && !_vm->_quit) {
bool foundStartLine = false;
_vm->_graphics->clearScene();
@@ -671,13 +681,16 @@
KeyboardEvent ke;
if (_vm->_input->readKey(&ke) == RD_OK && ke.keycode == 27) {
- fnStopMusic(NULL);
- break;
+ if (!abortCredits) {
+ abortCredits = true;
+ _vm->_graphics->fadeDown();
+ }
}
-
- _vm->_system->delay_msecs(30);
+ if (abortCredits && _vm->_graphics->getFadeStatus() == RDFADE_BLACK)
+ break;
+ _vm->sleepUntil(musicStart + (musicLength * scrollPos) / scrollSteps);
scrollPos++;
}
@@ -694,19 +707,18 @@
if (logoData)
free(logoData);
- if (_vm->_quit)
- return IR_CONT;
-
- _vm->_graphics->fadeDown();
- _vm->_graphics->waitForFade();
-
- // The music should have stopped by now, but I suppose there is a
- // slim chance it hasn't on a really, really fast computer.
+ if (!abortCredits) {
+ // The music should either have stopped or be about to stop, so
+ // wait for it to really happen.
- while (_vm->_sound->musicTimeRemaining()) {
- _vm->_graphics->updateDisplay(false);
- _vm->_system->delay_msecs(100);
+ while (_vm->_sound->musicTimeRemaining() && !_vm->_quit) {
+ _vm->_graphics->updateDisplay(false);
+ _vm->_system->delay_msecs(100);
+ }
}
+
+ if (_vm->_quit)
+ return IR_CONT;
_vm->_sound->restoreMusicState();
_vm->_sound->muteFx(false);
More information about the Scummvm-git-logs
mailing list