mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-29 14:42:26 +00:00
use relative timing instead of constant values.
svn-id: r15684
This commit is contained in:
parent
6fd31192e1
commit
376f51ba79
@ -623,6 +623,7 @@ Intro::Intro(Disk *disk, Screen *screen, MusicBase *music, Sound *sound, Text *t
|
||||
_saveBuf = (uint8*)malloc(10000);
|
||||
_bgBuf = NULL;
|
||||
_quitProg = false;
|
||||
_relDelay = 0;
|
||||
}
|
||||
|
||||
Intro::~Intro(void) {
|
||||
@ -681,9 +682,12 @@ bool Intro::nextPart(uint16 *&data) {
|
||||
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 @@ bool Intro::floppyScrollFlirt(void) {
|
||||
}
|
||||
_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 @@ void Intro::restoreScreen(void) {
|
||||
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 @@ bool Intro::escDelay(uint32 msecs) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,8 @@ private:
|
||||
uint32 _bgSize;
|
||||
PlayingSoundHandle _voice, _bgSfx;
|
||||
|
||||
int32 _relDelay;
|
||||
|
||||
bool escDelay(uint32 msecs);
|
||||
bool nextPart(uint16 *&data);
|
||||
bool floppyScrollFlirt(void);
|
||||
|
@ -245,11 +245,16 @@ void Screen::fnFadeDown(uint32 scroll) {
|
||||
// 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 @@ void Screen::paletteFadeUp(uint8 *pal) {
|
||||
|
||||
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 @@ void Screen::paletteFadeUp(uint8 *pal) {
|
||||
}
|
||||
_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user