LAB: Get rid of the rest of the custom time delay functions
This commit is contained in:
parent
1b0a7db0b6
commit
452c20ab8a
6 changed files with 12 additions and 111 deletions
|
@ -46,8 +46,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
|
|||
_headerdata._height = 0;
|
||||
_headerdata._fps = 0;
|
||||
_headerdata._flags = 0;
|
||||
_waitSec = 0;
|
||||
_waitMicros = 0;
|
||||
_delayMicros = 0;
|
||||
_continuous = false;
|
||||
_isPlaying = false;
|
||||
|
@ -98,8 +96,9 @@ void Anim::diffNextFrame(bool onlyDiffData) {
|
|||
|
||||
if (!onlyDiffData) {
|
||||
if (_headerdata._fps) {
|
||||
_vm->_utils->waitForTime(_waitSec, _waitMicros);
|
||||
_vm->_utils->addCurTime(0L, _delayMicros, &_waitSec, &_waitMicros);
|
||||
uint32 targetMillis = g_system->getMillis() + _delayMicros;
|
||||
while (g_system->getMillis() < targetMillis)
|
||||
g_system->delayMillis(10);
|
||||
}
|
||||
|
||||
if (_isPal && !_noPalChange) {
|
||||
|
@ -273,8 +272,6 @@ void Anim::stopDiffEnd() {
|
|||
*/
|
||||
void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
|
||||
_playOnce = playOnce;
|
||||
_waitSec = 0;
|
||||
_waitMicros = 0;
|
||||
_delayMicros = 0;
|
||||
_header = 0;
|
||||
_curBit = 0;
|
||||
|
|
|
@ -61,8 +61,6 @@ private:
|
|||
uint32 _header;
|
||||
uint16 _curBit;
|
||||
uint16 _numChunks;
|
||||
uint32 _waitSec;
|
||||
uint32 _waitMicros;
|
||||
uint32 _delayMicros;
|
||||
bool _continuous;
|
||||
bool _isPlaying;
|
||||
|
|
|
@ -1145,12 +1145,7 @@ int LabEngine::followCrumbs() {
|
|||
};
|
||||
|
||||
if (_isCrumbWaiting) {
|
||||
uint32 Secs;
|
||||
uint32 Micros;
|
||||
|
||||
_utils->timeDiff(_crumbSecs, _crumbMicros, &Secs, &Micros);
|
||||
|
||||
if (Secs != 0 || Micros != 0)
|
||||
if (g_system->getMillis() <= _crumbSecs * 1000 + _crumbMicros)
|
||||
return 0;
|
||||
|
||||
_isCrumbWaiting = false;
|
||||
|
@ -1193,7 +1188,8 @@ int LabEngine::followCrumbs() {
|
|||
_isCrumbTurning = (moveDir != VKEY_UPARROW);
|
||||
_isCrumbWaiting = true;
|
||||
|
||||
_utils->addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &_crumbSecs, &_crumbMicros);
|
||||
_crumbSecs = (theDelay + g_system->getMillis()) / 1000;
|
||||
_crumbMicros = (theDelay + g_system->getMillis()) % 1000;
|
||||
}
|
||||
|
||||
return moveDir;
|
||||
|
|
|
@ -75,19 +75,13 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
|
|||
char path[50] = "Lab:rooms/Intro/";
|
||||
strcat(path, filename);
|
||||
|
||||
uint timeDelay;
|
||||
if (isScreen) {
|
||||
_vm->_music->updateMusic();
|
||||
timeDelay = 35;
|
||||
} else {
|
||||
_vm->_music->updateMusic();
|
||||
timeDelay = 7;
|
||||
}
|
||||
uint timeDelay = (isScreen) ? 35 : 7;
|
||||
_vm->_music->updateMusic();
|
||||
|
||||
if (_quitIntro)
|
||||
return;
|
||||
|
||||
uint32 lastSecs = 0L, lastMicros = 0L, secs = 0L, micros = 0L;
|
||||
uint32 lastMillis = 0;
|
||||
IntuiMessage *msg;
|
||||
bool drawNextText = true, end = false, begin = true;
|
||||
|
||||
|
@ -132,9 +126,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
|
|||
return;
|
||||
}
|
||||
|
||||
uint32 t = g_system->getMillis();
|
||||
lastSecs = t / 1000;
|
||||
lastMicros = t % 1000;
|
||||
lastMillis = g_system->getMillis();
|
||||
}
|
||||
|
||||
msg = _vm->getMsg();
|
||||
|
@ -143,12 +135,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
|
|||
_vm->_music->updateMusic();
|
||||
_vm->_anim->diffNextFrame();
|
||||
|
||||
uint32 t = g_system->getMillis();
|
||||
secs = t / 1000;
|
||||
micros = t % 1000;
|
||||
_vm->_utils->anyTimeDiff(lastSecs, lastMicros, secs, micros, &secs, µs);
|
||||
uint32 elapsedSeconds = (g_system->getMillis() - lastMillis) / 1000;
|
||||
|
||||
if (secs > timeDelay) {
|
||||
if (elapsedSeconds > timeDelay) {
|
||||
if (end) {
|
||||
if (isScreen)
|
||||
_vm->_graphics->fade(false, 0);
|
||||
|
|
|
@ -427,78 +427,4 @@ void Utils::setBytesPerRow(int num) {
|
|||
_dataBytesPerRow = num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds seconds and microseconds to current time to get a new time.
|
||||
*/
|
||||
void Utils::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
|
||||
uint32 t = g_system->getMillis();
|
||||
*timeSec = (t / 1000) + sec;
|
||||
*timeMicros = (t % 1000) + micros;
|
||||
|
||||
if (*timeMicros >= ONESECOND) {
|
||||
(*timeSec)++;
|
||||
(*timeMicros) -= ONESECOND;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the difference between time1 and time2. If time1 is later than
|
||||
* time2, returns 0.
|
||||
*/
|
||||
void Utils::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros) {
|
||||
*diffSecs = 0;
|
||||
*diffMicros = 0;
|
||||
|
||||
if (sec1 > sec2)
|
||||
return;
|
||||
else if ((sec1 == sec2) && (micros1 >= micros2))
|
||||
return;
|
||||
|
||||
if (micros1 > micros2) {
|
||||
*diffSecs = sec2 - sec1 - 1;
|
||||
*diffMicros = (ONESECOND - micros1) + micros2;
|
||||
} else {
|
||||
*diffSecs = sec2 - sec1;
|
||||
*diffMicros = micros2 - micros1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the difference between the current time, and a future time. Returns
|
||||
* 0 if the future time is actually before the current time.
|
||||
*/
|
||||
void Utils::timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
|
||||
uint32 t = g_system->getMillis();
|
||||
uint32 curSec = t / 1000;
|
||||
uint32 curMicros = t % 1000;
|
||||
|
||||
anyTimeDiff(curSec, curMicros, sec, micros, diffSec, diffMicros);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for Secs seconds and Micros microseconds to pass.
|
||||
*/
|
||||
void Utils::microDelay(uint32 secs, uint32 micros) {
|
||||
uint32 targetMillis = g_system->getMillis() + secs * 1000 + micros;
|
||||
while (g_system->getMillis() < targetMillis)
|
||||
g_system->delayMillis(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for a specified time to occur.
|
||||
*/
|
||||
void Utils::waitForTime(uint32 sec, uint32 micros) {
|
||||
uint32 targetMillis = sec * 1000 + micros;
|
||||
uint32 t = g_system->getMillis();
|
||||
uint32 curSec = t / 1000;
|
||||
uint32 curMicros = t % 1000;
|
||||
|
||||
if (t >= targetMillis)
|
||||
return;
|
||||
|
||||
if (curMicros > micros)
|
||||
microDelay(sec - curSec - 1, (ONESECOND - curMicros) + micros - 1);
|
||||
else
|
||||
microDelay(sec - curSec, micros - curMicros - 1);
|
||||
}
|
||||
} // End of namespace Lab
|
||||
|
|
|
@ -43,7 +43,6 @@ private:
|
|||
void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
|
||||
void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
|
||||
void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
|
||||
void microDelay(uint32 secs, uint32 micros);
|
||||
|
||||
public:
|
||||
Utils(LabEngine *vm);
|
||||
|
@ -60,10 +59,6 @@ public:
|
|||
void runLengthDecode(byte *dest, byte *source);
|
||||
void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
|
||||
void setBytesPerRow(int num);
|
||||
void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
|
||||
void waitForTime(uint32 sec, uint32 micros);
|
||||
void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros);
|
||||
void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue