Reworked delay handling.

svn-id: r25324
This commit is contained in:
Johannes Schickel 2007-02-01 15:30:50 +00:00
parent 096f8958c5
commit 7e4fdbb36e
2 changed files with 9 additions and 4 deletions

View File

@ -41,7 +41,6 @@ Sprites::Sprites(KyraEngine *engine, OSystem *system) {
_dat = 0;
memset(_anims, 0, sizeof(_anims));
memset(_sceneShapes, 0, sizeof(_sceneShapes));
_animDelay = 16;
_spriteDefStart = 0;
memset(_drawLayerTable, 0, sizeof(_drawLayerTable));
_sceneAnimatorBeaconFlag = 0;
@ -159,6 +158,7 @@ void Sprites::updateSceneAnims() {
_anims[i].y = READ_LE_UINT16(data);
data += 2;
_anims[i].flipX = false;
_anims[i].lastRefresh = _system->getMillis();
refreshSceneAnimObject(i, _anims[i].sprite, _anims[i].x, _anims[i].y, _anims[i].flipX, _anims[i].unk1 != 0);
break;
case 0xFF8D:
@ -176,13 +176,15 @@ void Sprites::updateSceneAnims() {
_anims[i].y = READ_LE_UINT16(data);
data += 2;
_anims[i].flipX = true;
_anims[i].lastRefresh = _system->getMillis();
refreshSceneAnimObject(i, _anims[i].sprite, _anims[i].x, _anims[i].y, _anims[i].flipX, _anims[i].unk1 != 0);
break;
case 0xFF8A:
data += 2;
debugC(6, kDebugLevelSprites, "func: Set time to wait");
debugC(6, kDebugLevelSprites, "Time %i", READ_LE_UINT16(data));
_anims[i].nextRun = _system->getMillis() + READ_LE_UINT16(data) * _animDelay;
_anims[i].nextRun = _system->getMillis() + READ_LE_UINT16(data) * _engine->tickLength();
_anims[i].nextRun -= _system->getMillis() - _anims[i].lastRefresh;
data += 2;
break;
case 0xFFB3:
@ -193,7 +195,8 @@ void Sprites::updateSceneAnims() {
data += 2;
debugC(6, kDebugLevelSprites, "Maximum time %i", READ_LE_UINT16(data));
data += 2;
_anims[i].nextRun = _system->getMillis() + rndNr * _animDelay;
_anims[i].nextRun = _system->getMillis() + rndNr * _engine->tickLength();
_anims[i].nextRun -= _system->getMillis() - _anims[i].lastRefresh;
break;
case 0xFF8C:
data += 2;
@ -254,6 +257,7 @@ void Sprites::updateSceneAnims() {
_anims[i].sprite = READ_LE_UINT16(data);
_anims[i].flipX = false;
data += 2;
_anims[i].lastRefresh = _system->getMillis();
refreshSceneAnimObject(i, _anims[i].sprite, _anims[i].x, _anims[i].y, _anims[i].flipX, _anims[i].unk1 != 0);
break;
case 0xFF91:
@ -263,6 +267,7 @@ void Sprites::updateSceneAnims() {
_anims[i].sprite = READ_LE_UINT16(data);
_anims[i].flipX = true;
data += 2;
_anims[i].lastRefresh = _system->getMillis();
refreshSceneAnimObject(i, _anims[i].sprite, _anims[i].x, _anims[i].y, _anims[i].flipX, _anims[i].unk1 != 0);
break;
case 0xFF92:

View File

@ -45,6 +45,7 @@ struct Anim {
uint8 *loopStart;
uint16 loopsLeft;
uint32 nextRun;
uint32 lastRefresh;
bool play;
uint16 width;
uint16 height;
@ -85,7 +86,6 @@ protected:
Screen *_screen;
uint8 *_dat;
Common::RandomSource _rnd;
uint8 _animDelay;
uint8 *_spriteDefStart;
uint8 _drawLayerTable[8];
};