[Scummvm-cvs-logs] CVS: scummvm/sky intro.cpp,1.49,1.50 intro.h,1.5,1.6 screen.cpp,1.60,1.61
Robert Göffringmann
lavosspawn at users.sourceforge.net
Sun Oct 24 17:29:02 CEST 2004
Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9591/sky
Modified Files:
intro.cpp intro.h screen.cpp
Log Message:
use relative timing instead of constant values.
Index: intro.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/intro.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- intro.cpp 28 Sep 2004 20:19:32 -0000 1.49
+++ intro.cpp 25 Oct 2004 00:27:53 -0000 1.50
@@ -623,6 +623,7 @@
_saveBuf = (uint8*)malloc(10000);
_bgBuf = NULL;
_quitProg = false;
+ _relDelay = 0;
}
Intro::~Intro(void) {
@@ -681,9 +682,12 @@
return true;
case FADEUP:
_skyScreen->paletteFadeUp(*data++);
+ _relDelay += 32 * 20; // hack: the screen uses a seperate delay function for the
+ // blocking fadeups. So add 32*20 msecs to out delay counter.
return true;
case FADEDOWN:
_skyScreen->fnFadeDown(0);
+ _relDelay += 32 * 20; // hack: see above.
return true;
case DELAY:
if (!escDelay(*data++))
@@ -794,11 +798,7 @@
}
_system->copyRectToScreen(scrollPos, GAME_SCREEN_WIDTH, 0, 0, GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
_system->updateScreen();
-#ifndef _WIN32_WCE
- if (!escDelay(40))
-#else
- if (!escDelay(15))
-#endif
+ if (!escDelay(60))
doContinue = false;
}
memcpy(_skyScreen->giveCurrent(), scrollPos, FRAME_SIZE);
@@ -890,11 +890,13 @@
bool Intro::escDelay(uint32 msecs) {
OSystem::Event event;
+ if (_relDelay == 0) // first call, init with system time
+ _relDelay = (int32)_system->getMillis();
+
+ _relDelay += msecs; // now wait until _system->getMillis() >= _relDelay
+
+ int32 nDelay = 0;
do {
-#ifdef _WIN32_WCE
- uint32 startTimeLoop = _system->getMillis();
- uint32 delta;
-#endif
while (_system->pollEvent(event)) {
if (event.event_code == OSystem::EVENT_KEYDOWN) {
if (event.kbd.keycode == 27)
@@ -904,22 +906,13 @@
return false;
}
}
-#ifdef _WIN32_WCE
- uint8 nDelay = (msecs > 15) ? (15) : ((uint8)msecs);
-#else
- uint8 nDelay = (msecs > 50) ? (50) : ((uint8)msecs);
-#endif
+ nDelay = _relDelay - _system->getMillis();
+ if (nDelay < 0)
+ nDelay = 0;
+ else if (nDelay > 15)
+ nDelay = 15;
_system->delayMillis(nDelay);
-#ifdef _WIN32_WCE
- delta = _system->getMillis() - startTimeLoop;
- if (delta > msecs)
- break;
- else
- msecs -= delta;
-#else
- msecs -= nDelay;
-#endif
- } while (msecs > 0);
+ } while (nDelay == 15);
return true;
}
Index: intro.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/intro.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- intro.h 6 Jan 2004 12:45:32 -0000 1.5
+++ intro.h 25 Oct 2004 00:27:53 -0000 1.6
@@ -58,6 +58,8 @@
uint32 _bgSize;
PlayingSoundHandle _voice, _bgSfx;
+ int32 _relDelay;
+
bool escDelay(uint32 msecs);
bool nextPart(uint16 *&data);
bool floppyScrollFlirt(void);
Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/screen.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- screen.cpp 28 Sep 2004 20:19:32 -0000 1.60
+++ screen.cpp 25 Oct 2004 00:27:53 -0000 1.61
@@ -245,11 +245,16 @@
// will be scrolled into the visible screen by fnFadeUp
// fnFadeUp also frees the _scrollScreen
} else {
+ uint32 delayTime = _system->getMillis();
for (uint8 cnt = 0; cnt < 32; cnt++) {
+ delayTime += 20;
palette_fadedown_helper((uint32 *)_palette, GAME_COLOURS);
_system->setPalette(_palette, 0, GAME_COLOURS);
_system->updateScreen();
- _system->delayMillis(20);
+ int32 waitTime = (int32)delayTime - _system->getMillis();
+ if (waitTime < 0)
+ waitTime = 0;
+ _system->delayMillis((uint)waitTime);
}
}
}
@@ -289,7 +294,9 @@
convertPalette(pal, tmpPal);
+ uint32 delayTime = _system->getMillis();
for (uint8 cnt = 1; cnt <= 32; cnt++) {
+ delayTime += 20;
for (uint8 colCnt = 0; colCnt < GAME_COLOURS; colCnt++) {
_palette[(colCnt << 2) | 0] = (tmpPal[(colCnt << 2) | 0] * cnt) >> 5;
_palette[(colCnt << 2) | 1] = (tmpPal[(colCnt << 2) | 1] * cnt) >> 5;
@@ -297,7 +304,10 @@
}
_system->setPalette(_palette, 0, GAME_COLOURS);
_system->updateScreen();
- _system->delayMillis(20);
+ int32 waitTime = (int32)delayTime - _system->getMillis();
+ if (waitTime < 0)
+ waitTime = 0;
+ _system->delayMillis((uint)waitTime);
}
}
More information about the Scummvm-git-logs
mailing list